Commit e62f6a5b authored by Giacomo Bernini's avatar Giacomo Bernini Committed by Giacomo Bernini
Browse files

added oauth scope tests for NSLCM NS Instances

parent 29db9586
Loading
Loading
Loading
Loading
+46 −19
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ POST Create a new NsInstance
    ...    Test title: POST Create a new NsInstance
    ...    Test objective: The objective is to test the creation of a new Ns Instances and perform a JSON schema validation of the collected instance data structure
    ...    Pre-conditions: none.
    ...    Reference: Clause 6.4.2.3.1 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 6.4.2.3.1 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none.
    ...    Post-Conditions: A Ns instance is instantiated.
@@ -27,7 +27,7 @@ GET information about multiple NS instances
    ...    Test title: GET information about multiple NS instances
    ...    Test objective: The objective is to test the retrieval of all the available NS Instances and perform a JSON schema and content validation of the collected instance data structure
    ...    Pre-conditions: An existing Ns instance.
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none.
    ...    Post-Conditions: none.
@@ -39,8 +39,8 @@ GET information about multiple NS instances Bad Request Invalid attribute-based
    [Documentation]    Test ID: 5.3.2.1.3
    ...    Test title: GET information about multiple NS instances Bad Request Invalid attribute-based filtering parameters
    ...    Test objective: The objective is to test the retrieval of all the available NS Instances using attribute-based filter and perform a JSON schema and content validation of the collected instance data structure
    ...    Pre-conditions: A Ns instance is instantiated, a bad filter parameter (filter parameters are listed in Table 6.4.2.3.2-1  - ETSI GS NFV-SOL 005 [3] v4.5.1).
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Pre-conditions: A Ns instance is instantiated, a bad filter parameter (filter parameters are listed in Table 6.4.2.3.2-1  - ETSI GS NFV-SOL 005 [3] v4.4.1).
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none.
    ...    Post-Conditions: none.
@@ -52,8 +52,8 @@ GET information about multiple NS instances Bad Request Invalid attribute select
    [Documentation]    Test ID: 5.3.2.1.4
    ...    Test title: GET information about multiple NS instances Bad Request Invalid attribute selector
    ...    Test objective: The objective is to test the retrieval of all the available NS Instances using attribute-based filter and perform a JSON schema and content validation of the collected instance data structure
    ...    Pre-conditions: A Ns instance is instantiated,  a bad attribute selector (attribute selectors are listed in Table 6.4.2.3.2-1  - ETSI GS NFV-SOL 005 [3] v4.5.1).
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Pre-conditions: A Ns instance is instantiated,  a bad attribute selector (attribute selectors are listed in Table 6.4.2.3.2-1  - ETSI GS NFV-SOL 005 [3] v4.4.1).
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none.
    ...    Post-Conditions: none.
@@ -66,7 +66,7 @@ GET NSInstances with "all_fields" attribute selector
    ...    Test title: GET NSInstances with "all_fields" attribute selector
    ...    Test objective: The objective is to retrieve the list of active NSInstances with attribute selector
    ...    Pre-conditions: none
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability:  none
    ...    Post-Conditions: none
@@ -79,7 +79,7 @@ GET NSInstances with "exclude_default" attribute selector
    ...    Test title: GET NSInstances with "exclude_default" attribute selector
    ...    Test objective: The objective is to retrieve the list of active NSInstances with attribute selector
    ...    Pre-conditions: none
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability:  none
    ...    Post-Conditions: none
@@ -92,7 +92,7 @@ GET NSInstances with "fields" attribute selector
    ...    Test title: GET NSInstances with "fields" attribute selector
    ...    Test objective: The objective is to retrieve the list of active NSInstances with attribute selector
    ...    Pre-conditions: none
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability:  none
    ...    Post-Conditions: none
@@ -105,7 +105,7 @@ GET NSInstances with "exclude_fields" attribute selector
    ...    Test title: GET NSInstances with "exclude_fields" attribute selector
    ...    Test objective: The objective is to retrieve the list of active NSInstances with attribute selector
    ...    Pre-conditions: none
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability:  none
    ...    Post-Conditions: none
@@ -118,7 +118,7 @@ PUT NSInstances - Method not implemented
    ...    Test title: PUT Individual NS instance - Method not implemented
    ...    Test objective: The objective is to test that PUT method is not implemented
    ...    Pre-conditions: none
    ...    Reference: Clause 6.4.2.3.3 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 6.4.2.3.3 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
@@ -130,7 +130,7 @@ PATCH NSInstances - Method not implemented
    ...    Test title: PATCH NSInstances - Method not implemented
    ...    Test objective: The objective is to test that PATCH method is not implemented
    ...    Pre-conditions: none
    ...    Reference: Clause 6.4.2.3.4 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 6.4.2.3.4 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
@@ -142,7 +142,7 @@ DELETE NSInstances - Method not implemented
    ...    Test title: DELETE NSInstances - Method not implemented
    ...    Test objective: The objective is to test that DELETE method is not implemented
    ...    Pre-conditions: none
    ...    Reference: Clause 6.4.2.3.5 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 6.4.2.3.5 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
@@ -154,7 +154,7 @@ GET information about multiple NS instances as Paged Response
    ...    Test title: GET information about multiple NS instances as Paged Response
    ...    Test objective: The objective is to test the retrieval of all the available NS Instances as a Paged Response.
    ...    Pre-conditions: An existing Ns instance.
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none.
    ...    Post-Conditions: none.
