[ROBOT] ADD HTTPS based BULKPM test cases that use helm based components

Add https server based test cases

Signed-off-by: Krzysztof Kuzmicki <krzysztof.kuzmicki@nokia.com>
Issue-ID: INT-1895
Change-Id: I74f7102398a08e1629b50f510ef179d35c8761bd
diff --git a/robot/resources/usecases/5gbulkpm_helm_interface.robot b/robot/resources/usecases/5gbulkpm_helm_interface.robot
index 6707767..8dfc397 100644
--- a/robot/resources/usecases/5gbulkpm_helm_interface.robot
+++ b/robot/resources/usecases/5gbulkpm_helm_interface.robot
@@ -6,6 +6,7 @@
 Library           JSONLibrary
 Resource          ../mr_interface.robot
 Resource          ../dr_interface.robot
+Resource          ../bc_interface.robot
 Resource          ../consul_interface.robot
 Resource          ../chart_museum.robot
 
@@ -37,6 +38,8 @@
 ${CHECK_ENV_SET}                                    kubectl set env pod/$(kubectl get pod -n onap | grep datafile | awk '{print $1}') --list -n onap
 ${COPY_RSA_KEY}                                     kubectl cp /tmp/known_hosts $(kubectl get pod -n onap | grep datafile | awk '{print $1}'):/home/datafile/.ssh/known_hosts -n onap
 ${CHECK_DFC_LOGS}                                   kubectl logs $(kubectl get pod -n onap | grep datafile | awk '{print $1}') -n onap --tail=4
+${CHECK_ALL_DFC_LOGS}                               kubectl logs $(kubectl get pod -n onap | grep datafile | awk '{print $1}') -n onap --all-containers
+${CHECK_ALL_PMMAPPER_LOGS}                          kubectl logs $(kubectl get pod -n onap | grep pm-mapper | awk '{print $1}') -n onap --all-containers
 ${EXPECTED_PRINT}                                   StrictHostKeyChecking is enabled but environment variable KNOWN_HOSTS_FILE_PATH is not set or points to not existing file
 ${MONGO_BLUEPRINT_PATH}                             ${EXECDIR}/robot/assets/cmpv2/k8s-mongo.yaml
 ${PNF_SIMULATOR_BLUEPRINT_PATH}                     ${EXECDIR}/robot/assets/cmpv2/k8s-pnf-simulator.yaml
@@ -47,6 +50,7 @@
 ${consul_change_event}                              dfc/consul.jinja
 ${ves_client_single_event}=                         ves/pnf_simulator_single_event.jinja
 ${SFTP_HELM_CHARTS}                                 ${EXECDIR}/robot/assets/helm/sftp
+${HTTPS_SERVER_HELM_CHARTS}                         ${EXECDIR}/robot/assets/helm/pm-https-server
 ${HELM_RELEASE}                                     kubectl --namespace onap get pods | sed 's/ .*//' | grep robot | sed 's/-.*//'
 
 *** Keywords ***
@@ -73,6 +77,7 @@
 Send File Ready Event to VES Collector and Deploy all DCAE Applications
     [Arguments]                                 ${pm_file}              ${file_format_type}             ${file_format_version}
     Disable Warnings
+    Delete PERFORMANCE_MEASUREMENTS topic
     Setting Global Variables
     Send File Ready Event to VES Collector      ${pm_file}              ${file_format_type}             ${file_format_version}
     Add chart repository                        chart-museum                  http://chart-museum:80      onapinitializer      demo123456!
@@ -82,15 +87,26 @@
     Deploying 3GPP PM Mapper
     Log To Console                              Deploying SFTP Server As xNF
     Deploying SFTP Server As xNF
+    Log To Console                              Deploying HTTPS Server with correct CMPv2 certificates as xNF
+    Deploying HTTPS server with correct certificates
+    Log To Console                              Deploying HTTPS Server with wrong subject alternatives in CMPv2 certificates as xNF
+    Deploying HTTPS server with wrong certificates - wrong SAN-s
     Checking PERFORMANCE_MEASUREMENTS Topic In Message Router
     DR Bulk PM Feed Check
     DR PM Mapper Subscriber Check
 
 Usecase Teardown
     Disable Warnings
-    Uninstall helm charts               ${ONAP_HELM_RELEASE}-dfc
-    Uninstall helm charts               ${ONAP_HELM_RELEASE}-pmmapper
+    Get all logs from PM Mapper
+    Get all logs from Data File Collector
+    Uninstall helm charts               ${ONAP_HELM_RELEASE}-dcae-datafile-collector
+    Uninstall helm charts               ${ONAP_HELM_RELEASE}-dcae-pm-mapper
     Uninstall helm charts               ${ONAP_HELM_RELEASE}-sftp
+    Uninstall helm charts               ${ONAP_HELM_RELEASE}-pm-https-server-correct-sans
+    Uninstall helm charts               ${ONAP_HELM_RELEASE}-pm-https-server-wrong-sans
+
+Delete PERFORMANCE_MEASUREMENTS topic
+    ${resp}=                            Delete MR topic                 /webapi/topics/org.onap.dmaap.mr.PERFORMANCE_MEASUREMENTS
 
 Setting Global Variables
     ${test_variables} =  Create Dictionary
