Commit 49331e07 authored by Giacomo Bernini's avatar Giacomo Bernini Committed by Giacomo Bernini
Browse files

added oauth scope tests for NS Descriptors

parent 5a35f3fc
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ Library JSONSchemaLibrary schemas/
Library    RequestsLibrary
Library    Process
Library    String
Library    jwt
#Variables  descriptors/SOL006/NSD/nsd_SOL006.yaml
#Variables  descriptors/SOL001/NSD/nsd_SOL001.yaml

@@ -147,6 +148,34 @@ Send Post Request to create new Network Service Descriptor Resource
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output} 

Send Post Request to create new Network Service Descriptor Resource with permitted authorization scope
    Log    Creating a new network service descriptor
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${body}=    Get File    jsons/createNsdInfoRequest.json
    ${scopeValue}=    Create Dictionary    scope=${NSD_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Log    Authorization Token: ${authorizationToken}

    REST.POST    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors    ${body}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output} 

Send Post Request to create new Network Service Descriptor Resource with not permitted authorization scope
    Log    Creating a new network service descriptor
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${body}=    Get File    jsons/createNsdInfoRequest.json
    ${scopeValue}=    Create Dictionary    scope=${NSD_NOT_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Log    Authorization Token: ${authorizationToken}

    REST.POST    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors    ${body}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output} 

Check Postcondition NsdInfo Exists
    Log    Checking that nsd info exists
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
@@ -1604,3 +1633,8 @@ Match the NsdmSubscription Response Attributes with NS Descriptors
    Run Keyword If  '${descriptorType}'=='SOL001'    Should Be Equal As Strings    ${response['body']['filter']['nsdVersion']}    ${NS_Version}
    Run Keyword If  '${descriptorType}'=='SOL001'    Should Be Equal As Strings    ${response['body']['filter']['nsdDesigner']}    ${Designer}
    Run Keyword If  '${descriptorType}'=='SOL001'    Should Be Equal As Strings    ${response['body']['filter']['nsdInvariantId']}    ${NS_InvariantID}

JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded} 
+46 −18
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ GET all Network Service Descriptors Information
    ...    Test title: GET all Network Service Descriptors Information
    ...    Test objective: The objective is to test the retrieval of all the Network Service Descriptors information and perform a JSON schema and content validation of the collected data structure
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
@@ -26,7 +26,7 @@ GET Network Service Descriptors Information with attribute-based filter
    ...    Test title: GET Network Service Descriptors Information with attribute-based filter
    ...    Test objective: The objective is to test the retrieval of Network Service Descriptors information using attribute-based filter, perform a JSON schema validation of the collected data structure, and verify that the retrieved information matches the issued attribute-based filter
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
@@ -40,7 +40,7 @@ GET Network Service Descriptors Information with invalid attribute-based filter
    ...    Test title: GET Network Service Descriptors Information with invalid attribute-based filter
    ...    Test objective: The objective is to test that the retrieval of Network Service Descriptors information fails when using invalid attribute-based filter, and perform the JSON schema validation of the failed operation HTTP response
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
@@ -53,7 +53,7 @@ Get all Network Service Descriptors Information with malformed authorization tok
    ...    Test title: Get all Network Service Descriptors Information with malformed authorization token
    ...    Test objective: The objective is to test that the retrieval of Network Service Descriptors Information fails when using malformed authorization token
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: The NFVO requires the usage of access tokens for authorizing the API requests.
    ...    Post-Conditions: none
@@ -65,7 +65,7 @@ Get all Network Service Descriptors Information without authorization token
    ...    Test title: Get all Network Service Descriptors Information without authorization token
    ...    Test objective: The objective is to test that the retrieval of Network Service Descriptors Information fails when omitting the authorization token
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: The NFVO requires the usage of access tokens for authorizing the API requests.
    ...    Post-Conditions: none
@@ -77,7 +77,7 @@ GET all Network Service Descriptors Information with expired or revoked authoriz
    ...    Test title: GET all Network Service Descriptors Information with expired or revoked authorization token
    ...    Test objective: The objective is to test that the retrieval of Network Service Descriptors Information fails when using expired or revoked authorization token
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: The NFVO requires the usage of access tokens for authorizing the API requests.
    ...    Post-Conditions: none
@@ -89,7 +89,7 @@ GET all Network Service Descriptors Information with "all_fields" attribute sele
    ...    Test title: GET all Network Service Descriptors Information with "all_fields" attribute selector
    ...    Test objective: The objective is to test the retrieval of all Network Service Descriptors Information with "all_fields" attribute selector, perform a JSON schema validation of the collected data structure, and verify that the retrieved information matches the issued "all_fileds" selector
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
@@ -103,7 +103,7 @@ GET all Network Service Descriptors Information with "exclude_default" attribute
    ...    Test title: GET all Network Service Descriptors Information with "exclude_default" attribute selector
    ...    Test objective: The objective is to test the retrieval of all Network Service Descriptors Information with "exclude_default" attribute selector, perform a JSON schema validation of the collected data structure, and verify that the retrieved information matches the issued "exclude_default" selector
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
@@ -117,7 +117,7 @@ GET all Network Service Descriptors Information with "fields" attribute selector
    ...    Test title: GET all Network Service Descriptors Information with "fields" attribute selector
    ...    Test objective: The objective is to test the retrieval of all Network Service Descriptors Information with "fields" attribute selector, perform a JSON schema validation of the collected data structure, and verify that the retrieved information matches the issued "fields" selector
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: The NFVO supports the use of "fields" attribute selector
    ...    Post-Conditions: none
