Commit 75f39646 authored by Giacomo Bernini's avatar Giacomo Bernini Committed by Giacomo Bernini
Browse files

added oauth scope tests for NSFM Alarms

parent 7681ee20
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -284,3 +284,28 @@ GET information about multiple alarms with filter "probableCause"
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    alarms
    Check PostCondition HTTP Response Body alarms Matches the requested attribute-based filter "probableCause"

GET information about multiple alarms with permitted authorization scope
    [Documentation]    Test ID: 5.3.3.1.22
    ...    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 8.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Config ID: Config_prod_NFVO 
    ...    Applicability:  none
    ...    Post-Conditions: none
    GET 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: 5.3.3.1.22
    ...    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 when using not permitted authorization scope
    ...    Pre-conditions:  none
    ...    Reference: Clause 8.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Config ID: Config_prod_NFVO 
    ...    Applicability:  none
    ...    Post-Conditions: none
    GET Alarms with not permitted authorization scope
    Check HTTP Response Status Code Is    401
+29 −0
Original line number Diff line number Diff line
@@ -100,6 +100,30 @@ GET Alarms
    ${outputResponse}=    Output    response
    Set Global Variable    ${response}    ${outputResponse}

GET Alarms with permitted authorization scope
    Log    Query NFVO 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 Alarms with not permitted authorization scope
    Log    Query NFVO 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}
    
GET Alarms With Filters
	Log    Query NFVO The GET method queries information about multiple alarms with filters.
	Set Headers  {"Accept":"${ACCEPT}"}  
@@ -643,3 +667,8 @@ Check Response for duplicated subscription
    Run Keyword If    ${NFVO_ALLOWS_DUPLICATE_SUBS} == 1    Check HTTP Response Status Code Is    201
    Run Keyword If    ${NFVO_ALLOWS_DUPLICATE_SUBS} == 1    Check HTTP Response Body Json Schema Is    FmSubscription
    Run Keyword If    ${NFVO_ALLOWS_DUPLICATE_SUBS} == 0    Check HTTP Response Status Code Is    303

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

${OAUTH_ENCRIPTION_ALGORITHM}    HS256
${ALARMS_PERMITTED_SCOPE}    nsfm:v2:alarms 
${ALARMS_NOT_PERMITTED_SCOPE}    nsfm:v2:alarms:readonly
${SUBSCRIPTIONS_PERMITTED_SCOPE}    nsfm:v2:subscriptions
${NOT_PERMITTED_SCOPE}    nsfm:v2:invalid 

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