Commit 6487a985 authored by Giacomo Bernini's avatar Giacomo Bernini Committed by Giacomo Bernini
Browse files

added oauth scope tests for individual policy 10.3.1.3.9 and 10.3.1.3.10

parent 69ccdeb4
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -106,3 +106,28 @@ DELETE an individual policy - CONFLICT
    Check HTTP Response Status Code Is    409
    Check HTTP Response Body Json Schema Is   ProblemDetails    
    Check Postcondition Individual Policy is Not Deleted

PATCH an individual policy with permitted authorization scope 
     [Documentation]    Test ID: 10.3.1.3.9
    ...    Test title: PATCH an individual policy with permitted authorization scope 
    ...    Test objective: The objective is to test that an individual policy is modified successfully when a permitted authorization scope is used.
    ...    Pre-conditions: There should not exist a conflict as described in Reference.
    ...    Reference: Clause 5.5.4.3.4 - ETSI GS NFV-SOL 012 [9] v4.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none
    PATCH Individual Policy with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   PolicyModifications

PATCH an individual policy with permitted authorization scope 
     [Documentation]    Test ID: 10.3.1.3.10
    ...    Test title: PATCH an individual policy with not permitted authorization scope 
    ...    Test objective: The objective is to test that an individual policy is not modified when a not permitted authorization scope is used.
    ...    Pre-conditions: There should not exist a conflict as described in Reference.
    ...    Reference: Clause 5.5.4.3.4 - ETSI GS NFV-SOL 012 [9] v4.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none
    PATCH Individual Policy with not permitted authorization scope
    Check HTTP Response Status Code Is    401
 No newline at end of file
+124 −0
Original line number Diff line number Diff line
@@ -201,6 +201,32 @@ GET Subscriptions
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

