Commit 0c29afa6 authored by Muhammad Umair Khan's avatar Muhammad Umair Khan Committed by Giacomo Bernini
Browse files

implement oauth scope for SOL003 VNFFaultManagement API

parent 762b1457
Loading
Loading
Loading
Loading
+27 −1
Original line number Diff line number Diff line
@@ -179,6 +179,32 @@ Get information about multiple alarms - Bad Request Response too Big
    Check HTTP Response Status Code Is    400
    Check HTTP Response Body Json Schema Is    ProblemDetails

Get information about multiple alarms with permitted authorization scope 
    [Documentation]    Test ID: 7.3.5.1.14
    ...    Test title: Get information about multiple alarms with permitted authorization scope 
    ...    Test objective: The objective is to retrieve information about the alarm list and perform a JSON schema and content validation of the returned alarms data structure with permitted authorization scope 
    ...    Pre-conditions: none
    ...    Reference: Clause 7.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET Fault Management Alarms with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    Alarms

Get information about multiple alarms with not permitted authorization scope 
    [Documentation]    Test ID: 7.3.5.1.15
    ...    Test title: Get information about multiple alarms with not permitted authorization scope 
    ...    Test objective: The objective is to retrieve information about the alarm list and perform a JSON schema and content validation of the returned alarms data structure with not permitted authorization scope 
    ...    Pre-conditions: none
    ...    Reference: Clause 7.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET Fault Management Alarms with not permitted authorization scope
    Check HTTP Response Status Code Is    403
    Check HTTP Response Body Json Schema Is    ProblemDetails

*** Keywords ***
Void
    Log    do nothing
+114 −3
Original line number Diff line number Diff line
@@ -202,6 +202,28 @@ Send POST request for fault management Individual Alarm
    ${outputResponse}=    Output    response 
    Set Global Variable    ${response}    ${outputResponse}

GET Fault Management Alarms with permitted authorization scope 
    Log    Query NFVO The GET method queries information about multiple alarms with permitted authorization scope .
    Set Headers  {"Accept":"${ACCEPT}"}  
    ${scopeValue}=    Create Dictionary    scopeValue=${ALARMS_READONLY_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}"}
    Log    Execute Query
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms
    ${outputResponse}=    Output    response
    Set Global Variable    ${response}    ${outputResponse}

GET Fault Management Alarms with not permitted authorization scope 
    Log    Query NFVO The GET method queries information about multiple alarms with not permitted authorization scope .
    Set Headers  {"Accept":"${ACCEPT}"}  
    ${scopeValue}=    Create Dictionary    scopeValue=${ALARMS_READONLY_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}"}
    Log    Execute Query
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms
    ${outputResponse}=    Output    response
    Set Global Variable    ${response}    ${outputResponse}

DELETE Fault Management Individual Alarm
    log    Trying to perform a DELETE. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
@@ -248,6 +270,30 @@ PATCH Fault Management Individual Alarm
    ${outputResponse}=    Output    response
    Set Global Variable    ${response}    ${outputResponse}

PATCH Fault Management Individual Alarm with permitted authorization scope
    log    Trying to perform a PATCH. This method modifies an individual alarm resource with permitted authorization scope
    Set Headers  {"Accept":"${ACCEPT}"} 
    Set Headers  {"Content-Type": "${CONTENT_TYPE_PATCH}"} 
    ${scopeValue}=    Create Dictionary    scopeValue=${ALARMS_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}"}
    ${body}=    Get File    jsons/alarmModifications.json
    Patch    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarmId}    ${body}
    ${outputResponse}=    Output    response
    Set Global Variable    ${response}    ${outputResponse}

PATCH Fault Management Individual Alarm with not permitted authorization scope
    log    Trying to perform a PATCH. This method modifies an individual alarm resource with not permitted authorization scope
    Set Headers  {"Accept":"${ACCEPT}"} 
    Set Headers  {"Content-Type": "${CONTENT_TYPE_PATCH}"} 
    ${scopeValue}=    Create Dictionary    scopeValue=${ALARMS_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}"}
    ${body}=    Get File    jsons/alarmModifications.json
    Patch    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarmId}    ${body}
    ${outputResponse}=    Output    response
    Set Global Variable    ${response}    ${outputResponse}
    
PATCH Fault Management Individual Alarm - Etag mismatch
    log    Trying to perform a PATCH. This method modifies an individual alarm resource
    Set Headers  {"Accept":"${ACCEPT}"} 
@@ -326,6 +372,46 @@ Send POST Request for duplicated subscription not permitted
	Verify Mock Expectation   ${notification_request}
	Clear Requests    ${callback_endpoint}

POST 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=${ALARMS_SUBSCRIPTIONS_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/fmSubscriptionRequest.json
    ${body}=        Format String   ${template}    vnfdIds=${vnfdIds}      callback_uri=${callback_uri}:${callback_port}    callback_endpoint=${callback_endpoint}
    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}

