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

added oauth scope tests for VNF Pkg mgmt VNF Packages

parent cf0e95d0
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ Library MockServerLibrary
Library           String
Library           Collections
Library           String
Library           jwt
#Variables         descriptors/SOL001/VNFD/vnfd_SOL001.yaml
#Variables         descriptors/SOL006/VNFD/vnfd_SOL006.yaml

@@ -183,6 +184,32 @@ Send Post Request to create new VNF Package Resource
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output} 

Send Post Request to create new VNF Package Resource with permitted authorization scope
    Log    Creating a new VNF Package
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${body} =    Get File    jsons/CreateVnfPkgInfoRequest.json
    ${scopeValue}=    Create Dictionary    scope=${INFO_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}/vnf_packages    ${body}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output} 

Send Post Request to create new VNF Package Resource with not permitted authorization scope
    Log    Creating a new VNF Package
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${body} =    Get File    jsons/CreateVnfPkgInfoRequest.json
    ${scopeValue}=    Create Dictionary    scope=${INFO_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}/vnf_packages    ${body}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output} 
    
    
Check HTTP Response Body vnfPkginfo content against VNF Descriptor
    #${check_descriptors} flag, 1 to check descriptors
@@ -1302,3 +1329,8 @@ Send DELETE Request for VNF Package Artifact
    REST.DELETE    ${apiRoot}/${apiName}/${apiMajorVersion}/vnf_packages/${vnfPackageId}/artifacts
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded} 
 No newline at end of file
+29 −1
Original line number Diff line number Diff line
@@ -220,3 +220,31 @@ GET VNF Packages - Bad Request Response too Big
    GET all VNF Packages
    Check HTTP Response Status Code Is    400
    Check HTTP Response Body Json Schema Is   ProblemDetails

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

Create new VNF Package Resource with not permitted authorization scope
    [Documentation]    Test ID: 5.3.5.1.18
    ...    Test title: Create new VNF Package Resource with not permitted authorization scope
    ...    Test objective: The objective is to test that the creation of a new VNF Package Resource fails when using not permitted authorization scope
    ...    Pre-conditions: none
    ...    Reference: Clause 9.4.2.3.1 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
    Send Post Request to create new VNF Package 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
@@ -5,6 +5,14 @@ ${NFVO_PORT} 8081 # Listening port of the NFVO
${NFVO_SCHEMA}    https
${AUTHORIZATION_HEADER}    Authorization
${AUTHORIZATION_TOKEN}    Bearer 0b79bab50daca910b000d4f1a2b675d604257e42

${OAUTH_ENCRIPTION_ALGORITHM}    HS256
${INFO_PERMITTED_SCOPE}    vnfpkgm:v2::vnf_package_info 
${INFO_NOT_PERMITTED_SCOPE}    vnfpkgm:v2::vnf_package_info:readonly

${NOT_PERMITTED_SCOPE}    vnfpkgm:v2::invalid 


${CONTENT_TYPE_JSON}    application/json
${ACCEPT_JSON}    application/json
${apiRoot}        /