@@ -166,8 +166,8 @@ GET information about multiple NS instances - Bad Request Response too Big
    [Documentation]    Test ID: 5.3.2.1.13
    ...    Test title: GET information about multiple NS instances - Bad Request Response too Big
    ...    Test objective: The objective is to test the retrieval of all the available NS Instances fails because reponse is too big, and perform a JSON schema and content validation of the collected instance data structure
    ...    Pre-conditions: A Ns instance is instantiated,  a bad attribute selector (attribute selectors are listed in Table 6.4.2.3.2-1  - ETSI GS NFV-SOL 005 [3] v4.5.1).
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Pre-conditions: A Ns instance is instantiated,  a bad attribute selector (attribute selectors are listed in Table 6.4.2.3.2-1  - ETSI GS NFV-SOL 005 [3] v4.4.1).
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none.
    ...    Post-Conditions: none.
@@ -180,7 +180,7 @@ GET NSInstances with "fields" and "exclude_default" attribute selector
    ...    Test title: GET NSInstances with "fields" and "exclude_default" attribute selector
    ...    Test objective: The objective is to retrieve the list of active NSInstances with attribute selector list and exclude_default
    ...    Pre-conditions: none
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability:  none
    ...    Post-Conditions: none
@@ -193,10 +193,37 @@ GET information about multiple NS instances - Filter
    ...    Test title: GET information about multiple NS instances - Filter
    ...    Test objective: The objective is to test the retrieval of NS Instances using filter and perform a JSON schema and content validation of the collected instance data structure
    ...    Pre-conditions: An existing Ns instance.
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Reference: Clause 6.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none.
    ...    Post-Conditions: none.
    GET NsInstances using filtering parameter
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    NsInstances  

POST Create a new NsInstance with permitted authorization scope
    [Documentation]    Test ID: 5.3.2.1.16
    ...    Test title: POST Create a new NsInstance with permitted authorization scope
    ...    Test objective: The objective is to test the creation of a new Ns Instances with permitted authorization scope
    ...    Pre-conditions: none.
    ...    Reference: Clause 6.4.2.3.1 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none.
    ...    Post-Conditions: A Ns instance is instantiated.
    POST New nsInstance with permitted authorization scope
    Check HTTP Response Status Code Is    201
    Check HTTP Response Header Contains    Location
    Check HTTP Response Body Json Schema Is    NsInstance
    Check HTTP Response Body NsInstance content against NS Descriptor

POST Create a new NsInstance with not permitted authorization scope
    [Documentation]    Test ID: 5.3.2.1.17
    ...    Test title: POST Create a new NsInstance with not permitted authorization scope
    ...    Test objective: The objective is to test that the creation of a new Ns Instances fails when using a not permitted authorization scope
    ...    Pre-conditions: none.
    ...    Reference: Clause 6.4.2.3.1 - ETSI GS NFV-SOL 005 [3] v4.4.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none.
    ...    Post-Conditions: none.
    POST New nsInstance with not permitted authorization scope
    Check HTTP Response Status Code Is    401
 No newline at end of file
+35 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ Library OperatingSystem
Library    MockServerLibrary
Library    Collections
Library    String
Library    jwt
#Variables  descriptors/SOL006/VNFD/vnfd_SOL006.yaml
#Variables  descriptors/SOL006/NSD/nsd_SOL006.yaml
#Variables  descriptors/SOL001/VNFD/vnfd_SOL001.yaml
@@ -229,6 +230,36 @@ POST New nsInstance
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}     

POST New nsInstance with permitted authorization scope
    Log    Create NS instance by POST to ${apiRoot}/${apiName}/${apiMajorVersion}/ns_instances
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    ${scopeValue}=    Create Dictionary    scope=${NSINSTANCE_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}
    Run Keyword If    ${check_descriptors} == 1    PARSE the NS Descriptor File
    ${template}=    Get File    jsons/CreateNsRequest.json 
    ${body}=        Format String   ${template}     nsdId=${NS_DescriptorID}   nsInstanceName=${nsInstanceName}   vimAccountId=${vimAccountId}   nsInstanceDescription=${nsInstanceDescription}
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_instances    ${body}
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}     

POST New nsInstance with not permitted authorization scope
    Log    Create NS instance by POST to ${apiRoot}/${apiName}/${apiMajorVersion}/ns_instances
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    ${scopeValue}=    Create Dictionary    scope=${NSINSTANCE_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}
    Run Keyword If    ${check_descriptors} == 1    PARSE the NS Descriptor File
    ${template}=    Get File    jsons/CreateNsRequest.json 
    ${body}=        Format String   ${template}     nsdId=${NS_DescriptorID}   nsInstanceName=${nsInstanceName}   vimAccountId=${vimAccountId}   nsInstanceDescription=${nsInstanceDescription}
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_instances    ${body}
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

Check HTTP Response Body NsInstance content against VNF Descriptor
    #${check_descriptors} flag, 1 to check descriptors
    Run Keyword If    ${check_descriptors} == 1    Check Individual NsInstance Content
@@ -1718,4 +1749,7 @@ Configure Notification NS Creation Deletion Handler
    &{notification_response}=  Create Mock Response    headers=${headers}    status_code=204
    Create Mock Expectation  ${notification_request}  ${notification_response}

JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded} 
+6 −0
Original line number Diff line number Diff line
@@ -5,6 +5,12 @@ ${NFVO_SCHEMA} https

${AUTHORIZATION_HEADER}    Authorization
${AUTHORIZATION_TOKEN}    Bearer 0b79bab50daca910b000d4f1a2b675d604257e42

${OAUTH_ENCRIPTION_ALGORITHM}    HS256
${NSINSTANCE_PERMITTED_SCOPE}    nslcm:v2:instantiate 
${NSINSTANCE_NOT_PERMITTED_SCOPE}    nslcm:v2:instantiate:readonly


${CONTENT_TYPE}    application/json
${ACCEPT_JSON}         application/json
${ACCEPT}         application/json