Commit 5c25bea4 authored by Mudassar Khan's avatar Mudassar Khan Committed by Giacomo Bernini
Browse files

implement OAuth scope test for VNFFaultManagement API of SOL002

parent 4fb09676
Loading
Loading
Loading
Loading
+51 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ Library JSONLibrary
Library    JSONSchemaLibrary    schemas/
Library    OperatingSystem
Library     Collections
Library    jwt

*** Test Cases ***
POST Alarms - Method not implemented
@@ -256,6 +257,30 @@ GET information about multiple alarms with attribute-based filter "probableCause
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    alarms 
    Check PostCondition HTTP Response Body alarms Matches the requested attribute-based filter "probableCause"
GET information about multiple alarms with permitted authorization scope
    [Documentation]    Test ID: 6.3.4.1.20
    ...    Test title: GET information about multiple alarms with permitted authorization scope
    ...    Test objective: The objective is to retrieve information about the alarm list
    ...    Pre-conditions: none 
    ...    Reference: Clause 7.4.2.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET Alarms Task 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: 6.3.4.1.21
    ...    Test title: GET information about multiple alarms with not permitted authorization scope
    ...    Test objective: The objective is to retrieve information about the alarm list
    ...    Pre-conditions: none 
    ...    Reference: Clause 7.4.2.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET Alarms Task with not permitted authorization scope
    Check HTTP Response Status Code Is    403
    Check HTTP Response Body Json Schema Is    ProblemDetails

*** Keywords ***
POST Alarms Task
@@ -443,3 +468,28 @@ Check PostCondition HTTP Response Body alarms Matches the requested attribute-ba
    FOR   ${item}   IN  @{response['body']}
    Should Be Equal As Strings    ${item['probableCause']}   ${probableCause}
    END
JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded}
GET Alarms Task with permitted authorization scope
	Log    Query VNF The GET method queries information about multiple alarms.
    Set Headers  {"Accept":"${ACCEPT}"}  
    ${scope_value}=    Create Dictionary    scopeValue=${ALARMS_READONLY_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scope_value}    key=''    algorithm=${OAUTH_Encryption_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Log    Execute Query and validate response
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

GET Alarms Task with not permitted authorization scope
	Log    Query VNF The GET method queries information about multiple alarms.
    Set Headers  {"Accept":"${ACCEPT}"}  
    ${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_HEADER}":"${authorizationToken}"}
    Log    Execute Query and validate response
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
 No newline at end of file
+52 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ Resource environment/variables.txt
Library    REST    ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT}    ssl_verify=false
Library    JSONSchemaLibrary
Library    OperatingSystem
Library    jwt
Library    String
Suite Setup    Check resource existence

@@ -66,6 +67,28 @@ DELETE Escalate the perceived severity - Method not implemented
    ...    Post-Conditions: none
    Delete escalate severity
    Check HTTP Response Status Code Is    405
Escalate the perceived severity with permitted authorization scope
    [Documentation]    Test ID: 6.3.4.3.6
    ...    Test title: Escalate the perceived severity with permitted authorization scope
    ...    Test objective: To enable the consumer to escalate the perceived severity of an alarm that is represented by an individual alarm resource.
    ...    Pre-conditions: The resource representing the individual alarm has been created
    ...    Reference: Clause 7.4.4.3.1 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    POST escalate severity with permitted authorization scope
    Check HTTP Response Status Code Is    204
Escalate the perceived severity with NOT permitted authorization scope
    [Documentation]    Test ID: 6.3.4.3.7
    ...    Test title: Escalate the perceived severity with NOT permitted authorization scope
    ...    Test objective: To enable the consumer to escalate the perceived severity of an alarm that is represented by an individual alarm resource.
    ...    Pre-conditions: The resource representing the individual alarm has been created
    ...    Reference: Clause 7.4.4.3.1 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    POST escalate severity with not permitted authorization scope
    Check HTTP Response Status Code Is    403

*** Keywords ***
Check resource existence
@@ -121,3 +144,31 @@ Check HTTP Response Body Json Schema Is
    ${schema} =    Catenate    SEPARATOR=    ${input}	.schema.json
    Validate Json    ${schema}    ${response['body']}
    Log    Json Schema Validation OK
JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded}
POST escalate severity with permitted authorization scope
    Log    escalate the perceived severity of an alarm with the VNFM
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    ${scope_value}=    Create Dictionary    scopeValue=${ESCALATE_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scope_value}    key=''    algorithm=${OAUTH_Encryption_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    ${template}=    Get File    jsons/EscalatePerceivedSeverity.json
    ${body}=    Format String    ${template}    perceivedSeverity=${PerceivedSeverity}
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarmId}/escalate    ${body}  
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
POST escalate severity with not permitted authorization scope
    Log    escalate the perceived severity of an alarm with the VNFM
    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_HEADER}":"${authorizationToken}"}
    ${template}=    Get File    jsons/EscalatePerceivedSeverity.json
    ${body}=    Format String    ${template}    perceivedSeverity=${PerceivedSeverity}
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarmId}/escalate    ${body}  
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
 No newline at end of file
+54 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ Library OperatingSystem
Library    JSONLibrary
Library    JSONSchemaLibrary    schemas/
Library    DependencyLibrary
Library    jwt

*** Variables **
${original_etag}    1234
@@ -114,6 +115,31 @@ GET information about an individual alarm - Not Found
    GET Alarm Task
    Check HTTP Response Status Code Is    404
    Check HTTP Response Body Json Schema Is     ProblemDetails
PATCH Individual Alarm with permitted authorization scope
    [Documentation]    Test ID: 6.3.4.2.9
    ...    Test title: PATCH Individual Alarm with permitted authorization scope
    ...    Test objective: The objective is to Modify an individual alarm resource
    ...    Pre-conditions: The related alarm exists
    ...    Reference: Clause 7.4.3.3.4 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    PATCH Alarm Task with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Header Contains ETag and Last-Modified
    Check HTTP Response Body Json Schema Is     alarmModifications
PATCH Individual Alarm with NOT permitted authorization scope
    [Documentation]    Test ID: 6.3.4.2.10
    ...    Test title: PATCH Individual Alarm with NOT permitted authorization scope
    ...    Test objective: The objective is to Modify an individual alarm resource
    ...    Pre-conditions: The related alarm exists
    ...    Reference: Clause 7.4.3.3.4 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    PATCH Alarm Task with not permitted authorization scope
    Check HTTP Response Status Code Is    403
    Check HTTP Response Body Json Schema Is     ProblemDetails

*** Keywords ***
POST Alarm Task
@@ -215,4 +241,32 @@ Check HTTP Response Header Contains
    [Arguments]    ${CONTENT_TYPE}
    Should Contain    ${response['headers']}    ${CONTENT_TYPE}
    Log    Header is present
JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded}
PATCH Alarm Task with permitted authorization scope
    log    Trying to perform a PATCH. This method modifies an individual alarm resource
    Set Headers  {"Accept":"${ACCEPT}"} 
    Set Headers  {"Content-Type": "${CONTENT_TYPE_PATCH}"}
    Set Headers  {"If-Match": "${original_etag[0]}"}
    ${scope_value}=    Create Dictionary    scopeValue=${ALARMS_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scope_value}    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 Alarm Task with not permitted authorization scope
    log    Trying to perform a PATCH. This method modifies an individual alarm resource
    Set Headers  {"Accept":"${ACCEPT}"} 
    Set Headers  {"Content-Type": "${CONTENT_TYPE_PATCH}"}
    Set Headers  {"If-Match": "${original_etag[0]}"}
    ${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_HEADER}":"${authorizationToken}"}
    ${body}=    Get File    jsons/alarmModifications.json
    Patch    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarmId}    ${body}
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
+46 −2
Original line number Diff line number Diff line
*** Settings ***
Resource    environment/variables.txt 
Library    JSONLibrary
Library    jwt
Library    JSONSchemaLibrary    schemas/
Library    REST    ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT}       ssl_verify=false 
Documentation    This resource represents an individual subscription for VNF alarms. 
@@ -82,7 +83,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: 6.3.4.5.7
    ...    Test title: GET Information about an individual subscription with permitted authorization scope
    ...    Test objective: The objective is to read an individual subscription for VNF alarms subscribed by the client
    ...    Pre-conditions: The subscription with the given id exists
    ...    Reference: Clause 7.4.6.3.2 - ETSI GS NFV-SOL 002 [2] 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: 6.3.4.5.8
    ...    Test title: GET Information about an individual subscription with NOT permitted authorization scope
    ...    Test objective: The objective is to read an individual subscription for VNF alarms subscribed by the client
    ...    Pre-conditions: The subscription with the given id exists
    ...    Reference: Clause 7.4.6.3.2 - ETSI GS NFV-SOL 002 [2] 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
