Commit 7c1c5296 authored by Giacomo Bernini's avatar Giacomo Bernini Committed by Giacomo Bernini
Browse files

added oauth scope tests for alarms

parent 3b108109
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -221,3 +221,28 @@ DELETE Alarms - Method not implemented
    DELETE Fault management Alarms
    Check HTTP Response Status Code Is    405

Get information about multiple alarms with permitted authorization scope
    [Documentation]    Test ID: 8.3.3.1.18
    ...    Test title: Get information about multiple alarms with permitted authorization scope
    ...    Test objective: The objective is to retrieve information about the alarm list with permitted authorization scope
    ...    Pre-conditions: none
    ...    Reference: clause 7.5.3.3.2 - ETSI GS NFV-SOL 009 [7] v4.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none
    GET Fault Management Alarms 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: 8.3.3.1.19
    ...    Test title: Get information about multiple alarms with not permitted authorization scope
    ...    Test objective: The objective is to test that retrieve information about the alarm list fails with not permitted authorization scope
    ...    Pre-conditions: none
    ...    Reference: clause 7.5.3.3.2 - ETSI GS NFV-SOL 009 [7] v4.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none
    GET Fault Management Alarms with not permitted authorization scope
    Check HTTP Response Status Code Is    401
    
 No newline at end of file
+30 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ Library OperatingSystem
Library    Collections
Library    MockServerLibrary
Library    Process
Library    jwt

# *** Variables ***
# ${original_etag}    1234
@@ -37,6 +38,30 @@ GET Fault Management Alarms
    ${outputResponse}=    Output    response
    Set Global Variable    @{response}    ${outputResponse}

GET Fault Management Alarms with permitted authorization scope
    Log    Query NFV-MANO The GET method queries information about multiple alarms.
    Set Headers  {"Accept":"${ACCEPT}"}  
    ${scopeValue}=    Create Dictionary    scope=${ALARMS_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}
    Log    Execute Query
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms
    ${outputResponse}=    Output    response
    Set Global Variable    @{response}    ${outputResponse}
    
GET Fault Management Alarms with not permitted authorization scope
    Log    Query NFV-MANO The GET method queries information about multiple alarms.
    Set Headers  {"Accept":"${ACCEPT}"}  
    ${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}
    Log    Execute Query
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms
    ${outputResponse}=    Output    response
    Set Global Variable    @{response}    ${outputResponse}

Check HTTP Response Body Json Schema Is
    [Arguments]    ${input}
    Run Keyword If    '${input}' == 'ProblemDetails'    Should Contain    ${response['headers']['Content-Type']}    application/problem+json
@@ -713,3 +738,8 @@ 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} 
+7 −0
Original line number Diff line number Diff line
@@ -10,6 +10,13 @@ ${ACCEPT_JSON} application/json
${AUTH_USAGE}     1
${NEG_AUTHORIZATION_TOKEN}    Bearer negativetoken
${BAD_AUTHORIZATION_TOKEN}    Bear sometoken

${OAUTH_ENCRIPTION_ALGORITHM}    HS256
${ALAMRS_PERMITTED_SCOPE}    nfvmanofm:v2:alarm_info
${ALARMS_NOT_PERMITTED_SCOPE}    nfvmanofm:v2:alarm_info:readonly
${NOT_PERMITTED_SCOPE}    nfvmanofm:v2:policies:invalid


${apiRoot}        /
${apiName}        nfvmanofm
${apiMajorVersion}     v1