Commit 3fa5588e authored by Muhammad Umair Khan's avatar Muhammad Umair Khan Committed by Giacomo Bernini
Browse files

implement oauth scope for SOL003 VirtualisedResourcesQuota API

parent d23eff61
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -84,3 +84,29 @@ Get Information about an individual subscription - Not Found
    Get Virtualised Resources Quota Available Notification individual subscription
    Check HTTP Response Status Code Is    404
    Check HTTP Response Body Json Schema Is    ProblemDetails

Get Information about an individual subscription with permitted authorization scope 
    [Documentation]    Test ID: 7.3.7.2.2
    ...    Test title: Get Information about an individual subscription with permitted authorization scope 
    ...    Test objective: The objective is to read an individual Virtualised Resources Quota Available Notification subscription subscribed by the client and perform a JSON schema and content validation of the returned individual subscription data structure with permitted authorization scope  
    ...    Pre-conditions: The subscription with the given id exists
    ...    Reference: Clause 11.4.3.3.2 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none 
    ...    Post-Conditions: none
    Get Virtualised Resources Quota Available Notification individual subscription with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    VrQuotaAvailSubscription

Get Information about an individual subscription with not permitted authorization scope 
    [Documentation]    Test ID: 7.3.7.2.2
    ...    Test title: Get Information about an individual subscription with not permitted authorization scope 
    ...    Test objective: The objective is to read an individual Virtualised Resources Quota Available Notification subscription subscribed by the client and perform a JSON schema and content validation of the returned individual subscription data structure with not permitted authorization scope 
    ...    Pre-conditions: The subscription with the given id exists
    ...    Reference: Clause 11.4.3.3.2 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none 
    ...    Post-Conditions: none
    Get Virtualised Resources Quota Available Notification 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
+27 −0
Original line number Diff line number Diff line
@@ -176,3 +176,30 @@ Create new Virtualised Resources Quota Available Notification Subscription - Unp
    Send Post request for new Virtualised Resources Quota Available Notification subscription
    Check HTTP Response Status Code Is    422
    Check HTTP Response Body Json Schema Is  ProblemDetails

Create new Virtualised Resources Quota Available Notification subscription with permitted authorization scope 
    [Documentation]    Test ID: 7.3.7.1.13
    ...    Test title: Create new Virtualised Resources Quota Available Notification subscription with permitted authorization scope 
    ...    Test objective: The objective is to create a new Virtualised Resources Quota Available Notification subscription and perform a JSON schema and content validation of the returned subscription data structure with permitted authorization scope 
    ...    Pre-conditions: no subscription with the same filter and callback Uri exists
    ...    Reference: Clause 11.4.2.3.1 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    Send Post request for new Virtualised Resources Quota Available Notification subscription with permitted authorization scope
    Check HTTP Response Status Code Is    201
    Check HTTP Response Header Contains    Location
    Check HTTP Response Body Json Schema Is    VrQuotaAvailSubscription

Create new Virtualised Resources Quota Available Notification subscription with not permitted authorization scope 
    [Documentation]    Test ID: 7.3.7.1.14
    ...    Test title: Create new Virtualised Resources Quota Available Notification subscription with not permitted authorization scope 
    ...    Test objective: The objective is to create a new Virtualised Resources Quota Available Notification subscription and perform a JSON schema and content validation of the returned subscription data structure with not permitted authorization scope 
    ...    Pre-conditions: no subscription with the same filter and callback Uri exists
    ...    Reference: Clause 11.4.2.3.1 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    Send Post request for new Virtualised Resources Quota Available Notification 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
+66 −3
Original line number Diff line number Diff line
@@ -83,6 +83,26 @@ Get Virtualised Resources Quota Available Notification individual subscription
    ${outputResponse}=    Output    response 
    Set Global Variable    ${response}    ${outputResponse}

