Commit 8b545b36 authored by Mudassar Khan's avatar Mudassar Khan Committed by Giacomo Bernini
Browse files

implement OAuth scope test for VNFLCMCoordination API of SOL002

parent b5ccb3af
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -95,3 +95,27 @@ DELETE Cancellation of an Ongoing Individual Coordination Action - Method not Im
    ...    Post-Condition: none
    DELETE Cancellation of an Ongoing Individual Coordination Action
    Check HTTP Response Status Code Is    405
POST Cancellation of an Ongoing Individual Coordination Action with permitted authorization scope
    [Documentation]    Test ID: 6.3.6.4.8
    ...    Test title: POST Cancellation of an Ongoing Individual Coordination Action with permitted authorization scope
    ...    Test Objective: The objective is to test that POST request for cancellation of an ongoing individual coordination Action has accepted for processing.
    ...    pre-condition: The status of the related LCM operation occurance is "PROCESSING"
    ...    Reference: Clause 10.4.4.3.1 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: When there is an Ongoing individual LCM operation coordination action.
    ...    Post-Condition: none
    POST Cancellation of an Ongoing Individual Coordination Action with permitted authorization scope
    Check HTTP Response Status Code Is    202
    Check HTTP Response Body Should be Empty
POST Cancellation of an Ongoing Individual Coordination Action with not permitted authorization scope
    [Documentation]    Test ID: 6.3.6.4.9
    ...    Test title: POST Cancellation of an Ongoing Individual Coordination Action with not permitted authorization scope
    ...    Test Objective: The objective is to test that POST request for cancellation of an ongoing individual coordination Action has accepted for processing.
    ...    pre-condition: The status of the related LCM operation occurance is "PROCESSING"
    ...    Reference: Clause 10.4.4.3.1 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: When there is an Ongoing individual LCM operation coordination action.
    ...    Post-Condition: none
    POST Cancellation of an Ongoing Individual Coordination Action 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 −1
Original line number Diff line number Diff line
@@ -138,3 +138,29 @@ DELETE Coordination of a LCM Operation Occurance - Method not implemented
    ...    Post-Condition: none
    DELETE coordination of LCM operation Occurance
    Check HTTP Response Status Code Is    405
POST Coordination of LCM Operation Occurance and API Producer has Chosen the Synchronous Mode with permitted authorization scope
    [Documentation]    Test ID: 6.3.6.2.11
    ...    Test title: Post Coordination of an LCM operation occurrence with permitted authorization scope
    ...    Test Objective: The objective is to test the creation of new Individual Coordination Action, and perform a JSON schema validation of the returned LCM coordination data structure.
    ...    pre-condition: LCM operation occurrence resource is in Processing state
    ...    Reference: Clause 10.4.2.3.1 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: API producer has chosen the synchronous mode   
    ...    Post-Condition: none
    Post coordination of LCM operation Occurance and API Producer has Chosen Synchronous Mode with permitted authorization scope
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is    LcmCoord
    Check HTTP Response Header Contains    Location
    Check Postcondition LcmCoord Exists
POST Coordination of LCM Operation Occurance and API Producer has Chosen the Synchronous Mode with not permitted authorization scope
    [Documentation]    Test ID: 6.3.6.2.12
    ...    Test title: Post Coordination of an LCM operation occurrence with not permitted authorization scope
    ...    Test Objective: The objective is to test the creation of new Individual Coordination Action, and perform a JSON schema validation of the returned LCM coordination data structure.
    ...    pre-condition: LCM operation occurrence resource is in Processing state
    ...    Reference: Clause 10.4.2.3.1 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: API producer has chosen the synchronous mode   
    ...    Post-Condition: none
    Post coordination of LCM operation Occurance and API Producer has Chosen Synchronous Mode 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
+25 −1
Original line number Diff line number Diff line
@@ -94,3 +94,27 @@ DELETE Individual LCM Operation Coordination Results - Method not implemented
    ...    Post-Condition: none
    DELETE Individual LCM Operation Coordination Results
    Check HTTP Response Status Code Is    405
GET Individual LCM Operation Coordination Results - Coordination is Finished with permitted authorization scope
    [Documentation]    Test ID: 6.3.6.3.8
    ...    Test title: GET Individual LCM Operation Coordination Results - Coordination is Finished with permitted authorization scope
    ...    Test Objective: The objective is to test that coordination is finished and GET method reads individual LCM operation coordination results successfully, and perform a JSON schema validation of the returned LCM coordination data structure.
    ...    pre-condition: LCM operation occurrence resource is in Processing state
    ...    Reference: Clause 10.4.3.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: When the Individual LCM Operation Coordination is finished
    ...    Post-Condition: none
    GET Individual LCM Operation Coordination Results with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    LcmCoord
GET Individual LCM Operation Coordination Results - Coordination is Finished with not permitted authorization scope
    [Documentation]    Test ID: 6.3.6.3.9
    ...    Test title: GET Individual LCM Operation Coordination Results - Coordination is Finished with not permitted authorization scope
    ...    Test Objective: The objective is to test that coordination is finished and GET method reads individual LCM operation coordination results successfully, and perform a JSON schema validation of the returned LCM coordination data structure.
    ...    pre-condition: LCM operation occurrence resource is in Processing state
    ...    Reference: Clause 10.4.3.3.2 - ETSI GS NFV-SOL 002 [2] v4.5.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: When the Individual LCM Operation Coordination is finished
    ...    Post-Condition: none
    GET Individual LCM Operation Coordination Results 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
