Commit 9faaf618 authored by Mudassar Khan's avatar Mudassar Khan Committed by Giacomo Bernini
Browse files

implement OAuth scope test for VNFIndicators API of SOL002

parent 121c6ab2
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
*** Settings ***
Library           JSONSchemaLibrary    schemas/
Resource          environment/variables.txt    # Generic Parameters
Library           jwt
Library           OperatingSystem
Library           REST    ${EM-VNF_SCHEMA}://${EM-VNF_HOST}:${EM-VNF_PORT}    ssl_verify=false

@@ -92,6 +93,30 @@ 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: 6.3.2.5.8
    ...    Test title: Get individual subscription to VNF performance indicators with permitted authorization scope
    ...    Test objective: The objective is to test the retrieval of individual VNF performance indicator subscription and perform a JSON schema validation of the returned subscription data structure
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
    ...    Reference: Clause 8.4.6.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators
    ...    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: 6.3.2.5.9
    ...    Test title: Get individual subscription to VNF performance indicators with NOT permitted authorization scope
    ...    Test objective: The objective is to test the retrieval of individual VNF performance indicator subscription and perform a JSON schema validation of the returned subscription data structure
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
    ...    Reference: Clause 8.4.6.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators
    ...    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

*** Keywords ***
Get Individual VNF Indicator Subscription
@@ -178,3 +203,27 @@ Check Postcondition Individual VNF Indicator Subscription is Deleted
    Log    Check Postcondition subscription is deleted
    GET Individual VNF Indicator Subscription
    Check HTTP Response Status Code Is    404
JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded}
Get Individual VNF Indicator Subscription with permitted authorization scope
    Log    Trying to get a given subscription identified by subscriptionId
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${scope_value}=    Create Dictionary    scopeValue=${SUBSCRIPTIONS_VNF_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}
    ${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
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${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}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
+52 −1
Original line number Diff line number Diff line
*** Settings ***
Library           JSONSchemaLibrary    schemas/
Library           jwt
Resource          environment/variables.txt    # Generic Parameters
Library           REST    ${EM-VNF_SCHEMA}://${EM-VNF_HOST}:${EM-VNF_PORT}    ssl_verify=false

@@ -154,6 +155,32 @@ DELETE Individual Performance Indicator - Method not implemented
    ...    Post-Conditions: none
    Send DELETE Request for individual indicator
    Check HTTP Response Status Code Is    405
Get Individual Indicator for VNF Instance with permitted authorization scope
    [Documentation]    Test ID: 6.3.2.3.13
    ...    Test title: Get individual performance indicator for a VNF instance with permitted authorization scope
    ...    Test objective: The objective is to test the retrieval of a performance indicator for a given VNF instance and perform a JSON schema validation of the returned indicator data structure
    ...    Pre-conditions: A VNF instance is instantiated. At least one measure of performance indicator is available for the given VNF instance.
    ...    Reference: Clause 8.4.4.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators
    ...    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: 6.3.2.3.13
    ...    Test title: Get individual performance indicator for a VNF instance with NOT permitted authorization scope
    ...    Test objective: The objective is to test the retrieval of a performance indicator for a given VNF instance and perform a JSON schema validation of the returned indicator data structure
    ...    Pre-conditions: A VNF instance is instantiated. At least one measure of performance indicator is available for the given VNF instance.
    ...    Reference: Clause 8.4.4.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators
    ...    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
    
*** Keywords ***
Get Individual Indicator for a VNF instance
@@ -279,3 +306,27 @@ Send DELETE Request for individual indicator
    DELETE    ${apiRoot}/${apiName}/${apiMajorVersion}/indicators/${indicatorId}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output} 
JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded}
Get Individual Indicator for a VNF instance with permitted authorization scope
    Log    This resource represents a VNF indicator related to a VNF instance.
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${scope_value}=    Create Dictionary    scopeValue=${INDICATORS_EM_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}/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.
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${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}/indicators/${vnfInstanceId}/${indicatorId}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
 No newline at end of file
+49 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ Resource environment/variables.txt # Generic Parameters
Library           OperatingSystem
Library           JSONLibrary
Library           Process
Library           jwt
Library           MockServerLibrary
Library           String 
Library           REST    ${EM-VNF_SCHEMA}://${EM-VNF_HOST}:${EM-VNF_PORT}    ssl_verify=false
@@ -180,6 +181,30 @@ Create new VNF indicator Subscription - NO-DUPLICATION
    Post Create subscription - NO-DUPLICATION
    Check HTTP Response Status Code Is    303
    Check Operation Occurrence Id
GET VNF Indicators Subscriptions with permitted authorization scope
    [Documentation]    Test ID: 6.3.2.4.14
    ...    Test title: GET VNF Indicators Subscriptions with permitted authorization scope
    ...    Test objective: The objective is to test the retrieval of all VNF indicators subscriptions and perform a JSON schema validation of the returned subscriptions data structure
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
    ...    Reference: Clause 8.4.5.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of indicators
    ...    Post-Conditions: none
    Get VNF Indicators Subscriptions with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   VnfIndicatorSubscriptions