POST 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=${ALARMS_SUBSCRIPTIONS_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/fmSubscriptionRequest.json
    ${body}=        Format String   ${template}    vnfdIds=${vnfdIds}      callback_uri=${callback_uri}:${callback_port}    callback_endpoint=${callback_endpoint}
    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 Subscriptions
    Log    Get the list of active subscriptions
    Set Headers    {"Accept": "${ACCEPT}"}
@@ -417,6 +503,26 @@ 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 with permitted authorization scope
    Set Headers    {"Accept":"${ACCEPT}"}  
    ${scopeValue}=    Create Dictionary    scopeValue=${ALARMS_SUBSCRIPTIONS_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 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=${ALARMS_SUBSCRIPTIONS_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}  
    
PUT Individual Subscription
    log    Trying to perform a PUT. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}
@@ -527,3 +633,8 @@ Check PostCondition HTTP Response Body Subscriptions Matches the requested attri
    FOR   ${item}   IN  ${response['body']}
        Should Be Equal As Strings    ${item['filter']['probableCauses']}   ${probableCause}
    END

JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded}
 No newline at end of file
+28 −1
Original line number Diff line number Diff line
@@ -112,3 +112,30 @@ Get information about an fault management individual alarm - Not Found
    GET Fault Management Individual Alarm
    Check HTTP Response Status Code Is    404
    Check HTTP Response Body Json Schema Is    ProblemDetails

PATCH Fault Management Individual Alarm with permitted authorization scope
    [Documentation]    Test ID: 7.3.5.2.9
    ...    Test title: PATCH Fault Management Individual Alarm with permitted authorization scope
    ...    Test objective: The objective is to Modify an individual alarm resource and perform a JSON schema and content validation of the returned alarm data structure with permitted authorization scope
    ...    Pre-conditions: The related alarm exists
    ...    Reference: Clause 7.4.3.3.4 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    PATCH Fault Management Individual Alarm with permitted authorization scope
    Check HTTP Response Header Contains ETag and Last-Modified
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is  alarmModification

PATCH Fault Management Individual Alarm with not permitted authorization scope
    [Documentation]    Test ID: 7.3.5.2.10
    ...    Test title: PATCH Fault Management Individual Alarm with not permitted authorization scope
    ...    Test objective: The objective is to Modify an individual alarm resource and perform a JSON schema and content validation of the returned alarm data structure with not permitted authorization scope
    ...    Pre-conditions: The related alarm exists
    ...    Reference: Clause 7.4.3.3.4 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    PATCH Fault Management Individual Alarm with not permitted authorization scope
    Check HTTP Response Status Code Is    403
    Check HTTP Response Body Json Schema Is    ProblemDetails
+27 −1
Original line number Diff line number Diff line
@@ -80,3 +80,29 @@ 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 permitted authorization scope 
    [Documentation]    Test ID: 7.3.5.4.7
    ...    Test title: Get Information about an individual subscription with permitted authorization scope 
    ...    Test objective: The objective is to read an individual subscription for NFVO alarms subscribed by the client and perform a JSON schema and content validation of the returned fault management individual subscription data structure with permitted authorization scope 
    ...    Pre-conditions: The subscription with the given id exists
    ...   Reference: Clause 7.4.5.3.2 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    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    FmSubscription

Get Information about an individual subscription with not permitted authorization scope 
    [Documentation]    Test ID: 7.3.5.4.8
    ...    Test title: Get Information about an individual subscription with not permitted authorization scope with not permitted authorization scope 
    ...    Test objective: The objective is to read an individual subscription for NFVO alarms subscribed by the client and perform a JSON schema and content validation of the returned fault management individual subscription data structure with not permitted authorization scope 
    ...    Pre-conditions: The subscription with the given id exists
    ...   Reference: Clause 7.4.5.3.2 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    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
+30 −2
Original line number Diff line number Diff line
@@ -304,3 +304,31 @@ POST Create a new Subscription - Unprocessable Content
    Post Subscription
    Check HTTP Response Status Code Is    422
    Check HTTP Response Body Json Schema Is  ProblemDetails

Create a new Fault Management alarm subscription with permitted authorization scope 
    [Documentation]    Test ID: 7.3.5.3.23
    ...    Test title: Create a new Fault Management alarm subscription with permitted authorization scope 
    ...    Test objective: The objective is to create a new Fault management alarm subscriptions and perform a JSON schema and content validation of the returned fault management alarms subscription data structure with permitted authorization scope 
    ...    Pre-conditions: No subscription with the same filter and callbackUri exists
    ...    Reference: Clause 7.4.4.3.1 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID:   Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: subscription is created
    POST Subscription with permitted authorization scope
    Check HTTP Response Status Code Is    201
    Check Operation Occurrence Id
    Check HTTP Response Body Json Schema Is  FmSubscription
    Check created Subscription existence

Create a new Fault Management alarm subscription with not permitted authorization scope 
    [Documentation]    Test ID: 7.3.5.3.23
    ...    Test title: Create a new Fault Management alarm subscription with not permitted authorization scope 
    ...    Test objective: The objective is to create a new Fault management alarm subscriptions and perform a JSON schema and content validation of the returned fault management alarms subscription data structure with not permitted authorization scope 
    ...    Pre-conditions: No subscription with the same filter and callbackUri exists
    ...    Reference: Clause 7.4.4.3.1 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID:   Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: subscription is created
    POST Subscription with not permitted authorization scope
    Check HTTP Response Status Code Is    403
    Check HTTP Response Body Json Schema Is  ProblemDetails
Loading