Commit 21db903f authored by Giacomo Bernini's avatar Giacomo Bernini Committed by Giacomo Bernini
Browse files

added oauth scope tests for NS LCM Coordinations

parent 40931c5a
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -141,3 +141,30 @@ DELETE all Coordinations of an LCM operation occurrence - method not implemented
    ...    Post-Conditions: none
    DELETE all Coordinations of an LCM operation occurrence
    Check HTTP Response Status Code Is    405

Request a Coordination of an LCM operation occurrence synchronously with permitted authorization scope
    [Documentation]    Test ID: 5.3.8.2.10
    ...    Test title:  Request a Coordination of an LCM operation occurrence synchronously with permitted authorization scope
    ...    Test objective: The objective is to test the synchronous request for the coordination of an LCM operation occurrence with permitted authorization scope
    ...    Pre-conditions: The status of the related LCM opeation occurrence is "PROCESSING"
    ...    Reference: Clause 12.4.2.3.1 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Config ID: Config_prod_OSS/BSS
    ...    Applicability: none
    ...    Post-Conditions: A Individual coordination action resource is successfully created on the NFVO
    Send Post Request for coordination of an LCM operation occurrence with permitted authorization scope
    Check HTTP Response Status Code Is    201
    Check HTTP Response Header Contains    Location
    Check HTTP Response Body Json Schema Is   LcmCoord
    Check Postcondition LcmCoord Exists

Request a Coordination of an LCM operation occurrence synchronously with not permitted authorization scope
    [Documentation]    Test ID: 5.3.8.2.10
    ...    Test title:  Request a Coordination of an LCM operation occurrence synchronously with not permitted authorization scope
    ...    Test objective: The objective is to test that the synchronous request for the coordination of an LCM operation occurrence fails when using not permitted authorization scope
    ...    Pre-conditions: The status of the related LCM opeation occurrence is "PROCESSING"
    ...    Reference: Clause 12.4.2.3.1 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Config ID: Config_prod_OSS/BSS
    ...    Applicability: none
    ...    Post-Conditions: none
    Send Post Request for coordination of an LCM operation occurrence with 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
@@ -10,6 +10,7 @@ Library JSONSchemaLibrary schemas/
Library    RequestsLibrary
Library    Process
Library    String
Library    jwt

*** Keywords ***
Send Post Request for coordination of an LCM operation occurrence
@@ -23,6 +24,34 @@ Send Post Request for coordination of an LCM operation occurrence
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output} 

Send Post Request for coordination of an LCM operation occurrence with permitted authorization scope
    Log    Requesting a new coordination task for an LCM Operation occurrence
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${template}=    Get File    jsons/createLcmCoordRequest.json
    ${body}=        Format String    ${template}    nsInstanceId=${nsInstanceId}    nsLcmOpOccId=${nsLcmOpOccId}    lcmOperationType=${lcmOperationType}    coordinationActionName=${coordinationActionName}    nsLcmOpOccHref=${nsLcmOpOccHref}    nsInstanceHref=${nsInstanceHref}     
    ${scopeValue}=    Create Dictionary    scope=${ALL_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Run Keyword If    ${NFVO_AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Log    Authorization Token: ${authorizationToken}
    REST.POST    ${apiRoot}/${apiName}/${apiMajorVersion}/coordinations    ${body}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output} 

Send Post Request for coordination of an LCM operation occurrence with not permitted authorization scope
    Log    Requesting a new coordination task for an LCM Operation occurrence
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${template}=    Get File    jsons/createLcmCoordRequest.json
    ${body}=        Format String    ${template}    nsInstanceId=${nsInstanceId}    nsLcmOpOccId=${nsLcmOpOccId}    lcmOperationType=${lcmOperationType}    coordinationActionName=${coordinationActionName}    nsLcmOpOccHref=${nsLcmOpOccHref}    nsInstanceHref=${nsInstanceHref}     
    ${scopeValue}=    Create Dictionary    scope=${NOT_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Run Keyword If    ${NFVO_AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Log    Authorization Token: ${authorizationToken}
    REST.POST    ${apiRoot}/${apiName}/${apiMajorVersion}/coordinations    ${body}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output} 
    

Check HTTP Response Body Json Schema Is
    [Arguments]    ${input}
@@ -271,3 +300,8 @@ DELETE information about a cancellation of an ongoing coordination action
    REST.DELETE    ${apiRoot}/${apiName}/${apiMajorVersion}/coordinations/${ongoingCoordinationId}/cancel
    ${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
+6 −0
Original line number Diff line number Diff line
@@ -4,6 +4,12 @@ ${NFVO_PORT} 8081 # Listening port of the NFVO
${NFVO_SCHEMA}    https
${AUTHORIZATION_HEADER}    Authorization
${AUTHORIZATION_TOKEN}    Bearer 0b79bab50daca910b000d4f1a2b675d604257e42

${OAUTH_ENCRIPTION_ALGORITHM}    HS256
${ALL_PERMITTED_SCOPE}    lcmcoord:v2:all  
${NOT_PERMITTED_SCOPE}    lcmcoord:v2:invalid


${INSUFFICIENT_AUTHORIZATION_TOKEN}    Bearer INSUFFICIENT_AUTHORIZATION_TOKEN
#${NEG_AUTHORIZATION_TOKEN}    Bearer negativetoken
${NFVO_AUTH_USAGE}    1