From 197891b1c2d398de24699ba8c95a89384b5fb158 Mon Sep 17 00:00:00 2001
From: zulfiqar <sana.zulfiqar@xflowresearch.com>
Date: Thu, 11 Mar 2021 09:18:17 +0100
Subject: [PATCH] Added Tests for Individual PNFD archive artifact

---
 .../IndividualPNFDArchiveArtifact.robot       | 173 ++++++++++++++++++
 .../NSDManagementKeywords.robot               |  99 +++++++++-
 .../environment/variables.txt                 |   1 +
 3 files changed, 271 insertions(+), 2 deletions(-)
 create mode 100644 SOL005/NSDManagement-API/IndividualPNFDArchiveArtifact.robot

diff --git a/SOL005/NSDManagement-API/IndividualPNFDArchiveArtifact.robot b/SOL005/NSDManagement-API/IndividualPNFDArchiveArtifact.robot
new file mode 100644
index 00000000..a5d0f192
--- /dev/null
+++ b/SOL005/NSDManagement-API/IndividualPNFDArchiveArtifact.robot
@@ -0,0 +1,173 @@
+*** Settings ***
+Library           JSONSchemaLibrary    schemas/
+Resource          environment/variables.txt    # Generic Parameters
+Resource          NSDManagementKeywords.robot
+Library           JSONLibrary
+Library           REST    ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}    ssl_verify=false
+Library           OperatingSystem
+
+*** Test Cases ***
+GET Individual PNFD Archive Artifact
+    [Documentation]    Test ID: 5.3.1.17.1
+    ...    Test title: GET Individual PNFD Archive Artifact
+    ...    Test objective: The objective is to test the retrieval of an individual PNFD Archive artifact
+    ...    Pre-conditions: One or more PNFD archives are on-boarded in the NFVO.
+    ...    Reference: Clause 5.4.7c.3.2 - ETSI GS NFV-SOL 005 [3] v3.3.1
+    ...    Config ID: Config_prod_NFVO
+    ...    Applicability: none
+    ...    Post-Conditions: none
+    GET Individual PNFD Archive Artifact
+    Check HTTP Response Status Code Is    200
+    
+GET Individual PNFD Archive Artifact with include_signatures parameter
+    [Documentation]    Test ID: 5.3.1.17.2
+    ...    Test title: GET Individual PNFD Archive Artifact with include_signatures parameter
+    ...    Test objective: The objective is to test that the GET request read the whole content of the archive containing the artifact files successfully and also contain security certificates when requested with "include_signature" parameter, and perform a validation that returned content is in Zip format
+    ...    Pre-conditions: One or more PNFD archives are on-boarded to the NFVO.
+    ...    Reference: Clause 5.4.7c.3.2 - ETSI GS NFV-SOL 005 [3] v3.3.1
+    ...    Config ID: Config_prod_NFVO
+    ...    Applicability: none
+    ...    Post-Conditions: none
+    GET Individual PNFD Archive Artifact with include_signatures parameter
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Header Content-Type Is    application/zip
+    
+GET Individual PNFD Archive Artifact in octet stream format
+    [Documentation]    Test ID: 5.3.1.17.3
+    ...    Test title: GET Individual PNFD Archive Artifact in octet stream format
+    ...    Test objective: The objective is to test the retrieval of an individual PNFD Archive artifact when the NFVO cannot determine the artifact content type. The test performs a validation that the returned artifcat in is octet-stream format. 
+    ...    Pre-conditions: One or more PNFD archives are on-boarded to the NFVO.
+    ...    Reference: Clause 5.4.7c.3.2 - ETSI GS NFV-SOL 005 [3] v3.3.1
+    ...    Config ID: Config_prod_NFVO
+    ...    Applicability: The NFVO cannot determine the content type of the artifact
+    ...    Post-Conditions: none
+    GET Individual PNFD Archive Artifact in octet stream format
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Header Content-Type Is    application/octet-stream
+
+GET Individual PNFD Archive Artifact with Range Request and NFVO supporting Range Requests
+    [Documentation]    Test ID: 5.3.1.17.4
+    ...    Test title: GET Individual PNFD Archive Artifact with Range Request and NFVO supporting Range Requests
+    ...    Test objective: The objective is to test the retrieval of an individual PNFD Archive artifact when using a range request to return single range of bytes from the file, with the NFVO supporting it. The test also perform a validation that returned content matches the issued range
+    ...    Pre-conditions: One or more PNFD archives are on-boarded in the NFVO.
+    ...    Reference: Clause 5.4.7c.3.2 - ETSI GS NFV-SOL 005 [3] v3.3.1
+    ...    Config ID: Config_prod_NFVO
+    ...    Applicability: The NFVO supports range requests to return single range of bytes from the PNFD Archive artifact
+    ...    Post-Conditions: none
+    GET Individual PNFD Archive Artifact with Range Request
+    Check HTTP Response Status Code Is    206
+    Check HTTP Response Header Content-Range Is Present and Matches the requested range
+    Check HTTP Response Header Content-Length Is Present and Matches the requested range length
+    
+GET Individual PNFD Archive Artifact with Range Request and NFVO not supporting Range Requests
+    [Documentation]    Test ID: 5.3.1.17.5
+    ...    Test title: GET Individual PNFD Archive Artifact with Range Request and NFVO not supporting Range Requests
+    ...    Test objective: The objective is to test that the retrieval of an individual PNFD archive artifact, when using a range request to return single range of bytes from the file and the NFVO not supporting it, returns the full PNFD Archive artifact.
+    ...    Pre-conditions: One or more PNFD archives are on-boarded in the NFVO.
+    ...    Reference: Clause 5.4.7c.3.2 - ETSI GS NFV-SOL 005 [3] v3.3.1
+    ...    Config ID: Config_prod_NFVO
+    ...    Applicability: The NFVO does not support range requests to return single range of bytes from the PNFD Archive artifact
+    ...    Post-Conditions: none    
+    GET Individual PNFD Archive Artifact with Range Request
+    Check HTTP Response Status Code Is    200
+    
+GET Individual PNFD Archive Artifact with invalid resource identifier
+    [Documentation]    Test ID: 5.3.1.17.6
+    ...    Test title: GET Individual PNFD Archive Artifact with invalid resource identifier
+    ...    Test objective: The objective is to test that the retrieval of an individual PNFD Archive Artifact fails when using an invalid resource identifier
+    ...    Pre-conditions: One or more PNFD archives are on-boarded in the NFVO.
+    ...    Reference: Clause 5.4.7c.3.2 - ETSI GS NFV-SOL 005 [3] v3.3.1
+    ...    Config ID: Config_prod_NFVO
+    ...    Applicability: none
+    ...    Post-Conditions: none    
+    GET Individual PNFD Archive Artifact with invalid resource identifier
+    Check HTTP Response Status Code Is    404
+    Check HTTP Response Body Json Schema Is   ProblemDetails
+    
+GET Individual PNFD Archive Artifact - Not Acceptable
+    [Documentation]    Test ID: 5.3.1.17.7
+    ...    Test title: GET Individual PNFD Archive Artifact - Not Acceptable
+    ...    Test objective: The objective is to test that the retrieval of an individual PNFD Archive artifact fails when related request contained an "Accept" header not compatible with the Content type "application/zip" but the "include_signatures" flag was provided
+    ...    Pre-conditions: One or more PNFD archives are on-boarded to the NFVO.
+    ...    Reference: Clause 5.4.7c.3.2 - ETSI GS NFV-SOL 005 [3] v3.3.1
+    ...    Config ID: Config_prod_NFVO
+    ...    Applicability: none
+    ...    Post-Conditions: none      
+    GET Individual PNFD Archive Artifact with incompatable header
+    Check HTTP Response Status Code Is    406
+    Check HTTP Response Body Json Schema Is   ProblemDetails
+
+GET Individual PNFD Archive Artifact with conflict due to onboarding state
+    [Documentation]    Test ID: 5.3.1.17.8
+    ...    GET Individual PNFD Archive Artifact with conflict due to onboarding state
+    ...    Test objective: The objective is to test that the retrieval of an individual PNFD Archive Artifact fails due to a conflict when the PNFD is not in onboarding state ONBOARDED in the NFVO. The test also performs a validation of the JSON schema validation of the failed operation HTTP response
+    ...    Pre-conditions: The onboarding state of the PNFD archive for which the content is requested is different from ONBOARDED.
+    ...    Reference: Clause 5.4.7c.3.2 - ETSI GS NFV-SOL 005 [3] v3.3.1
+    ...    Config ID: Config_prod_NFVO
+    ...    Applicability: none
+    ...    Post-Conditions: none   
+    GET Individual PNFD Archive Artifact in onboarding state different from ONBOARDED
+    Check HTTP Response Status Code Is    409
+    Check HTTP Response Body Json Schema Is   ProblemDetails
+    
+GET Individual PNFD Archive Artifact with invalid Range Request
+    [Documentation]    Test ID: 5.3.1.17.9
+    ...    Test title: GET Individual PNFD Archive Artifact with invalid Range Request
+    ...    Test objective: The objective is to test that the retrieval of an Individual PNFD Archive fails when using a range request that does not match any available byte range in the file.
+    ...    Pre-conditions: One or more PNFD Archives are on-boarded to the NFVO.
+    ...    Reference: Clause 5.4.7c.3.2 - ETSI GS NFV-SOL 005 [3] v3.3.1
+    ...    Config ID: Config_prod_NFVO
+    ...    Applicability: The NFVO supports range requests to return single range of bytes from the PNFD Archive artifact
+    ...    Post-Conditions: none      
+    GET Individual PNFD Archive Artifact with invalid Range Request
+    Check HTTP Response Status Code Is    416
+    Check HTTP Response Body Json Schema Is   ProblemDetails
+
+POST Individual PNFD Archive Artifact - Method not implemented
+    [Documentation]    Test ID: 5.3.1.17.10
+    ...    Test title: POST Individual PNFD Archive Artifact - Method not implemented
+    ...    Test objective: The objective is to test that POST method is not allowed to create an individual artifact contained in an PNFD archive.
+    ...    Pre-conditions: none
+    ...    Reference: Clause 5.4.7c.3.1 - ETSI GS NFV-SOL 005 [3] v3.3.1
+    ...    Config ID: Config_prod_NFVO
+    ...    Applicability: none
+    ...    Post-Conditions: none
+    Send POST Request for PNFD archive Artifact
+    Check HTTP Response Status Code Is    405
+    
+PUT Individual PNFD Archive Artifact - Method not implemented
+    [Documentation]    Test ID: 5.3.1.17.11
+    ...    Test title: PUT Individual PNFD Archive Artifact - Method not implemented
+    ...    Test objective: The objective is to test that PUT method is not allowed to modify an Individual PNFD Archive artifact
+    ...    Pre-conditions: none
+    ...    Reference: Clause 5.4.7c.3.3 - ETSI GS NFV-SOL 005 [3] v3.3.1
+    ...    Config ID: Config_prod_NFVO
+    ...    Applicability: none
+    ...    Post-Conditions: none
+    Send PUT Request for Individual PNFD Archive Artifact
+    Check HTTP Response Status Code Is    405
+
+PATCH Individual PNFD Archive Artifact - Method not implemented
+    [Documentation]    Test ID: 5.3.1.17.12
+    ...    Test title: PATCH Individual PNFD Archive Artifact - Method not implemented
+    ...    Test objective: The objective is to test that PATCH  method is not allowed to update an Individual PNFD Archive artifact
+    ...    Pre-conditions: none
+    ...    Reference: Clause 5.4.7c.3.4 - ETSI GS NFV-SOL 005 [3] v3.3.1
+    ...    Config ID: Config_prod_NFVO
+    ...    Applicability: none
+    ...    Post-Conditions: none
+    Send PATCH Request for Individual PNFD Archive Artifact
+    Check HTTP Response Status Code Is    405
+
+DELETE Individual PNFD Archive Artifact - Method not implemented
+    [Documentation]    Test ID: 5.3.1.17.13
+    ...    Test title: DELETE Individual PNFD Archive Artifact - Method not implemented
+    ...    Test objective: The objective is to test that DELETE  method is not allowed to delete an Individual PNFD Archive artifact
+    ...    Pre-conditions: none
+    ...    Reference: Clause 5.4.7c.3.5 - ETSI GS NFV-SOL 005 [3] v3.3.1
+    ...    Config ID: Config_prod_NFVO
+    ...    Applicability: none
+    ...    Post-Conditions: none
+    Send DELETE Request for Individual PNFD Archive Artifact
+    Check HTTP Response Status Code Is    405
+    
\ No newline at end of file
diff --git a/SOL005/NSDManagement-API/NSDManagementKeywords.robot b/SOL005/NSDManagement-API/NSDManagementKeywords.robot
index ea4995a0..10b4f011 100644
--- a/SOL005/NSDManagement-API/NSDManagementKeywords.robot
+++ b/SOL005/NSDManagement-API/NSDManagementKeywords.robot
@@ -1318,6 +1318,101 @@ Send DELETE Request for PNFD Archive Manifest
     ${output}=    Output    response
     Set Suite Variable    ${response}    ${output}
     