GET VNF Indicators Subscriptions with NOT permitted authorization scope
    [Documentation]    Test ID: 6.3.2.4.15
    ...    Test title: GET VNF Indicators Subscriptions with not permitted authorization scope
    ...    Test objective: The objective is to test the retrieval of all VNF indicators subscriptions and perform a JSON schema validation of the returned subscriptions data structure
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
    ...    Reference: Clause 8.4.5.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of indicators
    ...    Post-Conditions: none
    Get VNF Indicators Subscriptions with not permitted authorization scope
    Check HTTP Response Status Code Is    403
    Check HTTP Response Body Json Schema Is   ProblemDetails
 
*** Keywords ***
Get VNF Indicators Subscriptions
@@ -368,3 +393,27 @@ Post Create subscription - NO-DUPLICATION
Check Operation Occurrence Id
    ${vnfLcmOpOccId}=    Get Value From Json    ${response['headers']}    $..Location
    Should Not Be Empty    ${vnfLcmOpOccId}
JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded}
Get VNF Indicators Subscriptions with permitted authorization scope
    Log    Trying to get the list of subscriptions
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${scope_value}=    Create Dictionary    scopeValue=${SUBSCRIPTIONS_VNF_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
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
Get VNF Indicators Subscriptions with not permitted authorization scope
    Log    Trying to get the list of subscriptions
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${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
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
+51 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ Documentation This Clause defines all the resources and methods provided by
Library           JSONSchemaLibrary    schemas/
Resource          environment/variables.txt    # Generic Parameters
Library           JSONLibrary
Library           jwt
Library           String
Library           REST    ${EM-VNF_SCHEMA}://${EM-VNF_HOST}:${EM-VNF_PORT}    ssl_verify=false

@@ -172,7 +173,30 @@ 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: 6.3.2.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
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF performance indicators are available in the VNF.
    ...    Reference: Clause 8.4.2.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators.
    ...    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: 6.3.2.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
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF performance indicators are available in the VNF.
    ...    Reference: Clause 8.4.2.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators.
    ...    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
*** Keywords ***
Get all VNF indicators
    Log    The GET method queries multiple VNF indicators
@@ -302,3 +326,29 @@ Check HTTP Response Body vnfIndicators Matches the requested attribute-based fil
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}
Get all VNF indicators with permitted authorization scope
    Log    The GET method queries multiple VNF indicators
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${scope_value}=    Create Dictionary    scopeValue=${INDICATORS_VNF_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}/indicators
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
Get all VNF indicators with not permitted authorization scope
    Log    The GET method queries multiple VNF indicators
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${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}/indicators
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
+53 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ Documentation This resource represents VNF indicators related to a VNF insta
Library           JSONSchemaLibrary    schemas/
Resource          environment/variables.txt    # Generic Parameters
Library           JSONLibrary
Library           jwt
Library           String 
Library           REST    ${EM-VNF_SCHEMA}://${EM-VNF_HOST}:${EM-VNF_PORT}    ssl_verify=false

@@ -134,6 +135,31 @@ Get Indicators for VNF Instance - Bad Request Response too Big
    Get all indicators for a VNF instance
    Check HTTP Response Status Code Is    400
    Check HTTP Response Body Json Schema Is   ProblemDetails
Get Indicators for VNF Instance with permitted authorization scope
    [Documentation]    Test ID: 6.3.2.2.11
    ...    Test title: Get all performance indicators for a VNF instance
    ...    Test objective: The objective is to test the retrieval of all performance indicators for a given VNF instance and perform a JSON schema validation of the returned indicators data structure
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of performance indicators are available for the given VNF instance.
    ...    Reference: Clause 8.4.3.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators
    ...    Post-Conditions: none
    Get all indicators for a VNF instance with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   vnfIndicators
    Check HTTP Response Body Includes Requested VNF Instance ID
Get Indicators for VNF Instance with NOT permitted authorization scope
    [Documentation]    Test ID: 6.3.2.2.11
    ...    Test title: Get all performance indicators for a VNF instance
    ...    Test objective: The objective is to test the retrieval of all performance indicators for a given VNF instance and perform a JSON schema validation of the returned indicators data structure
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of performance indicators are available for the given VNF instance.
    ...    Reference: Clause 8.4.3.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators
    ...    Post-Conditions: none
    Get all indicators for a VNF instance with not permitted authorization scope
    Check HTTP Response Status Code Is    403
    Check HTTP Response Body Json Schema Is   ProblemDetails

*** Keywords ***
Get all indicators for a VNF instance
@@ -232,3 +258,29 @@ Check HTTP Response Body Matches Attribute-Based Filter
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}
Get all indicators for a VNF instance with permitted authorization scope
    Log    This resource represents VNF indicators related to a VNF instance.
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${scope_value}=    Create Dictionary    scopeValue=${INDICATORS_EM_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scope_value}    key=''    algorithm=${OAUTH_Encryption_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/indicators/${vnfInstanceId}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
Get all indicators for a VNF instance with not permitted authorization scope
    Log    This resource represents VNF indicators related to a VNF instance.
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${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}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/indicators/${vnfInstanceId}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
 No newline at end of file
Loading