Commit 411dbddf authored by Muhammad Umair Khan's avatar Muhammad Umair Khan Committed by Giacomo Bernini
Browse files

implement oauth scope for SOL003 VNFIndicator API

parent 858d61ac
Loading
Loading
Loading
Loading
+27 −1
Original line number Diff line number Diff line
@@ -92,3 +92,29 @@ POST Individual VNF Indicator Subscription - Method not implemented
    ...    Post-Conditions: none
    Send Post Request for Individual VNF Indicator Subscription
    Check HTTP Response Status Code Is    405 

GET Individual VNF Indicator Subscription with permitted authorization scope
    [Documentation]    Test ID: 7.3.6.5.8
    ...    Test title: GET Individual VNF Indicator Subscription with permitted authorization scope
    ...    Test objective: The objective is to test the retrieval of individual VNF indicator subscription and perform a JSON schema validation of the returned subscription data structure with permitted authorization scope
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNFM.
    ...    Reference: Clause 8.4.6.3.2 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET Individual VNF Indicator Subscription with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   VnfIndicatorSubscription

GET Individual VNF Indicator Subscription with not permitted authorization scope
    [Documentation]    Test ID: 7.3.6.5.9
    ...    Test title: GET Individual VNF Indicator Subscription with not permitted authorization scope
    ...    Test objective: The objective is to test the retrieval of individual VNF indicator subscription and perform a JSON schema validation of the returned subscription data structure with not permitted authorization scope
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNFM.
    ...    Reference: Clause 8.4.6.3.2 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    GET Individual VNF Indicator 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
+29 −1
Original line number Diff line number Diff line
@@ -80,3 +80,31 @@ DELETE Individual VNF Indicator for VNF Instance - Method not implemented
    ...    Post-Conditions: none
    Send DELETE Request for individual indicator in VNF instance
    Check HTTP Response Status Code Is    405

Get Individual Indicator for VNF Instance with permitted authorization scope 
    [Documentation]    Test ID: 7.3.6.3.1
    ...    Test title: Get Individual Indicator for VNF Instance with permitted authorization scope 
    ...    Test objective: The objective is to test the retrieval of an indicator for a given VNF instance and perform a JSON schema validation of the returned indicator data structure with permitted authorization scope 
    ...    Pre-conditions: A VNF instance is instantiated. At least one measure of VNF indicator is available in the VNFM.
    ...    Reference: Clause 8.4.4.3.2 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    Get Individual Indicator for a VNF instance with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   vnfIndicator
    Check HTTP Response Body Includes Requested VNF Instance ID
    Check HTTP Response Body Includes Requested Indicator ID

Get Individual Indicator for VNF Instance with not permitted authorization scope 
    [Documentation]    Test ID: 7.3.6.3.1
    ...    Test title: Get Individual Indicator for VNF Instance with not permitted authorization scope 
    ...    Test objective: The objective is to test the retrieval of an indicator for a given VNF instance and perform a JSON schema validation of the returned indicator data structure with not permitted authorization scope 
    ...    Pre-conditions: A VNF instance is instantiated. At least one measure of VNF indicator is available in the VNFM.
    ...    Reference: Clause 8.4.4.3.2 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    Get Individual Indicator for a VNF instance 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
+28 −0
Original line number Diff line number Diff line
@@ -184,3 +184,31 @@ POST Create a new Subscription - Unprocessable Content
    Send Post Request for VNF Indicator Subscription
    Check HTTP Response Status Code Is    422
    Check HTTP Response Body Json Schema Is  ProblemDetails

Create new VNF indicator subscription with permitted authorization scope
    [Documentation]    Test ID: 7.3.6.4.5
    ...    Test title: Create new VNF indicator subscription with permitted authorization scope
    ...    Test objective: The objective is to test the creation of a new VNF indicator subscription and perform a JSON schema and content validation of the returned subscription data structure with permitted authorization scope
    ...    Pre-conditions: A VNF instance is instantiated.
    ...    Reference: Clause 8.4.5.3.1 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: The VNF indicator subscription is successfully set and it matches the issued subscription   
    Send Post Request for VNF Indicator Subscription with permitted authorization scope
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is    VnfIndicatorSubscription
    Check HTTP Response Body Matches the Subscription
    Check Postcondition VNF Indicator Subscription Is Set

Create new VNF indicator subscription with not permitted authorization scope
    [Documentation]    Test ID: 7.3.6.4.5
    ...    Test title: Create new VNF indicator subscription with not permitted authorization scope
    ...    Test objective: The objective is to test the creation of a new VNF indicator subscription and perform a JSON schema and content validation of the returned subscription data structure with not permitted authorization scope
    ...    Pre-conditions: A VNF instance is instantiated.
    ...    Reference: Clause 8.4.5.3.1 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: The VNF indicator subscription is successfully set and it matches the issued subscription   
    Send Post Request for VNF Indicator 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
+26 −0
Original line number Diff line number Diff line
@@ -168,3 +168,29 @@ Get VNF Indicators - Bad Request Response too Big
    Get all VNF indicators
    Check HTTP Response Status Code Is    400
    Check HTTP Response Body Json Schema Is   ProblemDetails

