summaryrefslogtreecommitdiffstats
path: root/robot/resources
diff options
context:
space:
mode:
Diffstat (limited to 'robot/resources')
-rw-r--r--robot/resources/sdc_interface.robot1
-rw-r--r--robot/resources/test_templates/vnfsdk_validation_template.robot143
-rw-r--r--robot/resources/vnfsdk_interface.robot7
3 files changed, 151 insertions, 0 deletions
diff --git a/robot/resources/sdc_interface.robot b/robot/resources/sdc_interface.robot
index a85ba27f..4780a35a 100644
--- a/robot/resources/sdc_interface.robot
+++ b/robot/resources/sdc_interface.robot
@@ -778,6 +778,7 @@ Upload SDC Heat Package
Create Multi Part ${files} upload ${file_path} contentType=application/zip
${resp}= SDC.Run Post Files Request ${SDC_BE_ONBOARD_ENDPOINT} ${SDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${software_product_id}/versions/${version_id}${SDC_VENDOR_SOFTWARE_UPLOAD_PATH} ${files} ${SDC_DESIGNER_USER_ID} auth=${GLOBAL_SDC_AUTHENTICATION}
Should Be Equal As Strings ${resp.status_code} 200
+ [Return] ${resp}
Add SDC Catalog Service
[Documentation] Creates an SDC Catalog Service and returns its id
diff --git a/robot/resources/test_templates/vnfsdk_validation_template.robot b/robot/resources/test_templates/vnfsdk_validation_template.robot
new file mode 100644
index 00000000..56cd0b96
--- /dev/null
+++ b/robot/resources/test_templates/vnfsdk_validation_template.robot
@@ -0,0 +1,143 @@
+*** Settings ***
+Documentation This test template encapsulates the VNF Orchestration use case.
+
+Library OperatingSystem
+Library ArchiveLibrary
+Library Collections
+
+Library ONAPLibrary.Templating WITH NAME Templating
+Resource ../global_properties.robot
+Resource ../vnfsdk_interface.robot
+Resource ../sdc_interface.robot
+
+*** Variables ***
+${VNFSDK_TEST} vnfsdk/vnfsdk_validation_request.jinja
+
+
+
+*** Variables ***
+${VNFSDK_TOSCA_ONBOARDING_PACKAGES_DIRECTORY} ${GLOBAL_TOSCA_ONBOARDING_PACKAGES_FOLDER}/vnfsdk
+${VNFSDK_CSAR_DIRECTORY} ${VNFSDK_TOSCA_ONBOARDING_PACKAGES_DIRECTORY}/temp
+@{empty_list}
+*** Keywords ***
+
+Validate Onboarding Package
+ [Arguments] ${package_folder} ${scenario}=onap-vtp ${test_suite_name}=validation ${test_case_name}=csar-validate ${pnf}=TRUE ${secured_package}=FALSE ${negative_test_case}=TRUE ${failed_vnfreqNames}=@{empty_list} ${sdc_response}=@{empty_list} ${secure_type}=CMS ${sdc_cert}=sdc-valid
+ Create Directory ${VNFSDK_CSAR_DIRECTORY}
+ ${onboarding_package_path}= Run Keyword If "${secured_package}"=='FALSE' Create CSAR Package ${package_folder}
+ ... ELSE Create Secured CSAR ZIP Package ${package_folder} ${secure_type} ${sdc_cert}
+ Run Keyword If "${negative_test_case}"=='FALSE' Validate Valid Onboarding Package ${package_folder} ${onboarding_package_path} ${scenario} ${test_suite_name} ${test_case_name} ${pnf} ${secured_package}
+ ... ELSE Validate Not Valid Onboarding Package ${package_folder} ${onboarding_package_path} ${scenario} ${test_suite_name} ${test_case_name} ${pnf} ${failed_vnfreqNames} ${secured_package}
+ Validate Onboarding Package In SDC ${onboarding_package_path} ${package_folder} ${sdc_cert} ${negative_test_case} ${sdc_response} ${sdc_cert}
+
+
+Create CSAR Package
+ [Arguments] ${package_folder}
+ Empty Directory ${VNFSDK_CSAR_DIRECTORY}
+ ${csar}= Catenate ${VNFSDK_CSAR_DIRECTORY}/${package_folder}.csar
+ Copy File ${GLOBAL_TOSCA_ONBOARDING_PACKAGES_FOLDER}/vnfsdk/${package_folder}.csar ${csar}
+ [Return] ${csar}
+
+Create Secured CSAR ZIP Package
+ [Arguments] ${package_folder} ${secure_type} ${sdc_cert}
+ ${zip}= Run Keyword If "${secure_type}"=='CMS' Create Secured CSAR ZIP Package with CMS ${package_folder} ${sdc_cert}
+ ... ELSE Create Secured CSAR ZIP Package with CMS and CERT ${package_folder} ${sdc_cert}
+ [Return] ${zip}
+
+Create Secured CSAR ZIP Package with CMS
+ [Arguments] ${package_folder} ${cert}
+ ${zip}= Catenate ${VNFSDK_CSAR_DIRECTORY}/${package_folder}.zip
+ ${cms}= Catenate ${VNFSDK_CSAR_DIRECTORY}/${package_folder}.cms
+ ${csar}= Create CSAR Package ${package_folder}
+ ${rc} = Run and Return RC openssl cms -sign -signer /tmp/package-robot-${cert}.cert -inkey /tmp/package-private-robot-${cert}.key -outform PEM -binary -in ${csar} -out ${cms}
+ Should Be Equal As Integers ${rc} 0
+ ${rc} = Run and Return RC cd ${VNFSDK_CSAR_DIRECTORY}; zip -r ${zip} *
+ Should Be Equal As Integers ${rc} 0
+ [Return] ${zip}
+
+Create Secured CSAR ZIP Package with CMS and CERT
+ [Arguments] ${package_folder} ${cert}
+ ${zip}= Catenate ${VNFSDK_CSAR_DIRECTORY}/${package_folder}.zip
+ ${cms}= Catenate ${VNFSDK_CSAR_DIRECTORY}/${package_folder}.cms
+ ${csar}= Create CSAR Package ${package_folder}
+ Copy File /tmp/package-robot-${cert}.cert ${VNFSDK_CSAR_DIRECTORY}/${package_folder}.cert
+ ${rc} = Run and Return RC openssl cms -sign -signer /tmp/package-robot-${cert}.cert -inkey /tmp/package-private-robot-${cert}.key -outform PEM -binary -nocerts -in ${csar} -out ${cms}
+ Should Be Equal As Integers ${rc} 0
+ ${rc} = Run and Return RC cd ${VNFSDK_CSAR_DIRECTORY}; zip -r ${zip} *
+ Should Be Equal As Integers ${rc} 0
+ [Return] ${zip}
+
+Validate Valid Onboarding Package
+ [Arguments] ${package_folder} ${onboarding_package_path} ${scenario} ${test_suite_name} ${test_case_name} ${pnf} ${secured_package}
+ ${onboarding_package_name}= Run Keyword If "${secured_package}"=='FALSE' Catenate ${package_folder}.csar
+ ... ELSE Catenate ${package_folder}.zip
+ ${result}= Run VNFSDK Validate Request ${onboarding_package_name} ${onboarding_package_path} ${scenario} ${test_suite_name} ${test_case_name} ${pnf}
+ Log ${result.json()}
+ ${json}= Set Variable ${result.json()}
+ ${status}= Set Variable ${json[0]['results']['criteria']}
+ Should Be Equal As Strings ${status} PASS
+
+Run VNFSDK Validate Request
+ [Arguments] ${onboarding_package_name} ${onboarding_package_path} ${scenario} ${test_suite_name} ${test_case_name} ${pnf}
+ ${arguments}= Create Dictionary scenario=${scenario} onboarding_package_path=${onboarding_package_path} test_suite_name=${test_suite_name} test_case_name=${test_case_name} pnf=${pnf} file_name=${onboarding_package_name}
+ Templating.Create Environment vnfsdk ${GLOBAL_TEMPLATE_FOLDER}
+ ${executions}= Templating.Apply Template vnfsdk ${VNFSDK_TEST} ${arguments}
+ ${fileData}= Get Binary File ${onboarding_package_path}
+ ${fileDir} ${fileName}= Split Path ${onboarding_package_path}
+ ${file_part}= Create List ${fileName} ${fileData} application/octet-stream
+ ${executions_parts}= Create List ${executions}
+ ${fileParts}= Create Dictionary
+ Set to Dictionary ${fileParts} file=${file_part}
+ Set to Dictionary ${fileParts} executions=${executions}
+ ${resp}= Run VNFSDK Post Request /onapapi/vnfsdk-marketplace/v1/vtp/executions ${fileParts}
+ [Return] ${resp}
+
+Validate Not Valid Onboarding Package
+ [Arguments] ${package_folder} ${onboarding_package_path} ${scenario} ${test_suite_name} ${test_case_name} ${pnf} ${failed_req_list} ${secured_package}
+ ${onboarding_package_name}= Run Keyword If "${secured_package}"=='FALSE' Catenate ${package_folder}.csar
+ ... ELSE Catenate ${package_folder}.zip
+ ${result}= Run VNFSDK Validate Request ${onboarding_package_name} ${onboarding_package_path} ${scenario} ${test_suite_name} ${test_case_name} ${pnf}
+ Log ${result.json()}
+ ${json}= Set Variable ${result.json()}
+ ${status}= Set Variable ${json[0]['results']['criteria']}
+ Should Be Equal As Strings ${status} FAILED
+ ${status_req_list}= Set Variable ${json[0]['results']['results']}
+ ${failed_req_from_test_run}= Create List
+ :FOR ${status_req} IN @{status_req_list}
+ \ ${req_status}= Get From Dictionary ${status_req} passed
+ \ Run Keyword If "${req_status}"=='False' Add Failed Requirement To List ${status_req} ${failed_req_from_test_run} vnfreqName
+ Log ${failed_req_from_test_run}
+ Lists Should Be Equal ${failed_req_from_test_run} ${failed_req_list}
+
+Add Failed Requirement To List
+ [Arguments] ${status_req} ${failed_req} ${param_name}
+ ${req}= Get From Dictionary ${status_req} ${param_name}
+ Append To List ${failed_req} ${req}
+
+Get And Comapre Error Responses From SDC API
+ [Arguments] ${resp} ${sdc_response}
+ ${json}= Set Variable ${resp.json()}
+ ${sdc_response_list} Set Variable ${json['errors']['uploadFile']}
+ ${failed_req_from_test_run}= Create List
+ :FOR ${message_item} IN @{sdc_response_list}
+ \ ${req_status}= Get From Dictionary ${message_item} level
+ \ Run Keyword If "${req_status}"=='ERROR' Add Failed Requirement To List ${message_item} ${failed_req_from_test_run} message
+ Log ${failed_req_from_test_run}
+ Lists Should Be Equal ${failed_req_from_test_run} ${sdc_response}
+
+Validate Onboarding Package In SDC
+ [Arguments] ${onboarding_package_path} ${package_folder} ${sdc_validation} ${negative_test_case} ${sdc_response} ${sdc_cert}
+ ${license_model_id} ${license_model_version_id}= Add SDC License Model
+ ${license_temp_date}= Get Current Date
+ ${license_start_date}= Get Current Date result_format=%m/%d/%Y
+ ${license_end_date}= Add Time To Date ${license_temp_date} 365 days result_format=%m/%d/%Y
+ ${key_group_id}= Add SDC License Group ${license_model_id} ${license_model_version_id} ${license_start_date} ${license_end_date}
+ ${pool_id}= Add SDC Entitlement Pool ${license_model_id} ${license_model_version_id} ${license_start_date} ${license_end_date}
+ ${feature_group_id}= Add SDC Feature Group ${license_model_id} ${key_group_id} ${pool_id} ${license_model_version_id}
+ ${license_agreement_id}= Add SDC License Agreement ${license_model_id} ${feature_group_id} ${license_model_version_id}
+ Submit SDC License Model ${license_model_id} ${license_model_version_id}
+ ${license_model_resp}= Get SDC License Model ${license_model_id} ${license_model_version_id}
+ ${software_product_id} ${software_product_version_id}= Add SDC Software Product ${license_agreement_id} ${feature_group_id} ${license_model_resp['vendorName']} ${license_model_id} ${license_model_version_id} ${package_folder}
+ ${resp}= Upload SDC Heat Package ${software_product_id} ${onboarding_package_path} ${software_product_version_id}
+ Run Keyword If "${negative_test_case}"=='TRUE' or "${sdc_cert}"=='sdc-invalid' Get And Comapre Error Responses From SDC API ${resp} ${sdc_response}
+ ... ELSE Validate SDC Software Product ${software_product_id} ${software_product_version_id}
diff --git a/robot/resources/vnfsdk_interface.robot b/robot/resources/vnfsdk_interface.robot
index 01cacf4d..fea6b31a 100644
--- a/robot/resources/vnfsdk_interface.robot
+++ b/robot/resources/vnfsdk_interface.robot
@@ -22,3 +22,10 @@ Run VNFSDK Get Request
Log Received response from VNFSDK ${resp.text}
[Return] ${resp}
+Run VNFSDK Post Request
+ [Documentation] Runs VNFSDK Get request
+ [Arguments] ${data_path} ${files} ${headers}
+ ${session}= Create Session vnfsdk ${VNFSDK_ENDPOINT}
+ ${resp}= Post Request vnfsdk ${data_path} files=${files}
+ Log Received response from VNFSDK ${resp}
+ [Return] ${resp}