Get Virtualised Resources Quota Available Notification individual subscription with permitted authorization scope 
    log    Trying to get information about an individual subscription with permitted authorization scope 
    Set Headers    {"Accept":"${ACCEPT}"}  
    ${scopeValue}=    Create Dictionary    scopeValue=${VRQAN_PERMITTED_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=${OAUTH_KEY}    algorithm=${OAUTH_ENCRYPTION_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${subscriptionId}
    ${outputResponse}=    Output    response 
    Set Global Variable    ${response}    ${outputResponse}

Get Virtualised Resources Quota Available Notification individual subscription with not permitted authorization scope 
    log    Trying to get information about an individual subscription with not permitted authorization scope 
    Set Headers    {"Accept":"${ACCEPT}"}  
    ${scopeValue}=    Create Dictionary    scopeValue=${VRQAN_NOT_PERMITTED_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=${OAUTH_KEY}    algorithm=${OAUTH_ENCRYPTION_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${subscriptionId}
    ${outputResponse}=    Output    response 
    Set Global Variable    ${response}    ${outputResponse}

Delete Virtualised Resources Quota Available Notification individual subscription
    log    Try to delete an individual subscription
    Set Headers  {"Accept":"${ACCEPT}"}  
@@ -147,6 +167,46 @@ Send Post request for new Virtualised Resources Quota Available Notification sub
	Verify Mock Expectation   ${notification_request}
	Clear Requests    ${callback_endpoint}

Send Post request for new Virtualised Resources Quota Available Notification subscription with permitted authorization scope 
    Log    Create subscription instance by POST to ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions with permitted authorization scope 
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    ${scopeValue}=    Create Dictionary    scopeValue=${VRQAN_PERMITTED_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=${OAUTH_KEY}    algorithm=${OAUTH_ENCRYPTION_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    ${template}=    Get File    jsons/vrQuotaAvailSubscriptionRequest.json
    ${body}=        Format String   ${template}    callback_uri=${callback_uri}:${callback_port}    callback_subscribe=${callback_subscribe}
    Log  Creating mock request and response to handle GET operation on notification endpoint
    &{notification_request}=  Create Mock Request Matcher	GET  ${callback_endpoint}
    &{notification_response}=  Create Mock Response	status_code=204
    Log    Issue the subscription request
    Create Mock Expectation  ${notification_request}  ${notification_response}
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions    ${body}    allow_redirects=false
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
	Verify Mock Expectation   ${notification_request}
	Clear Requests    ${callback_endpoint}

Send Post request for new Virtualised Resources Quota Available Notification subscription with not permitted authorization scope 
    Log    Create subscription instance by POST to ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions with not permitted authorization scope 
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    ${scopeValue}=    Create Dictionary    scopeValue=${VRQAN_NOT_PERMITTED_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=${OAUTH_KEY}    algorithm=${OAUTH_ENCRYPTION_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    ${template}=    Get File    jsons/vrQuotaAvailSubscriptionRequest.json
    ${body}=        Format String   ${template}    callback_uri=${callback_uri}:${callback_port}    callback_subscribe=${callback_subscribe}
    Log  Creating mock request and response to handle GET operation on notification endpoint
    &{notification_request}=  Create Mock Request Matcher	GET  ${callback_endpoint}
    &{notification_response}=  Create Mock Response	status_code=204
    Log    Issue the subscription request
    Create Mock Expectation  ${notification_request}  ${notification_response}
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions    ${body}    allow_redirects=false
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
	Verify Mock Expectation   ${notification_request}
	Clear Requests    ${callback_endpoint}
    
GET Virtualised Resources Quota Available Notification Subscriptions
    Log    Get the list of active subscriptions
    Set Headers  {"Accept":"${ACCEPT}"} 
@@ -220,4 +280,7 @@ Check HTTP Response Header Contain Link
    Should Be Equal As Integers	${length}	0
    Set Global Variable    ${nextPageUri}    ${linkHeaderUri[0]}

      
 No newline at end of file
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
@@ -2,8 +2,14 @@
${NFVO_HOST}      localhost    # Hostname of the NFVO
${NFVO_PORT}      8081    # Listening port of the NFVO
${NFVO_SCHEMA}    https
${OAUTH_ENCRYPTION_ALGORITHM}  HS256
${OAUTH_KEY}
${AUTHORIZATION_HEADER}    Authorization
${AUTHORIZATION_TOKEN}    Bearer 0b79bab50daca910b000d4f1a2b675d604257e42

${VRQAN_PERMITTED_SCOPE}  vrqan:v1:all    
${VRQAN_NOT_PERMITTED_SCOPE}  vrqan:v1:all:invalid

${CONTENT_TYPE}    application/json
${AUTH_USAGE}     1
${ACCEPT}         application/json