+Send POST Request for PNFD archive Artifact
+    Pass Execution If    ${testOptionalMethods} == 0    optional methods are not implemented on the FUT. Skipping test.
+    Log    Trying to perform a POST. This method should not be implemented
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
+    REST.POST    ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${pnfdInfoId}/artifacts/${pnfd_artifactPath}
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+    
+Send PUT Request for Individual PNFD Archive Artifact
+    Pass Execution If    ${testOptionalMethods} == 0    optional methods are not implemented on the FUT. Skipping test.
+    Log    Trying to perform a PUT. This method should not be implemented
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
+    REST.PUT   ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${pnfdInfoId}/artifacts/${pnfd_artifactPath}
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+
+Send PATCH Request for Individual PNFD Archive Artifact
+    Pass Execution If    ${testOptionalMethods} == 0    optional methods are not implemented on the FUT. Skipping test.
+    Log    Trying to perform a PATCH. This method should not be implemented
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
+    REST.PATCH   ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${pnfdInfoId}/artifacts/${pnfd_artifactPath}
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+    
+Send DELETE Request for Individual PNFD Archive Artifact
+    Pass Execution If    ${testOptionalMethods} == 0    optional methods are not implemented on the FUT. Skipping test.
+    Log    Trying to perform a DELETE. This method should not be implemented
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
+    REST.DELETE   ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${pnfdInfoId}/artifacts/${pnfd_artifactPath}
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+    
+GET Individual PNFD Archive Artifact
+    Log    Trying to get a PNFD Archive Artifact
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
+    REST.GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${pnfdInfoId}/artifacts/${pnfd_artifactPath}
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+    
+GET Individual PNFD Archive Artifact with include_signatures parameter
+    Log    Trying to get PNFD Archive Artifact with security certificates
+    Set Headers    {"Accept": "${ACCEPT_ZIP}"}
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
+    REST.GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${pnfdInfoId}/artifacts/${pnfd_artifactPath}/include_signatures
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+    
+GET Individual PNFD Archive Artifact in octet stream format
+    Log    Trying to get a PNFD Archive Artifact
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
+    REST.GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${pnfdInfoId}/artifacts/${pnfd_artifactPath}
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+    
+GET Individual PNFD Archive Artifact with Range Request
+    Log    Trying to get an Artifact using RANGE Header and using an NFVO that can handle it
+    Pass Execution If    ${NFVO_RANGE_OK} == 0    Skipping this test as NFVO is not able to handle partial Requests.
+    Set Headers    {"Range": "${range}"}
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
+    REST.GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${pnfdInfoId}/artifacts/${pnfd_artifactPath}
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+    
+GET Individual PNFD Archive Artifact with invalid resource identifier
+    Log    Trying to perform a negative get, using an erroneous PNFD ID
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
+    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${erroneous_pnfdInfoId}/artifacts/${pnfd_artifactPath}
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+    
+GET Individual PNFD Archive Artifact with incompatable header
+    Log    Trying to get a PNFD Archive Artifact
+    Set Headers    {"Accept": "${ACCEPT_PLAIN}"}
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
+    REST.GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${pnfdInfoId}/artifacts/${pnfd_artifactPath}
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+    
+GET Individual PNFD Archive Artifact in onboarding state different from ONBOARDED
+    Log    Trying to get a PNFD Archive artifact present in the NFVO Catalogue, but not in ONBOARDED pnfdOnboardingState
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
+    REST.GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${onboardingStatePnfdId}/artifacts/${pnfd_artifactPath}
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+    
+GET Individual PNFD Archive Artifact with invalid Range Request
+    Log    Trying to get a range of bytes of the limit of the PNFD Archive
+    Pass Execution If    ${NFVO_RANGE_OK} == 0    Skipping this test as NFVO is not able to handle partial Requests.
+    Set Headers    {"Accept": "${ACCEPT_ZIP}"}
+    Set Headers    {"Range": "${erroneousRange}"}
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
+    REST.GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${pnfdInfoId}/artifacts/${pnfd_artifactPath}
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+    
 Send POST Request for NSD archive Artifact
     Pass Execution If    ${testOptionalMethods} == 0    optional methods are not implemented on the FUT. Skipping test.
     Log    Trying to perform a POST. This method should not be implemented
