Add test for csar validation get result using execution id. 70/113570/2
authorBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Tue, 6 Oct 2020 12:03:36 +0000 (14:03 +0200)
committerBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Wed, 7 Oct 2020 05:23:46 +0000 (07:23 +0200)
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Change-Id: Ie58b355f534d871b72f2b81efcf10d3a0e9cc662
Issue-ID: VNFSDK-659

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

diff --git a/tests/vnfsdk-refrepo/csar/invalid_pm_dictionary.csar b/tests/vnfsdk-refrepo/csar/invalid_pm_dictionary.csar
new file mode 100644 (file)
index 0000000..81a0e23
Binary files /dev/null and b/tests/vnfsdk-refrepo/csar/invalid_pm_dictionary.csar differ
index afe4301..3ae5925 100644 (file)
@@ -5,14 +5,15 @@ Resource          ./resources/vnfsdk_keywords.robot
 
 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}
+
+    ${response}=   Validate CSAR usign Post request   ${csar_valid_no_security}   ${execute_no_security_csar_validation}
     # 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   \\"
@@ -22,3 +23,25 @@ Validate correct, no security CSAR
         Should Be Equal As Strings   ${resault["errors"]}   []
         Should Be Equal As Strings   ${resault["passed"]}   True
     END
+
+
+Validate CSAR and use get method to receive outcome
+    [Documentation]    Validate CSAR with invalid PM_Dictionary (r130206), then use get method with validation id to receive valdiation outcome
+
+    ${response}=   Validate CSAR usign Post request   ${csar_invalid_pm_dictionary}   ${execute_invalid_pm_dictionary_validation}
+    # 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
+
+    ${get_response}=   Get validation result using GET request    ${json_response[0]["executionId"]}
+    # 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
+    ${get_response}=   Remove String    ${get_response}    \\\\    \\u0027
+    ${json_get_response}=    evaluate    json.loads('''${get_response}''')    json
+    Should Be Equal As Strings   ${json_get_response[0]["status"]}   failed
+    ${errors_number}=    Get Length    ${json_get_response[0]["results"]}
+    Should Be Equal As Strings  ${errors_number}  4
+    FOR   ${error}  IN  @{json_get_response[0]["results"]}
+        Should Contain   ${error["code"]}  R130206
+    END
index 1bdcf71..11bb601 100644 (file)
@@ -1,4 +1,6 @@
 *** Settings ***
+Resource          ./vnfsdk_properties.robot
+
 Library           OperatingSystem
 Library           Process
 Library           String
@@ -6,10 +8,18 @@ Library           Collections
 Library           RequestsLibrary
 Library           json
 
-*** Variables ***
-${base_url}=    http://${REFREPO_IP}:8702/onapapi/vnfsdk-marketplace/v1
+*** Keywords ***
 
-${csarpath}=    ${SCRIPTS}/../tests/vnfsdk-refrepo/csar
+Validate CSAR usign Post request
+    [Documentation]    Perform POST Request to vnfsdk marketplace with CSAR and execution options, in order to perfvorm CSAR validation
+    [Arguments]    ${csar_name}  ${execution_json}
+    ${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_name}' --form 'executions=${execution_json}'
+    ${response}=    String.Replace String    ${response}    \\n   ${SPACE}
+    [Return]     ${response}
 
-${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"}}]
+Get validation result using GET request
+    [Documentation]    Perform GET request to vnfsdk marketplace with request id or execution id, in order to get that request/execution result
+    [Arguments]    ${requestId}
+    ${response}=   Run   curl -s --location --request GET '${base_url}/vtp/executions?requestId=${requestId}' --header 'Accept: application/json'
+    ${response}=    String.Replace String    ${response}    \\n   ${SPACE}
+    [Return]     ${response}
diff --git a/tests/vnfsdk-refrepo/resources/vnfsdk_properties.robot b/tests/vnfsdk-refrepo/resources/vnfsdk_properties.robot
new file mode 100644 (file)
index 0000000..8390b93
--- /dev/null
@@ -0,0 +1,12 @@
+*** 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"}}]
+
+
+${csar_invalid_pm_dictionary}=  invalid_pm_dictionary.csar
+${execute_invalid_pm_dictionary_validation}=  [{"scenario": "onap-dublin","testSuiteName": "validation","testCaseName": "csar-validate-r130206","parameters": {"csar": "file://${csar_invalid_pm_dictionary}","pnf":"true"}}]
+