GET Subscriptions with permitted authorization scope
    Log    Get the list of active subscriptions
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    ${scopeValue}=    Create Dictionary    scope=${SUBSCRIPTIONS_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Log    Authorization Token: ${authorizationToken}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Log    Execute Query and validate response
    Get    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

GET Subscriptions with not permitted authorization scope
    Log    Get the list of active subscriptions
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    ${scopeValue}=    Create Dictionary    scope=${NOT_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Log    Authorization Token: ${authorizationToken}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Log    Execute Query and validate response
    Get    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
	
Get subscriptions with all_fields attribute selector
    Log    Get the list of active subscriptions, using fields
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
@@ -307,6 +333,28 @@ GET Individual subscription
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

GET Individual subscription with permitted authorization scope
    log    Trying to get information about an individual subscription
    Set Headers    {"Accept":"${ACCEPT}"}  
    ${scopeValue}=    Create Dictionary    scope=${SUBSCRIPTIONS_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Log    Authorization Token: ${authorizationToken}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}  
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

GET Individual subscription with not permitted authorization scope
    log    Trying to get information about an individual subscription
    Set Headers    {"Accept":"${ACCEPT}"}  
    ${scopeValue}=    Create Dictionary    scope=${NOT_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Log    Authorization Token: ${authorizationToken}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}  
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
	
GET Individual subscription with Invalid URI
    log    Trying to get information about an individual subscription with invalid subscription ID
    Set Headers    {"Accept":"${ACCEPT}"}  
@@ -601,6 +649,32 @@ PATCH Individual Policy
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

PATCH Individual Policy with permitted authorization scope
    Log    Modify individual policy instance by PATCH to ${apiRoot}/${apiName}/${apiVersion}/policies/${policyId}
    ${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/PolicyModifications.json
    Patch    ${apiRoot}/${apiName}/${apiVersion}/policies/${policyId}    ${body}    
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

PATCH Individual Policy with not permitted authorization scope
    Log    Modify individual policy instance by PATCH to ${apiRoot}/${apiName}/${apiVersion}/policies/${policyId}
    ${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/PolicyModifications.json
    Patch    ${apiRoot}/${apiName}/${apiVersion}/policies/${policyId}    ${body}    
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
	
DELETE Individual Policy
    log    Trying to delete an individual policy, no conflict
    Set Headers  {"Accept":"${ACCEPT}"}  
@@ -658,6 +732,28 @@ GET Selected Version of an Individual Policy
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

GET Selected Version of an Individual Policy with permitted authorization scope
    log    Trying to get information about the selected version of an individual policy
    ${scopeValue}=    Create Dictionary    scope=${SELECTED_VERSION_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Log    Authorization Token: ${authorizationToken}
    Set Headers  {"Accept":"${ACCEPT}"}  
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/policies/${policyId}/selected_version  
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
	
GET Selected Version of an Individual Policy with not permitted authorization scope
    log    Trying to get information about the selected version of an individual policy
    ${scopeValue}=    Create Dictionary    scope=${NOT_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Log    Authorization Token: ${authorizationToken}
    Set Headers  {"Accept":"${ACCEPT}"}  
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/policies/${policyId}/selected_version  
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

GET Selected Version of an Individual Policy in CREATED state
    log    Trying to get information about the selected version of an individual policy which is in CREATED state
    Set Headers    {"Accept":"${ACCEPT}"}  
@@ -729,6 +825,34 @@ PUT Particular Version of an Individual Policy
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

PUT Particular Version of an Individual Policy with permitted authorization scope
    Log    Using PUT method to transfer the content of a particular version of an individual policy.
    Set Headers  {"Accept":"${ACCEPT}"}  
    Determine Policy Content Type
    Set Headers  {"Content-Type": "${POLICY_CONTENT_TYPE}"}
    ${scopeValue}=    Create Dictionary    scope=${VERSIONS_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Log    Authorization Token: ${authorizationToken}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    ${body}=    Get File    ${POLICY_CONTENT_FILENAME}
    Put    ${apiRoot}/${apiName}/${apiVersion}/policies/${policyId}/versions/${policyVersion}    ${body}    
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

PUT Particular Version of an Individual Policy with not permitted authorization scope
    Log    Using PUT method to transfer the content of a particular version of an individual policy.
    Set Headers  {"Accept":"${ACCEPT}"}  
    Determine Policy Content Type
    Set Headers  {"Content-Type": "${POLICY_CONTENT_TYPE}"}
    ${scopeValue}=    Create Dictionary    scope=${VERSIONS_NOT_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Log    Authorization Token: ${authorizationToken}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    ${body}=    Get File    ${POLICY_CONTENT_FILENAME}
    Put    ${apiRoot}/${apiName}/${apiVersion}/policies/${policyId}/versions/${policyVersion}    ${body}    
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

PUT Particular Version of an Individual Policy CONFLICT
    Log    Using PUT method to transfer the content of a particular version of an already transferred policy.
    Set Headers  {"Accept":"${ACCEPT}"}  
+5 −0
Original line number Diff line number Diff line
@@ -8,6 +8,11 @@ ${AUTHORIZATION_TOKEN} Bearer QWxhZGRpbjpvcGVuIHNlc2FtZQ==
${OAUTH_ENCRIPTION_ALGORITHM}    HS256
${POLICIES_PERMITTED_SCOPE}    nfvpolicy:v2:policies
${POLICIES_NOT_PERMITTED_SCOPE}    nfvpolicy:v2:policies:readonly
${SELECTED_VERSION_PERMITTED_SCOPE}    nfvpolicy:v2:policies:selected_version
${NOT_PERMITTED_SCOPE}    nfvpolicy:v2:policies:invalid
${VERSIONS_PERMITTED_SCOPE}    nfvpolicy:v2:versions
${VERSIONS_NOT_PERMITTED_SCOPE}    nfvpolicy:v2:versions:readonly
${SUBSCRIPTIONS_PERMITTED_SCOPE}    nfvpolicy:v2:subscriptions

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