Commit 69ccdeb4 authored by Giacomo Bernini's avatar Giacomo Bernini Committed by Giacomo Bernini
Browse files

added new oauth scope tests for Policies endpoint tests id 10.3.1.2.15 and 10.3.1.2.16

parent c20537a5
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -183,3 +183,29 @@ DELETE Policies - Method not implemented
    DELETE Policies
    Check HTTP Response Status Code Is    405
    Check Postcondition Policies Exist

POST Create a new Policy with permitted authorization scope
    [Documentation]    Test ID: 10.3.1.2.15
    ...    Test title: POST Create a new Policy with permitted authorization scope
    ...    Test objective: The objective is to test that POST method creates a policy with permitted authorization scope.
    ...    Pre-conditions: none
    ...    Reference: Clause 5.5.3.3.1 - ETSI GS NFV-SOL 012 [9] v4.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: Policy is created.     
    POST Policies with permitted authorization scope
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is    Policy
    Check HTTP Response Header Contains    Location

POST Create a new Policy with not permitted authorization scope
    [Documentation]    Test ID: 10.3.1.2.16
    ...    Test title: POST Create a new Policy with not permitted authorization scope
    ...    Test objective: The objective is to test that POST method to create a policy fails when a not permitted authorization scope is used.
    ...    Pre-conditions: none
    ...    Reference: Clause 5.5.3.3.1 - ETSI GS NFV-SOL 012 [9] v4.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none.     
    POST Policies with not permitted authorization scope
    Check HTTP Response Status Code Is    401
 No newline at end of file
+33 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ Library JSONSchemaLibrary schemas/
Library    String
Library    MockServerLibrary
Library    Process
Library    jwt

*** Keywords ***
Create Sessions
@@ -427,6 +428,32 @@ POST Policies
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

POST Policies with permitted authorization scope
    Log    Create policy instance by POST to ${apiRoot}/${apiName}/${apiVersion}/policies
    ${scopeValue}=    Create Dictionary    scope=${POLICIES_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Log    Authorization Token: ${authorizationToken}
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    ${body}=    Get File    jsons/CreatePolicyRequest.json
    Post    ${apiRoot}/${apiName}/${apiVersion}/policies    ${body}    
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

POST Policies with not permitted authorization scope
    Log    Create policy instance by POST to ${apiRoot}/${apiName}/${apiVersion}/policies
    ${scopeValue}=    Create Dictionary    scope=${POLICIES_NOT_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Log    Authorization Token: ${authorizationToken}
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    ${body}=    Get File    jsons/CreatePolicyRequest.json
    Post    ${apiRoot}/${apiName}/${apiVersion}/policies    ${body}    
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

GET Policies
    Log    Get the list of existing policies
    Set Headers  {"Accept":"${ACCEPT}"}  
@@ -742,3 +769,8 @@ Check that the Content-Type Header Is Set
    Log    Validating content type
    Should Be Equal    ${response['headers']['Content-Type']}    ${POLICY_CONTENT_TYPE}
    Log    Content Type validated 

JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded}   
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -4,6 +4,11 @@ ${NFVMANO_PORT} 8081 # Listening port of the NFVO
${NFVMANO_SCHEMA}    https
${AUTHORIZATION_HEADER}    Authorization
${AUTHORIZATION_TOKEN}    Bearer    QWxhZGRpbjpvcGVuIHNlc2FtZQ==

${OAUTH_ENCRIPTION_ALGORITHM}    HS256
${POLICIES_PERMITTED_SCOPE}    nfvpolicy:v2:policies
${POLICIES_NOT_PERMITTED_SCOPE}    nfvpolicy:v2:policies:readonly

${CONTENT_TYPE}    application/json
${CONTENT_TYPE_JSON}    application/json
${ACCEPT}         application/json