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

added oauth scope tests for PM jobs

parent 2e27ec0c
Loading
Loading
Loading
Loading
+37 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ Library MockServerLibrary
Library     Process
Library     BuiltIn
Library     Collections

Library     jwt

*** Keywords ***
GET all NFV-MANO Performance Monitoring Jobs
@@ -130,6 +130,36 @@ Send Post Request to create new NFV-MANO Performance Monitoring Job
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Send Post Request to create new NFV-MANO Performance Monitoring Job with permitted authorization scope
    Log    Creating a new PM Job
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_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}
    ${template}=    Get File    jsons/CreatePmJobRequest.json
    ${body}=        Format String   ${template}     objectInstanceIds=${objectInstanceIds}    callbackUri=${callback_uri}
    Check GET response from Notification Endpoint
    POST    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs    ${body}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Send Post Request to create new NFV-MANO Performance Monitoring Job with not permitted authorization scope
    Log    Creating a new PM Job
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    ${scopeValue}=    Create Dictionary    scope=${JOBS_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}
    ${template}=    Get File    jsons/CreatePmJobRequest.json
    ${body}=        Format String   ${template}     objectInstanceIds=${objectInstanceIds}    callbackUri=${callback_uri}
    Check GET response from Notification Endpoint
    POST    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs    ${body}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Send Post Request to create new NFV-MANO Performance Monitoring Job - Unreachable Endpoint
    Log    Creating a new PM Job for unreachable notification endpoint
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
@@ -733,3 +763,9 @@ Create Sessions
    Start Process  java  -jar  ${MOCK_SERVER_JAR}  -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
    Create Mock Session  ${callback_uri}

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
@@ -243,3 +243,29 @@ POST Create new NFV-MANO Performance Monitoring Job - Unreachable Notification E
    Send Post Request to create new NFV-MANO Performance Monitoring Job - Unreachable Endpoint
    Check HTTP Response Status Code Is    422
    Check HTTP Response Body Json Schema Is   ProblemDetails

POST Create new NFV-MANO Performance Monitoring Job with permitted authorization scope
    [Documentation]    Test ID: 8.3.2.1.20
    ...    Test title:  POST Create a new NFV-MANO Performance Monitoring Job with permitted authorization scope
    ...    Test objective: The objective is to test the creation of a new NFV-MANO performance monitoring job with permitted authorization scope
    ...    Pre-conditions: A NFV-MANO instance is instantiated. One or more NFV-MANO performance jobs are set in the NFV-MANO.
    ...    Reference: clause 6.5.3.3.1 - ETSI GS NFV-SOL 009 [7] v4.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: The NFV-MANO Performance Job is successfully created on the NFV-MANO
    Send Post Request to create new NFV-MANO Performance Monitoring Job with permitted authorization scope
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is   PmJob
    Check Postcondition PmJob Exists

POST Create new NFV-MANO Performance Monitoring Job with not permitted authorization scope
    [Documentation]    Test ID: 8.3.2.1.21
    ...    Test title:  POST Create a new NFV-MANO Performance Monitoring Job with not permitted authorization scope
    ...    Test objective: The objective is to test that the creation of a new NFV-MANO performance monitoring job fails with not permitted authorization scope
    ...    Pre-conditions: A NFV-MANO instance is instantiated. One or more NFV-MANO performance jobs are set in the NFV-MANO.
    ...    Reference: clause 6.5.3.3.1 - ETSI GS NFV-SOL 009 [7] v4.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: The NFV-MANO Performance Job is successfully created on the NFV-MANO
    Send Post Request to create new NFV-MANO Performance Monitoring Job with not permitted authorization scope
    Check HTTP Response Status Code Is    401
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
@@ -9,6 +9,14 @@ ${AUTHORIZATION_TOKEN} Bearer 0b79bab50daca910b000d4f1a2b675d604257e42
${NEG_AUTHORIZATION_TOKEN}    Bearer negativetoken
${BAD_AUTHORIZATION_TOKEN}    Bear sometoken

${OAUTH_ENCRIPTION_ALGORITHM}    HS256
${JOBS_PERMITTED_SCOPE}    nfvmanopm:v2:pm_job_info
${JOBS_NOT_PERMITTED_SCOPE}    nfvmanopm:v2:pm_job_info:readonly
${THREHSOLD_PERMITTED_SCOPE}    nfvmanopm:v2:thresold_info
${THRESHOLD_NOT_PERMITTED_SCOPE}    nfvmanopm:v2:threshold_info:readonly
${NOT_PERMITTED_SCOPE}    nfvmanopm:v2:invalid


${CONTENT_TYPE_JSON}    application/json
${CONTENT_TYPE_PATCH}   application/merge-patch+json
${ACCEPT_JSON}    application/json