@@ -125,21 +141,6 @@
     Put File                            ${pm_file_path}                    upload/${pm_file}
     [Return]  ${pm_file}
 
-Upload PM Files to xNF HTTPS Server
-    [Arguments]                         ${pm_file_path}                     ${https_server}
-    ${epoch}=                           Get Current Date                    result_format=epoch
-    Set Variable                       A${epoch}.xml.gz
-    Copy File                           ${pm_file_path}                     tmp/${pm_file}
-    ${fileData}=                        Get Binary File                     tmp/${pm_file}
-    ${file_part}=                       Create List                         ${pm_file}                         ${fileData}                   application/octet-stream
-    ${fileParts}=                       Create Dictionary
-    Set to Dictionary                   ${fileParts}                        uploaded_file=${file_part}
-    ${auth}=                            Create List                         demo                                demo123456!
-    ${session}=                         Create Session                      https                               http://${https_server}:80   auth=${auth}
-    ${resp}=                            Post Request                        https                               /upload.php                 files=${fileParts}
-    Should Be Equal As Strings          ${resp.status_code}                 200
-    [Return]                            ${pm_file}
-
 Check Given Print In DFC Log
     [Arguments]                         ${check_dfc_logs}
     ${dfc_logs}=                        Run Given Command On DFC Container                                      ${CHECK_DFC_LOGS}
@@ -167,15 +168,25 @@
     [Return]                            ${output}
 
 Deploying Data File Collector
-    Install helm charts                 chart-museum                       dcae-datafile-collector         ${ONAP_HELM_RELEASE}-dfc          3 min
+    Install helm charts                 chart-museum                       dcae-datafile-collector         ${ONAP_HELM_RELEASE}-dcae-datafile-collector           3 min      --set useCmpv2Certificates=true --set global.cmpv2Enabled=true --set masterPasswordOverride=test --debug
 
 Deploying 3GPP PM Mapper
-    Install helm charts                 chart-museum                       dcae-pm-mapper         ${ONAP_HELM_RELEASE}-pmmapper             3 min
+    Install helm charts                 chart-museum                       dcae-pm-mapper         ${ONAP_HELM_RELEASE}-dcae-pm-mapper             3 min  --debug
 
 Deploying SFTP Server As xNF
-    ${override} =                       Set Variable                       --set fullnameOverride=${ONAP_HELM_RELEASE}-sftp
+    ${override} =                       Set Variable                       --set fullnameOverride=${ONAP_HELM_RELEASE}-sftp --debug
     Install helm charts from folder     ${SFTP_HELM_CHARTS}                ${ONAP_HELM_RELEASE}-sftp                 set_values_override=${override}
 
+Deploying HTTPS server with correct certificates
+    ${name} =                           Set Variable                       ${ONAP_HELM_RELEASE}-pm-https-server-correct-sans
+    ${override} =                       Set Variable                       --set fullnameOverride=${name} --set nameOverride=${name} --set certificates.name=${name} --set certificates.commonName=${name} --set certificates.dnsNames={${name}} --debug
+    Install helm charts from folder     ${HTTPS_SERVER_HELM_CHARTS}        ${name}                 set_values_override=${override}
+
+Deploying HTTPS server with wrong certificates - wrong SAN-s
+    ${name} =                           Set Variable                       ${ONAP_HELM_RELEASE}-pm-https-server-wrong-sans
+    ${override} =                       Set Variable                       --set fullnameOverride=${name} --set nameOverride=${name} --set certificates.name=${name} --set certificates.commonName=wrong-sans-1 --set certificates.dnsNames={wrong-sans-2} --debug
+    Install helm charts from folder     ${HTTPS_SERVER_HELM_CHARTS}        ${name}                 set_values_override=${override}
+
 Checking PERFORMANCE_MEASUREMENTS Topic In Message Router
     ${headers}=                         Create Dictionary                  content-type=application/json
     ${subdata}=                         OperatingSystem.Get File           ${PMMAPPER_SUB_ROLE_DATA}
@@ -228,10 +239,70 @@
     ${dfc_logs}=                     Run Given Command On DFC Container      ${CHECK_DFC_LOGS}
     Should Not Contain               ${dfc_logs}                             ${EXPECTED_PRINT}
 
+Get all logs from PM Mapper
+    ${pmmapper_logs}=                Check logs      ${CHECK_ALL_PMMAPPER_LOGS}
+    Log                              ${pmmapper_logs}
+
+Get all logs from Data File Collector
+    ${pmmapper_logs}=                Check logs      ${CHECK_ALL_DFC_LOGS}
+    Log                              ${pmmapper_logs}
+
 Checking DFC Logs After SFTP Server RSA Key Changed
     Wait Until Keyword Succeeds         5 min  30 sec            Check Given Print In DFC LOG  ${CHECK_DFC_LOGS}
 
