Commit 71ad7865 authored by Mudassar Khan's avatar Mudassar Khan Committed by Giacomo Bernini
Browse files

implement OAuth scope test for NSInstanceUsageNotification API of SOL011

parent e050659d
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -81,3 +81,27 @@ GET Information about an individual subscription - NOT FOUND
    GET Individual subscription
    Check HTTP Response Status Code Is    404
    Check HTTP Response Body Json Schema Is   ProblemDetails
GET Information about an individual subscription with permitter authorization scope - Successful
     [Documentation]    Test ID: 9.3.2.2.7
    ...    Test title: GET Information about an individual subscription with permitter authorization scope - Successful
    ...    Test objective: The objective is to test the retrieval of NS instance usage notification subscription and perform a JSON schema validation of the returned subscription data structure
    ...    Pre-conditions: An NS instance is instantiated. At least one NS instance usage notification subscription is available in the NFVO.
    ...    Reference: Clause 8.5.4.3.2 - ETSI GS NFV-SOL 011 [8] v4.5.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
    GET Individual subscription with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   subscription
GET Information about an individual subscription with not permitter authorization scope - Successful
     [Documentation]    Test ID: 9.3.2.2.8
    ...    Test title: GET Information about an individual subscription with not permitter authorization scope - Successful
    ...    Test objective: The objective is to test the retrieval of NS instance usage notification subscription and perform a JSON schema validation of the returned subscription data structure
    ...    Pre-conditions: An NS instance is instantiated. At least one NS instance usage notification subscription is available in the NFVO.
    ...    Reference: Clause 8.5.4.3.2 - ETSI GS NFV-SOL 011 [8] v4.5.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
    GET Individual subscription with not permitted authorization scope
    Check HTTP Response Status Code Is    403
    Check HTTP Response Body Json Schema Is   ProblemDetails
 No newline at end of file
+48 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ Library OperatingSystem
Library    JSONLibrary
Library    JSONSchemaLibrary    schemas/
Library    String
Library    jwt

*** Keywords ***
Check HTTP Response Status Code Is
@@ -262,3 +263,49 @@ Check Postcondition Subscription Resource Returned in Location Header Is Availab
Check Postcondition Subscriptions Exist
    Log    Checking that subscriptions exists
    Get Subscriptions 
JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded}
POST subscriptions with permitted authorization scope
    Log    Create subscription instance by POST to ${apiRoot}/${apiName}/${apiVersion}/subscriptions
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    ${scope_value}=    Create Dictionary    scopeValue=${SUBSCRIPTION_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scope_value}    key=''    algorithm=${OAUTH_Encryption_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${authorizationToken}"}
    ${body}=    Get File    jsons/NsInstanceUsageSubscriptionRequest.json
    Post    ${apiRoot}/${apiName}/${apiVersion}/subscriptions    ${body}    allow_redirects=false
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
POST subscriptions with not permitted authorization scope
    Log    Create subscription instance by POST to ${apiRoot}/${apiName}/${apiVersion}/subscriptions
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    ${scope_value}=    Create Dictionary    scopeValue=${NEG_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scope_value}    key=''    algorithm=${OAUTH_Encryption_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${authorizationToken}"}
    ${body}=    Get File    jsons/NsInstanceUsageSubscriptionRequest.json
    Post    ${apiRoot}/${apiName}/${apiVersion}/subscriptions    ${body}    allow_redirects=false
	${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}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    ${scope_value}=    Create Dictionary    scopeValue=${SUBSCRIPTION_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scope_value}    key=''    algorithm=${OAUTH_Encryption_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${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}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    ${scope_value}=    Create Dictionary    scopeValue=${NEG_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scope_value}    key=''    algorithm=${OAUTH_Encryption_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${authorizationToken}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}  
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
 No newline at end of file
+28 −1
Original line number Diff line number Diff line
@@ -219,3 +219,30 @@ GET subscriptions with "exclude_default" and "fields" attribute selector
    Get subscriptions with exclude_default and fields attribute selector
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   subscriptions  
POST Create a new subscription with permitted authorization scope
    [Documentation]    Test ID: 9.3.2.1.17
    ...    Test title: POST Create a new subscription with permitted authorization scope
    ...    Test objective: The objective is to test that POST method creates a subscription
    ...    Pre-conditions: none
    ...    Reference: Clause 8.5.3.3.1 - ETSI GS NFV-SOL 011 [8] v4.5.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: Subscription is created in the NFVO     
    POST subscriptions with permitted authorization scope
    Check HTTP Response Status Code Is    201
    Check HTTP Response Header Contains    Location
    Check HTTP Response Body Json Schema Is    subscription
    Check HTTP Response Header Contains Resource URI
    Check Postcondition Subscription Is Set 
POST Create a new subscription with NOT permitted authorization scope
    [Documentation]    Test ID: 9.3.2.1.18
    ...    Test title: POST Create a new subscription with not permitted authorization scope
    ...    Test objective: The objective is to test that POST method creates a subscription
    ...    Pre-conditions: none
    ...    Reference: Clause 8.5.3.3.1 - ETSI GS NFV-SOL 011 [8] v4.5.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: Subscription is created in the NFVO     
    POST subscriptions with not permitted authorization scope
    Check HTTP Response Status Code Is    403
    Check HTTP Response Body Json Schema Is    ProblemDetails
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -24,6 +24,10 @@ ${VNFM_SCHEMA} https
${CONTENT_TYPE_PATCH}    application/merge-patch+json
${WRONG_AUTHORIZATION}    Bearer    XXXXXWRONGXXXXX

${SUBSCRIPTION_SCOPE}   nsiun:v1:all
${NEG_SCOPE}    nsiun:v1:invalid
${OAUTH_Encryption_ALGORITHM}   HS256

${vnfInstanceDescription}    description vnf
${vnfInstanceDescription_Update}    Updated description vnf 
${SINGLE_FILE_VNFD}    1    # If VNFD is PLAIN TEXT