Commit 5a1d810f authored by Giacomo Bernini's avatar Giacomo Bernini Committed by Giacomo Bernini
Browse files

added oauth scope tests for NFVICI information

parent 522af155
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -192,3 +192,28 @@ DELETE NFVI Capacity Information - Method not implemented
    ...    Post-Conditions: none
    DELETE NFVI Capacity Information
    Check HTTP Response Status Code Is    405

GET NFVI Capacity Information with permitted authorization scope
    [Documentation]    Test ID: 5.3.6.2.16
    ...    Test title: GET NFVI Capacity Information with permitted authorization scope
    ...    Test objective: The objective is to GET NFVI Capacity Information objects with permitted authorization scope
    ...    Pre-conditions: none
    ...    Reference: Clause 10.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
    GET NFVI Capacity Information with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    NfviCapacityInfos

GET NFVI Capacity Information with not permitted authorization scope
    [Documentation]    Test ID: 5.3.6.2.17
    ...    Test title: GET NFVI Capacity Information with not permitted authorization scope
    ...    Test objective: The objective is to test that GET NFVI Capacity Information objects fails when using not permitted authorization scope
    ...    Pre-conditions: none
    ...    Reference: Clause 10.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
    GET NFVI Capacity Information with not permitted authorization scope
    Check HTTP Response Status Code Is    401
+31 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ Library JSONLibrary
Library     JSONSchemaLibrary    schemas/
Library     OperatingSystem
Library     String
Library     jwt

*** Keywords ***
POST API Version
@@ -110,6 +111,30 @@ GET NFVI Capacity Information
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse} 	

GET NFVI Capacity Information with permitted authorization scope
    Log    The GET method queries information about NFVI Capacity Information.
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${scopeValue}=    Create Dictionary    scope=${INFOS_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Log    Authorization Token: ${authorizationToken}
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/nfvi_capacity_infos 
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse} 	

GET NFVI Capacity Information with not permitted authorization scope
    Log    The GET method queries information about NFVI Capacity Information.
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${scopeValue}=    Create Dictionary    scope=${NOT_PERMITTED_SCOPE} 
    ${authorizationToken}=    JWT Encode    payload=${scopeValue}    key=''    algorithm=${OAUTH_ENCRIPTION_ALGORITHM}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${authorizationToken}"}
    Log    Authorization Token: ${authorizationToken}
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/nfvi_capacity_infos 
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse} 

GET NFVI Capacity Information with filter
    Log    The GET method queries information about NFVI Capacity Information.
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
@@ -512,3 +537,8 @@ DELETE notification endpoint
    Delete    ${callbackResp}
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

JWT Encode
    [Arguments]    ${payload}    ${key}    ${algorithm}
    ${encoded}=    Evaluate    jwt.encode(${payload}, ${key}, ${algorithm})
    [Return]    ${encoded} 
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -4,6 +4,11 @@ ${NFVO_PORT} 8081 # Listening port of the NFVO
${NFVO_SCHEMA}    https
${AUTHORIZATION_HEADER}    Authorization
${AUTHORIZATION_TOKEN}    Bearer 0b79bab50daca910b000d4f1a2b675d604257e42

${INFOS_PERMITTED_SCOPE}    nfvici:v2:nfvi_capacity_infos
${THRESHOLDS_PERMITTED_SCOPE}    nfvici:v2:thresholds
${NOT_PERMITTED_SCOPE}    nfvici:v2:invalid

${ACCEPT_JSON}    application/json
${AUTH_USAGE}     1
${CONTENT_TYPE_JSON}    application/json