Add test for csar validation in vnfsdk refrepo. 56/113556/2
authorBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Tue, 6 Oct 2020 06:12:12 +0000 (08:12 +0200)
committerBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Tue, 6 Oct 2020 08:19:36 +0000 (10:19 +0200)
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Change-Id: Ia4c3b58e5c614a947b1bf69eb9b5cd806b722568
Issue-ID: VNFSDK-659

tests/vnfsdk-refrepo/csar/valid_no_security.csar [new file with mode: 0644]
tests/vnfsdk-refrepo/csar_validation_tests.robot
tests/vnfsdk-refrepo/resources/vnfsdk_keywords.robot [new file with mode: 0644]

diff --git a/tests/vnfsdk-refrepo/csar/valid_no_security.csar b/tests/vnfsdk-refrepo/csar/valid_no_security.csar
new file mode 100644 (file)
index 0000000..11d1945
Binary files /dev/null and b/tests/vnfsdk-refrepo/csar/valid_no_security.csar differ
index 88075c6..afe4301 100644 (file)
@@ -1,18 +1,24 @@
 *** Settings ***
-Library           OperatingSystem
-Library           Process
-Library           String
-Library           Collections
-Library           RequestsLibrary
-Library           json
-
-
-*** Variables ***
-${base_url}=    http://${REFREPO_IP}:8702/onapapi/vnfsdk-marketplace/v1
+Resource          ./resources/vnfsdk_keywords.robot
 
 *** Test Cases ***
+
 Perform vnf refrepo healthcheck
     [Documentation]    Check if vnf refrepo is up and running
     Create Session   refrepo  ${base_url}
     ${response}=    Get Request    refrepo   /PackageResource/healthcheck
     Should Be Equal As Strings  ${response.status_code}     200
+
+Validate correct, no security CSAR
+    [Documentation]    Valid CSAR with no security should PASS validation and should return no error
+    ${response}=   Run   curl -s --location --request POST '${base_url}/vtp/executions' --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --form 'file=@${csarpath}/${csar_valid_no_security}' --form 'executions=${execute_no_security_csar_validation}'
+    ${response}=    String.Replace String    ${response}    \\n   ${SPACE}
+    # Removing strings that are causing errors during evaluation,
+    # those strings are dependent on validation response and may need to be changed if vnf refrepo response changes
+    ${response}=   Remove String    ${response}    \\\\    \\u003c    \\u003e   \\"
+    ${json_response}=    evaluate    json.loads('''${response}''')    json
+    Should Be Equal As Strings    ${json_response[0]["results"]["criteria"]}   PASS
+    FOR   ${resault}  IN  @{json_response[0]["results"]["results"]}
+        Should Be Equal As Strings   ${resault["errors"]}   []
+        Should Be Equal As Strings   ${resault["passed"]}   True
+    END
diff --git a/tests/vnfsdk-refrepo/resources/vnfsdk_keywords.robot b/tests/vnfsdk-refrepo/resources/vnfsdk_keywords.robot
new file mode 100644 (file)
index 0000000..1bdcf71
--- /dev/null
@@ -0,0 +1,15 @@
+*** Settings ***
+Library           OperatingSystem
+Library           Process
+Library           String
+Library           Collections
+Library           RequestsLibrary
+Library           json
+
+*** Variables ***
+${base_url}=    http://${REFREPO_IP}:8702/onapapi/vnfsdk-marketplace/v1
+
+${csarpath}=    ${SCRIPTS}/../tests/vnfsdk-refrepo/csar
+
+${csar_valid_no_security}=  valid_no_security.csar
+${execute_no_security_csar_validation}=  [{"scenario": "onap-dublin","testSuiteName": "validation","testCaseName": "csar-validate","parameters": {"csar": "file://${csar_valid_no_security}","pnf":"true"}}]