-Check DFC logs
-    [Arguments]  ${DFC_LOG_CHECK}
-    ${rc} =                                    Run and Return RC                   ${DFC_LOG_CHECK}
-    Should Be Equal As Integers                ${rc}                               0
+Check logs
+    [Arguments]  ${LOG_CHECK}
+    ${rc} =                                    Run And Return Rc And Output                    ${LOG_CHECK}
+    Should Be Equal As Integers                ${rc[0]}                               0
+    [Return]                                   ${rc[1]}
+
+Change DFC httpsHostnameVerify configuration in Consul
+    [Documentation]     Changes DFC httpsHostnameVerify config.
+    [Arguments]                     ${httpsHostnameVerify}
+    ${httpsHostnameVerify_conf}     Create Dictionary               httpsHostnameVerify=${httpsHostnameVerify}
+    Templating.Create Environment   pm                              ${GLOBAL_TEMPLATE_FOLDER}
+    ${event}=                       Templating.Apply Template       pm                              ${consul_change_event}      ${httpsHostnameVerify_conf}
+    ${rc}   ${container_name} =   Run and Return RC and Output  kubectl get pods -n onap | grep datafile-collector | awk '{print $1}' | grep -v NAME | awk -F'-' '{print $2}'
+    Should Be Equal As Integers   ${rc}                           0
+    ${resp}=                        Run Consul Put Request          /v1/kv/${container_name}-datafile-collector?raw=1          ${event}
+    Should Be Equal As Strings      ${resp.status_code}             200
+    ${rc} =                       Run and Return RC               kubectl delete pods -n onap $(kubectl get pods -n onap | grep datafile-collector | awk '{print $1}' | grep -v NAME)
+    Should Be Equal As Integers   ${rc}                           0
+    Wait Until Keyword Succeeds         120 sec          5 sec       Check logs                  kubectl logs -n onap $(kubectl get pods -n onap | grep datafile-collector | awk '{print $1}' | grep -v NAME) ${container_name}-datafile-collector
+
+Sending File Ready Event to VES Collector for HTTPS Server
+    [Arguments]  ${https-server_host}
+    Send File Ready Event to VES Collector for HTTPS Server  ${PM_FILE}  ${GLOBAL_TEST_VARIABLES["FILE_FORMAT_TYPE"]}  ${GLOBAL_TEST_VARIABLES["FILE_FORMAT_VERSION"]}    ${https-server_host}
+
+Send File Ready Event to VES Collector for HTTPS Server
+    [Arguments]                         ${pm_file}                          ${file_format_type}             ${file_format_version}     ${https_server_host}
+    Disable Warnings
+    ${pm_event}                         Create Dictionary                   https_server_host=${https_server_host}  pm_file=${pm_file}   fileFormatType=${file_format_type}   fileFormatVersion=${file_format_version}
+    Templating.Create Environment       pm                                  ${GLOBAL_TEMPLATE_FOLDER}
+    ${VES_FILE_READY_NOTIFICATION}=     Templating.Apply Template           pm                              ${pm_notification_event}   ${pm_event}
+    ${headers}=                         Create Dictionary                   content-type=application/json
+    ${auth}=                            Create List                         ${GLOBAL_DCAE_VES_USERNAME}     ${GLOBAL_DCAE_VES_PASSWORD}
+    ${session}=                         Create Session                      ves                             ${VES_HEALTH_CHECK_PATH}      auth=${auth}
+    ${resp}=                            Post Request                        ves                             ${VES_LISTENER_PATH}          data=${VES_FILE_READY_NOTIFICATION}   headers=${headers}
+    Should Be Equal As Strings          ${resp.status_code}                 202
+
+
+Uploading PM Files to xNF HTTPS Server
+    [Arguments]                         ${https-server_host}
+    ${pm_file}=                         Upload PM Files to xNF HTTPS Server     ${GLOBAL_TEST_VARIABLES["PM_FILE_PATH"]}    ${https-server_host}
+    Set Global Variable                 ${PM_FILE}                              ${pm_file}
+
+Upload PM Files to xNF HTTPS Server
+    [Arguments]                         ${pm_file_path}                     ${https_server}
+    ${epoch}=                           Get Current Date                    result_format=epoch
+    ${pm_file} =                        Set Variable                        A${epoch}.xml.gz
+    Copy File                           ${pm_file_path}                     tmp/${pm_file}
+    ${fileData}=                        Get Binary File                     tmp/${pm_file}
+    ${file_part}=                       Create List                         ${pm_file}                         ${fileData}                   application/octet-stream
+    ${fileParts}=                       Create Dictionary
+    Set to Dictionary                   ${fileParts}                        uploaded_file=${file_part}
+    ${auth}=                            Create List                         demo                                demo123456!
+    ${session}=                         Create Session                      https                               http://${https_server}:80   auth=${auth}
+    ${resp}=                            Post Request                        https                               /upload.php                 files=${fileParts}
+    Should Be Equal As Strings          ${resp.status_code}                 200
+    [Return]                            ${pm_file}
\ No newline at end of file