@@ -131,7 +131,7 @@ GET all Network Service Descriptors Information with "exclude_fields" attribute
    ...    Test title: GET all Network Service Descriptors Information with "exclude_fields" attribute selector
    ...    Test objective: The objective is to test the retrieval of all Network Service Descriptors Information with "exclude_fields" attribute selector, perform a JSON schema validation of the collected data structure, and verify that the retrieved information matches the issued "exclude_fields" selector
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: The NFVO supports the use of "exclude_fields" attribute selector
    ...    Post-Conditions: none
@@ -145,7 +145,7 @@ Create new Network Service Descriptor Resource
    ...    Test title:  Create new Network Service Descriptor Resource
    ...    Test objective: The objective is to test the creation of a new Create new Network Service Descriptor resource and perform the JSON schema validation of the returned structure
    ...    Pre-conditions: none
    ...    Reference: Clause 5.4.2.3.1 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.1 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: The Network Service Descriptor resource is successfully created on the NFVO
@@ -161,7 +161,7 @@ PUT all Network Service Descriptors - Method not implemented
    ...    Test title: PUT all Network Service Descriptors Information - Method not implemented
    ...    Test objective: The objective is to test that PUT method is not allowed to modify Network Service Descriptors Information
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.3 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.3 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
@@ -173,7 +173,7 @@ PATCH all Network Service Descriptors - Method not implemented
    ...    Test title: PATCH all Network Service Descriptors Information - Method not implemented
    ...    Test objective: The objective is to test that PATCH method is not allowed to update Network Service Descriptors Information
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.4 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.4 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
@@ -185,7 +185,7 @@ DELETE all Network Service Descriptors - Method not implemented
    ...    Test title: DELETE all Network Service Descriptors Information - Method not implemented
    ...    Test objective: The objective is to test that DELETE method is not allowed to delete Network Service Descriptors Information
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.5 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.5 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: The Network Service Descriptors are not deleted by the failed operation
@@ -198,7 +198,7 @@ GET all Network Service Descriptors Information as Paged Response
    ...    Test title: GET all Network Service Descriptors Information as Paged Response
    ...    Test objective: The objective is to test the retrieval of all the Network Service Descriptors information as a Paged Response.
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
@@ -211,7 +211,7 @@ Get all Network Service Descriptors Information - Bad Request Response too Big
    ...    Test title: Get all Network Service Descriptors Information - Bad Request Response too Big
    ...    Test objective: The objective is to test that the retrieval of Network Service Descriptors Information fails because response is too big, and perform the JSON schema validation of the failed operation HTTP response
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: The NFVO requires the usage of access tokens for authorizing the API requests.
    ...    Post-Conditions: none
@@ -224,7 +224,7 @@ GET all Network Service Descriptors Information with "exclude_default" and "fiel
    ...    Test title: GET all Network Service Descriptors Information with "exclude_default" and "fields" attribute selector
    ...    Test objective: The objective is to test the retrieval of all Network Service Descriptors Information with "exclude_default" and "fields" attribute selector, perform a JSON schema validation of the collected data structure, and verify that the retrieved information matches the issued "exclude_default" and "fields" selector
    ...    Pre-conditions: One or more Network Service Descriptors are onboarded in the NFVO
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 5.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: The NFVO supports the use of "exclude_default" and "fields" attribute selector
    ...    Post-Conditions: none
@@ -232,3 +232,31 @@ GET all Network Service Descriptors Information with "exclude_default" and "fiel
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   NsdInfos
    Check HTTP Response Body NsdInfos Matches the requested fields selector

Create new Network Service Descriptor Resource with permitted authorization scope
    [Documentation]    Test ID: 5.3.1.1.18
    ...    Test title:  Create new Network Service Descriptor Resource with permitted authorization scope
    ...    Test objective: The objective is to test the creation of a new Create new Network Service Descriptor resource with permitted authorization scope
    ...    Pre-conditions: none
    ...    Reference: Clause 5.4.2.3.1 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: The Network Service Descriptor resource is successfully created on the NFVO
    Send Post Request to create new Network Service Descriptor Resource with permitted authorization scope
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is   NsdInfo
    Check HTTP Response Header Contains    Location
    Check Postcondition NsdInfo Exists
    Check HTTP Response Body NsInstance content against NS Descriptor

Create new Network Service Descriptor Resource with not permitted authorization scope
    [Documentation]    Test ID: 5.3.1.1.19
    ...    Test title:  Create new Network Service Descriptor Resource with permitted authorization scope
    ...    Test objective: The objective is to test that the creation of a new Create new Network Service Descriptor resource fails when using not permitted authorization scope
    ...    Pre-conditions: none
    ...    Reference: Clause 5.4.2.3.1 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
    Send Post Request to create new Network Service Descriptor Resource with not permitted authorization scope
    Check HTTP Response Status Code Is    401
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
@@ -9,6 +9,14 @@ ${ACCEPT_JSON} application/json
${apiRoot}        /
${AUTH_USAGE}     1
${NEG_AUTHORIZATION_TOKEN}    Bearer negativetoken

${OAUTH_ENCRIPTION_ALGORITHM}    HS256
${NSD_PERMITTED_SCOPE}    nsd:v2:ns_descriptors
${NSD_NOT_PERMITTED_SCOPE}    nsd:v2:ns_descriptors:readonly

${NOT_PERMITTED_SCOPE}    nfvmanologm:v2:nvalid


${apiMajorVersion}     v2
${apiName}        nsd
${MOCK_SERVER_JAR}    ../../../bin/mockserver-netty-5.5.0-jar-with-dependencies.jar