Get all VNF Indicators with permitted authorization scope 
    [Documentation]    Test ID: 7.3.6.1.14
    ...    Test title: Get all VNF Indicators with permitted authorization scope 
    ...    Test objective: The objective is to test the retrieval of all the available VNF indicators and perform a JSON schema validation of the collected indicators data structure with permitted authorization scope 
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF indicators are available in the VNFM.
    ...    Reference: Clause 8.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    Get all VNF indicators with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   vnfIndicators

Get all VNF Indicators with not permitted authorization scope 
    [Documentation]    Test ID: 7.3.6.1.15
    ...    Test title: Get all VNF Indicators with not permitted authorization scope 
    ...    Test objective: The objective is to test the retrieval of all the available VNF indicators and perform a JSON schema validation of the collected indicators data structure with not permitted authorization scope 
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF indicators are available in the VNFM.
    ...    Reference: Clause 8.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v4.5.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: none
    ...    Post-Conditions: none
    Get all VNF indicators 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
+110 −2
Original line number Diff line number Diff line
@@ -130,6 +130,45 @@ Send Post Request for Duplicated VNF indicator Subscription
    Verify Mock Expectation    ${notification_request}
	Clear Requests    ${callback_endpoint}

Send Post Request for VNF Indicator Subscription with permitted authorization scope
    Log    Trying to create a new subscription with permitted authorization scope
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${template}=    Get File    jsons/subscriptions.json
    ${body}=        Format String   ${template}     callback_uri=${callback_uri}    callback_port=${callback_port}    callback_endpoint=${callback_endpoint}
    ${scopeValue}=    Create Dictionary    scopeValue=${INDICATORS_SUBSCRIPTION_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  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}
	Verify Mock Expectation    ${notification_request}
	Clear Requests    ${callback_endpoint}

Send Post Request for VNF Indicator Subscription with not permitted authorization scope
    Log    Trying to create a new subscription with not permitted authorization scope
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${template}=    Get File    jsons/subscriptions.json
    ${body}=        Format String   ${template}     callback_uri=${callback_uri}    callback_port=${callback_port}    callback_endpoint=${callback_endpoint}
    ${scopeValue}=    Create Dictionary    scopeValue=${INDICATORS_SUBSCRIPTION_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  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}
	Verify Mock Expectation    ${notification_request}
	Clear Requests    ${callback_endpoint}
    
Send Put Request for VNF Indicator Subscriptions
    Log    Trying to perform a PUT. This method should not be implemented
@@ -283,6 +322,30 @@ Get all VNF indicators with invalid resource endpoint
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Get all VNF indicators with permitted authorization scope 
    Log    The GET method queries multiple VNF indicators with permitted authorization scope 
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    ${scopeValue}=    Create Dictionary    scopeValue=${INDICATORS_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 and validate response
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/indicators
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    Set Suite Variable    ${vnfIndicators}    ${response['body']}

Get all VNF indicators with not permitted authorization scope 
    Log    The GET method queries multiple VNF indicators with not permitted authorization scope 
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    ${scopeValue}=    Create Dictionary    scopeValue=${INDICATORS_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 and validate response
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/indicators
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    Set Suite Variable    ${vnfIndicators}    ${response['body']}

Send POST Request for all VNF indicators
    log    Trying to perform a POST. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
@@ -411,6 +474,26 @@ Get Individual Indicator for a VNF instance with invalid indicator identifier
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Get Individual Indicator for a VNF instance with permitted authorization scope 
    Log    This resource represents a VNF indicator related to a VNF instance with permitted authorization scope .
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    ${scopeValue}=    Create Dictionary    scopeValue=${INDICATORS_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}/indicators/${vnfInstanceId}/${indicatorId}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Get Individual Indicator for a VNF instance with not permitted authorization scope 
    Log    This resource represents a VNF indicator related to a VNF instance with not permitted authorization scope .
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    ${scopeValue}=    Create Dictionary    scopeValue=${INDICATORS_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}/indicators/${vnfInstanceId}/${indicatorId}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Send POST Request for individual indicator in VNF instance
    Log    Trying to perform a POST (method should not be implemented)
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
@@ -465,6 +548,26 @@ GET Individual VNF Indicator Subscription
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

GET Individual VNF Indicator Subscription with permitted authorization scope
    Log    Trying to get a given subscription identified by subscriptionId with permitted authorization scope
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    ${scopeValue}=    Create Dictionary    scopeValue=${INDICATORS_SUBSCRIPTION_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}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

GET Individual VNF Indicator Subscription with not permitted authorization scope
    Log    Trying to get a given subscription identified by subscriptionId with not permitted authorization scope
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    ${scopeValue}=    Create Dictionary    scopeValue=${INDICATORS_SUBSCRIPTION_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}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

GET Individual VNF Indicator Subscription with invalid resource identifier
    Log    Trying to perform a request on a subscriptionID which doesn't exist
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
@@ -538,3 +641,8 @@ Check Notification Endpoint
Check HTTP Response Header Contain Link
    ${linkURL}=    Get Value From Json    ${response['headers']}    $..Link
    Should Not Be Empty    ${linkURL}

JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded}
 No newline at end of file
Loading