Commit 322ab7fd authored by Giacomo Bernini's avatar Giacomo Bernini Committed by Giacomo Bernini
Browse files

added oauth scope tests for nfv mano entity

parent fa02dfaf
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ Library JSONLibrary
Library    Collections
Library    JSONSchemaLibrary    schemas/
Library    Process
Library    jwt

*** Keywords ***
Check HTTP Response Status Code Is
@@ -46,6 +47,28 @@ GET NFV-MANO entity resource
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

GET NFV-MANO entity resource with permitted authorization scope
    Log    Trying to get a NFV-MANO entity resource 
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    ${scopeValue}=    Create Dictionary    scope=${ENTITY_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}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/mano_entity
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

GET NFV-MANO entity resource with not permitted authorization scope
    Log    Trying to get a NFV-MANO entity resource 
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    ${scopeValue}=    Create Dictionary    scope=${ENTITY_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}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/mano_entity
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Send Put request for NFV-MANO Entity  
    Log    Trying to perform a PUT (method should not be implemented)
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
@@ -858,3 +881,9 @@ GET Peer Entities with expired or revoked authorization token
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/peer_entities
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded} 
+27 −1
Original line number Diff line number Diff line
@@ -107,3 +107,29 @@ DELETE NFV-MANO entity - Method not implemented
    ...    Post-Conditions: none
    Send Delete request for NFV-MANO Entity
    Check HTTP Response Status Code Is    405

GET NFV-MANO entity with permitted authorization scope
    [Documentation]    Test ID: 8.3.1.1.9
    ...    Test title: Get NFV-MANO entity with permitted authorization scope
    ...    Test objective: The objective is to test the retrieval of information about an NFV-MANO functional entity by reading the NFV-MANO entity resource when a permitted authorization scope is used.
    ...    Pre-conditions: none
    ...    Reference: clause 5.5.3.3.2 - ETSI GS NFV-SOL 009 [7] v4.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none
    GET NFV-MANO entity resource with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   ManoEntity

GET NFV-MANO entity with not permitted authorization scope
    [Documentation]    Test ID: 8.3.1.1.10
    ...    Test title: Get NFV-MANO entity with not permitted authorization scope
    ...    Test objective: The objective is to test the retrieval of information about an NFV-MANO functional entity fails when a not permitted authorization scope is used.
    ...    Pre-conditions: none
    ...    Reference: clause 5.5.3.3.2 - ETSI GS NFV-SOL 009 [7] v4.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none
    GET NFV-MANO entity resource with not permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   ManoEntity
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
@@ -5,9 +5,17 @@ ${NFVMANO_SCHEMA} https

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

${BAD_AUTHORIZATION_TOKEN}    Bear sometoken

${OAUTH_ENCRIPTION_ALGORITHM}    HS256
${ENTITY_PERMITTED_SCOPE}    nfvpolicy:v2:mano_entity_info
${ENTITY_NOT_PERMITTED_SCOPE}    nfvpolicy:v2:mano_entity_info:readonly
${PEER_PERMITTED_SCOPE}    nfvpolicy:v2:peer_entity_info
${PEER_NOT_PERMITTED_SCOPE}    nfvpolicy:v2:peer_entity_info:readonly
${NOT_PERMITTED_SCOPE}    nfvpolicy:v2:policies:invalid

${CONTENT_TYPE_JSON}    application/json
${ACCEPT_JSON}    application/json
${CONTENT_TYPE_PATCH}    application/merge-patch+json