+72 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ Library JSONLibrary
Library    JSONSchemaLibrary    schemas/
Library    OperatingSystem
Library    DependencyLibrary
Library    jwt

*** Keywords *** 

@@ -342,3 +343,73 @@ DELETE API Version with apiMajorVersion
    Delete    ${apiRoot}/${apiName}/${apiMajorVersion}/api_versions
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse} 
JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded}
Post coordination of LCM operation Occurance and API Producer has Chosen Synchronous Mode with permitted authorization scope
    Pass Execution If    ${SYNCHRONOUS_MODE_SUPPORT} == 0    The API producer is in Asynchronous Mode. Skipping the test.
    Log    Create coordination action by POST to ${apiRoot}/${apiName}/${apiMajorVersion}/coordinations
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${scope_value}=    Create Dictionary    scopeValue=${LCMCOORDINATION_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/LcmCoordRequest.json
    ${body}=    Format String    ${template}    vnfInstanceId=${vnfInstanceId}    vnfLcmOpOccId=${vnfLcmOpOccId}    lcmOperationType=${lcmOperationType}    coordinationActionName=${coordinationActionName}    vnfLcmOpOccHref=${vnfLcmOpOccHref}    vnfInstanceHref=${vnfInstanceHref}
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/coordinations    ${body}
    ${outputResponse}=    Output    response
	Set Suite Variable    ${response}    ${outputResponse}
Post coordination of LCM operation Occurance and API Producer has Chosen Synchronous Mode with not permitted authorization scope
    Pass Execution If    ${SYNCHRONOUS_MODE_SUPPORT} == 0    The API producer is in Asynchronous Mode. Skipping the test.
    Log    Create coordination action by POST to ${apiRoot}/${apiName}/${apiMajorVersion}/coordinations
    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}"}
    ${template} =    Get File    jsons/LcmCoordRequest.json
    ${body}=    Format String    ${template}    vnfInstanceId=${vnfInstanceId}    vnfLcmOpOccId=${vnfLcmOpOccId}    lcmOperationType=${lcmOperationType}    coordinationActionName=${coordinationActionName}    vnfLcmOpOccHref=${vnfLcmOpOccHref}    vnfInstanceHref=${vnfInstanceHref}
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/coordinations    ${body}
    ${outputResponse}=    Output    response
	Set Suite Variable    ${response}    ${outputResponse}
GET Individual LCM Operation Coordination Results with permitted authorization scope
    Log    Requesting the retrieve of a finished coordination task 
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${scope_value}=    Create Dictionary    scopeValue=${LCMCOORDINATION_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}/lcmcoord/${apiMajorVersion}/coordinations/${Id_of_Finished_Coordination_Action}
    ${outputResponse}=    Output    response
	Set Suite Variable    ${response}    ${outputResponse} 
GET Individual LCM Operation Coordination Results with not permitted authorization scope
    Log    Requesting the retrieve of a finished coordination task 
    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}/lcmcoord/${apiMajorVersion}/coordinations/${Id_of_Finished_Coordination_Action}
    ${outputResponse}=    Output    response
	Set Suite Variable    ${response}    ${outputResponse} 
POST Cancellation of an Ongoing Individual Coordination Action with permitted authorization scope
    Log    Trying to initiates the cancellation of an ongoing coordination action.
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${scope_value}=    Create Dictionary    scopeValue=${LCMCOORDINATION_SCOPE}
    ${authorizationToken}=    JWT Encode    payload=${scope_value}    key=''    algorithm=${OAUTH_Encryption_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    POST    ${apiRoot}/lcmcoord/${apiMajorVersion}/coordinations/${Id_of_Ongoing_Coordination_Action}/cancel
    ${outputResponse}=    Output    response
	Set Suite Variable    ${response}    ${outputResponse}
POST Cancellation of an Ongoing Individual Coordination Action with not permitted authorization scope
    Log    Trying to initiates the cancellation of an ongoing coordination action.
    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}"}
    POST    ${apiRoot}/lcmcoord/${apiMajorVersion}/coordinations/${Id_of_Ongoing_Coordination_Action}/cancel
    ${outputResponse}=    Output    response
	Set Suite Variable    ${response}    ${outputResponse}
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@ ${EM-VNF_PORT} 8081 # Listening port of the NFVO
${EM-VNF_SCHEMA}    https
${CONTENT_TYPE_JSON}    application/json
${ACCEPT_JSON}         application/json
${LCMCOORDINATION_SCOPE}    lcmcoord:v1:all
${NEG_SCOPE}    lcmcoord:v1:invalid
${OAUTH_Encryption_ALGORITHM}   HS256

${SYNCHRONOUS_MODE_SUPPORT}      1  #Set it to 0 if API producer supporting Asynchronous mode, and set it to 1 if API producer supporting Synchronous mode.