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

added oauth scope tests for NSD archive content

parent fcf012bf
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -229,6 +229,31 @@ DELETE NSD Content - Method not implemented
    Send DELETE Request for NSD Content
    Check HTTP Response Status Code Is    405

Upload NSD Content as Zip file in synchronous mode with permitted authorization scope
    [Documentation]    Test ID: 5.3.1.3.19
    ...    Test title: Upload NSD Content as Zip file in synchronous mode  with permitted authorization scope
    ...    Test objective: The objective is to test the upload of an NSD Content in Zip format with permitted authorization scope
    ...    Pre-conditions: One or more NSDs are onboarded in the NFVO.
    ...    Reference: Clause 5.4.4.3.3 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: The NFVO supports the upload of NSD contents in synchronous mode
    ...    Post-Conditions: The NSD content is successfully uploaded and available in the NFVO
    Send PUT Request to upload NSD Content as zip file in synchronous mode with permitted authorization scope
    Check HTTP Response Status Code Is    204
    Check Postcondition NSD Content is uploaded and available in the NFVO

Upload NSD Content as Zip file in synchronous mode with not permitted authorization scope
    [Documentation]    Test ID: 5.3.1.3.20
    ...    Test title: Upload NSD Content as Zip file in synchronous mode with not permitted authorization scope
    ...    Test objective: The objective is to test that the upload of an NSD Content in Zip format fails when using a not permitted authorization scope
    ...    Pre-conditions: One or more NSDs are onboarded in the NFVO.
    ...    Reference: Clause 5.4.4.3.3 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: The NFVO supports the upload of NSD contents in synchronous mode
    ...    Post-Conditions: none
    Send PUT Request to upload NSD Content as zip file in synchronous mode with not permitted authorization scope
    Check HTTP Response Status Code Is    401

*** Keywords ***
Void
    log    do nothing
+24 −0
Original line number Diff line number Diff line
@@ -438,6 +438,30 @@ Send PUT Request to upload NSD Content as zip file in synchronous mode
    ${response}=    Create Dictionary   status=${response.status_code}
    Set Suite Variable      ${response}     ${response}

Send PUT Request to upload NSD Content as zip file in synchronous mode with permitted authorization scope
    Create Session      nbi     ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}  headers={"Accept": "${ACCEPT_JSON}", "Content-Type": "application/zip", "${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}      verify=False
    ${body}=  Get Binary File  ${contentZipNsd}
    ${scopeValue}=    Create Dictionary    scope=${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     nbi     ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors/${nsdInfoIdZip}/nsd_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 NSD Content as zip file in synchronous mode with not permitted authorization scope
    Create Session      nbi     ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}  headers={"Accept": "${ACCEPT_JSON}", "Content-Type": "application/zip", "${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}      verify=False
    ${body}=  Get Binary File  ${contentZipNsd}
    ${scopeValue}=    Create Dictionary    scope=${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     nbi     ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors/${nsdInfoIdZip}/nsd_content     data=${body}
    Should Be Empty     ${response.text}
    ${response}=    Create Dictionary   status=${response.status_code}
    Set Suite Variable      ${response}     ${response}

Check Post Condition NSD Content has been Uploaded
    Log    Checking NsdOnboardingNotification Recieved
    Wait Until Keyword Succeeds    ${retry}    ${interval}  Check Response is NsdOnboardingNotification
+3 −0
Original line number Diff line number Diff line
@@ -13,6 +13,9 @@ ${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
${ARCHIVE_PERMITTED_SCOPE}    nsd:v2:nsd_archive_content
${ARCHIVE_NOT_PERMITTED_SCOPE}    nsd:v2:nsd_archive_content:readonly


${NOT_PERMITTED_SCOPE}    nfvmanologm:v2:nvalid