Commit cc1a2aa5 authored by Giacomo Bernini's avatar Giacomo Bernini Committed by Giacomo Bernini
Browse files

added oauth scope tests for NSPM jobs

parent 72191c8c
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ Library Collections
Library    JSONSchemaLibrary    schemas/
Library    Process
Library    String
Library    jwt

*** Keywords ***
GET all NS Performance Monitoring Jobs
@@ -19,6 +20,28 @@ GET all NS Performance Monitoring Jobs
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

GET all NS Performance Monitoring Jobs with permitted authorization scope
    Log    Trying to get all PM Jobs present in the NFVO
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    ${scopeValue}=    Create Dictionary    scope=${JOBS_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}/pm_jobs
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

GET all NS Performance Monitoring Jobs with not permitted authorization scope
    Log    Trying to get all PM Jobs present in the NFVO
    Set Headers    {"Accept": "${ACCEPT_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}/pm_jobs
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

GET NS Performance Monitoring Jobs with attribute-based filter
    Log    Trying to get all PM Jobs present in the NFVO, using filter params
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
@@ -687,3 +710,8 @@ Check Notification Endpoint
Check HTTP Response Header Contains Location
    ${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} 
+26 −0
Original line number Diff line number Diff line
@@ -224,3 +224,29 @@ POST new NS Performance Monitoring Job - Unprocessable Content
    Send POST request for NS Performance Monitoring Job with unprocessable content
    Check HTTP Response Status Code Is    422
    Check HTTP Response Body Json Schema Is    ProblemDetails

GET all NS Performance Monitoring Jobs with permitted authorization scope
    [Documentation]    Test ID: 5.3.4.1.17
    ...    Test title: GET all NS Performance Monitoring Jobs with permitted authorization scope
    ...    Test objective: The objective is to test the retrieval of all the available NS performance monitoring jobs with permitted authorization scope
    ...    Pre-conditions: A NS instance is instantiated. One or more NS performance jobs are set in the NFVO.
    ...    Reference: Clause 7.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
    GET all NS Performance Monitoring Jobs with permitted authorization scope
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   PmJobs
    Check HTTP Response Body PmJobs Do Not Contain reports

GET all NS Performance Monitoring Jobs with not permitted authorization scope
    [Documentation]    Test ID: 5.3.4.1.17
    ...    Test title: GET all NS Performance Monitoring Jobs with not permitted authorization scope
    ...    Test objective: The objective is to test that the retrieval of all the available NS performance monitoring jobs fails when using not permitted authorization scope
    ...    Pre-conditions: A NS instance is instantiated. One or more NS performance jobs are set in the NFVO.
    ...    Reference: Clause 7.4.2.3.2 - ETSI GS NFV-SOL 005 [3] v4.5.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none
    GET all NS Performance Monitoring Jobs with not permitted authorization scope
    Check HTTP Response Status Code Is    401
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
@@ -4,6 +4,12 @@ ${NFVO_PORT} 8081 # Listening port of the NFVO
${NFVO_SCHEMA}    https
${AUTHORIZATION_HEADER}    Authorization
${AUTHORIZATION_TOKEN}    Bearer 0b79bab50daca910b000d4f1a2b675d604257e42

${OAUTH_ENCRIPTION_ALGORITHM}    HS256
${JOBS_PERMITTED_SCOPE}    nspm:v2:pm_jobs 
${THRESHOLDS_PERMITTED_SCOPE}    nspm:v2:thresholds 
${NOT_PERMITTED_SCOPE}    nspm:v2:invalid

${CONTENT_TYPE_JSON}    application/json
${ACCEPT_JSON}    application/json
${apiRoot}        /