Commit 5519be64 authored by Giacomo Bernini's avatar Giacomo Bernini Committed by Giacomo Bernini
Browse files

added oauth scope tests for PNFD archive content

parent 0b5172f6
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -851,6 +851,32 @@ Send PUT Request to upload PNFD Content as zip file
    ${response}=    Create Dictionary   status=${response.status_code}
    Set Suite Variable      ${response}     ${response}

Send PUT Request to upload PNFD Content as zip file with permitted authorization scope
    Log    Trying to perform a PUT. This method upload the content of a PNFD
    Create Session      pnfd     ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}      headers={"Accept": "${ACCEPT_PLAIN}", "Content-Type": "application/zip", "${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}      verify=False
    ${body}=  Get Binary File  ${contentZipPnfd}
    ${scopeValue}=    Create Dictionary    scope=${PNFD_ARCHIVE_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}
    ${response}=    Put Request     pnfd     ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${pnfdInfoId}/pnfd_content     data=${body}
    Should Be Empty     ${response.text}
    ${response}=    Create Dictionary   status=${response.status_code}
    Set Suite Variable      ${response}     ${response}

Send PUT Request to upload PNFD Content as zip file with not permitted authorization scope
    Log    Trying to perform a PUT. This method upload the content of a PNFD
    Create Session      pnfd     ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}      headers={"Accept": "${ACCEPT_PLAIN}", "Content-Type": "application/zip", "${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}      verify=False
    ${body}=  Get Binary File  ${contentZipPnfd}
    ${scopeValue}=    Create Dictionary    scope=${PNFD_ARCHIVE_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}
    ${response}=    Put Request     pnfd     ${apiRoot}/${apiName}/${apiMajorVersion}/pnf_descriptors/${pnfdInfoId}/pnfd_content     data=${body}
    Should Be Empty     ${response.text}
    ${response}=    Create Dictionary   status=${response.status_code}
    Set Suite Variable      ${response}     ${response}

Send PUT Request to upload PNFD Content with conflict due to onboarding state
    Log    Trying to perform a PUT. This method upload the content of a PNFD
    Set Headers    {"Accept": "${ACCEPT_ZIP}"}
+26 −1
Original line number Diff line number Diff line
@@ -148,3 +148,28 @@ Upload PNFD Archive Content
    Send PUT Request to upload PNFD Content as zip file
    Check HTTP Response Status Code Is    202
    Wait for individual grant successful notification

Upload PNFD Content as zip file with permitted authorization scope
    [Documentation]    Test ID: 5.3.1.6.12
    ...    Test title: Upload PNFD Content as zip file with permitted authorization scope
    ...    Test objective: The objective is to test the upload of a PNFD Content in zip format with permitted authorization scope.
    ...    Pre-conditions: One or more PNFDs are onboarded in the NFVO.
    ...    Reference: Clause 5.4.7.3.3 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: The uploaded PNFD content is available in the NFVO
    Send PUT Request to upload PNFD Content as zip file with permitted authorization scope
    Check HTTP Response Status Code Is    204
    Check Postcondition PNFD Content Exists

Upload PNFD Content as zip file with not permitted authorization scope
    [Documentation]    Test ID: 5.3.1.6.13
    ...    Test title: Upload PNFD Content as zip file with not permitted authorization scope
    ...    Test objective: The objective is to test the upload of a PNFD Content in zip format fails when using not permitted authorization scope.
    ...    Pre-conditions: One or more PNFDs are onboarded in the NFVO.
    ...    Reference: Clause 5.4.7.3.3 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: noe
    Send PUT Request to upload PNFD Content as zip file with permitted authorization scope
    Check HTTP Response Status Code Is    401
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -20,8 +20,8 @@ ${NSD_MANIFEST_PERMITTED_SCOPE} nsd:v2:nsd:readonly
${NSD_ARTIFACTS_PERMITTED_SCOPE}    nsd:<vn>:nsd_artifacts:readonly 
${PNFD_PERMITTED_SCOPE}    nsd:v2:pnf_descriptors
${PNFD_NOT_PERMITTED_SCOPE}    nsd:v2:pnf_descriptors:readonly
${PNF_ARCHIVE_PERMITTED_SCOPE}    nsd:v2:pnfd_archive_content
${ARCHIVE_NOT_PERMITTED_SCOPE}    nsd:v2:pnfd_archive_content:readonly
${PNFD_ARCHIVE_PERMITTED_SCOPE}    nsd:v2:pnfd_archive_content
${PNFD_ARCHIVE_NOT_PERMITTED_SCOPE}    nsd:v2:pnfd_archive_content:readonly
${PNFF_PERMITTED_SCOPE}    nsd:v2:pnfd:readonly
${PNFF_MANIFEST_PERMITTED_SCOPE}    nsd:v2:pnfd:readonly
${PNFD_ARTIFACTS_PERMITTED_SCOPE}    nsd:<vn>:pnfd_artifacts:readonly