*** Keywords ***
Check resource existence
    Set Headers    {"Accept":"${ACCEPT}"}
@@ -156,4 +179,25 @@ Check HTTP Response Body Json Schema Is
Check Postcondition resource is deleted
    Get individual subscription
    Check HTTP Response Status Code Is    404
    
 No newline at end of file
JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded}
Get individual subscription with permitted authorization scope
    log    Trying to get information about an individual subscription
    Set Headers    {"Accept":"${ACCEPT}"}  
    ${scope_value}=    Create Dictionary    scopeValue=${SUBSCRIPTIONS_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scope_value}    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
    Set Headers    {"Accept":"${ACCEPT}"}  
    ${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_HEADER}":"${authorizationToken}"}
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${subscriptionId}
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
 No newline at end of file
+67 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ Library JSONSchemaLibrary schemas/
Library    String
Library    Process
Library    MockServerLibrary
Library    jwt
Suite Setup       Create Sessions
Suite Teardown    Terminate All Processes    kill=true

@@ -298,6 +299,31 @@ POST Create a new Subscription - Unprocessable Content
    Post Create subscription
    Check HTTP Response Status Code Is    422
    Check HTTP Response Body Json Schema Is  ProblemDetails
Create a new subscription with permitted authorization scope
    [Documentation]    Test ID: 6.3.4.4.23
    ...    Test title: Create a new subscription with permitted authorization scope
    ...    Test objective: The objective is to create a new subscription.
    ...    Pre-conditions: no subscription with the same filter and callbackUri exists
    ...    Reference: Clause 7.4.5.3.1 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: Resource created successfully
    Post Create subscription with permitted authorization scope
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is    FmSubscription
    Check HTTP Response Header Contain Link
    Check Postcondition resource exists
Create a new subscription with not permitted authorization scope
    [Documentation]    Test ID: 6.3.4.4.24
    ...    Test title: Create a new subscription with not permitted authorization scope
    ...    Test objective: The objective is to create a new subscription.
    ...    Pre-conditions: no subscription with the same filter and callbackUri exists
    ...    Reference: Clause 7.4.5.3.1 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: Resource created successfully
    Post Create subscription with not permitted authorization scope
    Check HTTP Response Status Code Is    403

*** Keywords ***
Void
@@ -526,3 +552,43 @@ Check Response for duplicated subscription
    Run Keyword If    ${VNFM_ALLOWS_DUPLICATE_SUBS} == 1    Check HTTP Response Status Code Is    201
    Run Keyword If    ${VNFM_ALLOWS_DUPLICATE_SUBS} == 1    Check HTTP Response Body Json Schema Is    FmSubscription
    Run Keyword If    ${VNFM_ALLOWS_DUPLICATE_SUBS} == 0    Check HTTP Response Status Code Is    303
JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded}
Post Create subscription with permitted authorization scope
    Log    Create subscription instance by POST to ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    ${scope_value}=    Create Dictionary    scopeValue=${SUBSCRIPTIONS_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scope_value}    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}     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
	${output}=    Output    response
	Set Global Variable    ${response}    ${output}
	Clear Requests    ${callback_endpoint}
Post Create subscription with not permitted authorization scope
    Log    Create subscription instance by POST to ${apiRoot}/${apiName}/${apiMajorVersion}/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_HEADER}":"${authorizationToken}"}
    ${template}=    Get File    jsons/fmSubscriptionRequest.json
    ${body}=        Format String   ${template}     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
	${output}=    Output    response
	Set Global Variable    ${response}    ${output}
	Clear Requests    ${callback_endpoint}
 No newline at end of file
Loading