@@ -1372,7 +1467,7 @@ Check HTTP Response Header Content-Length Is Present and Matches the requested r
 GET Individual NSD Archive Artifact with invalid resource identifier
     Log    Trying to perform a negative get, using an erroneous NSD ID
     Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
-    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors/${erroneous_nsdInfoId}/artifacts/${artifactPath}
+    REST.GET    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors/${erroneous_nsdInfoId}/artifacts/${artifactPath}
     ${output}=    Output    response
     Set Suite Variable    ${response}    ${output}
     
@@ -1380,7 +1475,7 @@ GET Individual NSD Archive Artifact with incompatable header
     Log    Trying to get a NSD Archive Artifact
     Set Headers    {"Accept": "${ACCEPT_PLAIN}"}
     Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
-    REST.GET    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors/${nsdInfoId}/artifacts/${artifactPath}/include_signatures
+    REST.GET    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors/${nsdInfoId}/artifacts/${artifactPath}
     ${output}=    Output    response
     Set Suite Variable    ${response}    ${output}
 
diff --git a/SOL005/NSDManagement-API/environment/variables.txt b/SOL005/NSDManagement-API/environment/variables.txt
index 52611838..410a1b4f 100644
--- a/SOL005/NSDManagement-API/environment/variables.txt
+++ b/SOL005/NSDManagement-API/environment/variables.txt
@@ -92,6 +92,7 @@ ${contentZipPnfd}    files/pnfd.zip
 ${contentFilePnfd}    files/pnfd.yml
 ${creatingPnfdId}    2e4ce0ef-3ea8-49f9-92dd-8771866015bb
 ${userDefinedDataSet}    some
+${pnfd_artifactPath}    artifactPath
 
 ${notifCallbackUri}     http://172.22.1.7:9091/nsd/subscriptions
 ${filter_ok}      callbackUri=${notifCallbackUri}
-- 
GitLab