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

added oauth scope tests for LogM jobs

parent 0a59cd38
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -231,3 +231,30 @@ DELETE Logging Jobs - Method not implemented
    ...    Post-Conditions: none
    DELETE Logging Jobs
    Check HTTP Response Status Code Is    405

POST Create a new logging job with permitted authorization scope
    [Documentation]    Test ID: 8.3.4.1.19 
    ...    Test title: POST Create a new logging job with permitted authorization scope
    ...    Test objective: The objective is to create a new logging job with permitted authorization scope.
    ...    Pre-conditions: none
    ...    Reference: clause 8.5.3.3.1 - ETSI GS NFV-SOL 009 [7] v4.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: logging job created
    POST Create a new logging job with permitted authorization scope
    Check HTTP Response Status Code Is    201
    Check HTTP Response Header Contains    Location
    Check HTTP Response Body Json Schema Is    LoggingJob
    Check Post-Condition Logging job is created

POST Create a new logging job with not permitted authorization scope
    [Documentation]    Test ID: 8.3.4.1.20 
    ...    Test title: POST Create a new logging job with not permitted authorization scope
    ...    Test objective: The objective is to test that the creation of a new logging job fails when a not permitted authorization scope is used.
    ...    Pre-conditions: none
    ...    Reference: clause 8.5.3.3.1 - ETSI GS NFV-SOL 009 [7] v4.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none
    POST Create a new logging job with not permitted authorization scope
    Check HTTP Response Status Code Is    401
 No newline at end of file
+34 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ Library JSONLibrary
Library    Collections
Library    JSONSchemaLibrary    schemas/
Library    Process
Library    jwt

*** Keywords ***
Check HTTP Response Status Code Is
@@ -41,6 +42,33 @@ POST Create a new logging job
    ${outputResponse}=    Output    response
	Set Global Variable    @{response}    ${outputResponse}

POST Create a new logging job with permitted authorization scope
     Log    Create a logging job
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    ${scopeValue}=    Create Dictionary    scope=${JOB_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/createLoggingJobRequest.json
    ${body}=        Format String   ${template}     objectInstanceId=${objectInstanceId} 
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/log_jobs    ${body}
    ${outputResponse}=    Output    response
	Set Global Variable    @{response}    ${outputResponse}

POST Create a new logging job with not permitted authorization scope
     Log    Create a logging job
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    ${scopeValue}=    Create Dictionary    scope=${JOB_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/createLoggingJobRequest.json
    ${body}=        Format String   ${template}     objectInstanceId=${objectInstanceId} 
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/log_jobs    ${body}
    ${outputResponse}=    Output    response
	Set Global Variable    @{response}    ${outputResponse}	
Check Post-Condition Logging job is created
    GET Logging Jobs
    Check HTTP Response Status Code Is    200
@@ -740,3 +768,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
@@ -11,6 +11,13 @@ ${AUTHORIZATION_TOKEN} Bearer 0b79bab50daca910b000d4f1a2b675d604257e42
${NEG_AUTHORIZATION_TOKEN}    Bearer negativetoken
${BAD_AUTHORIZATION_TOKEN}    Bear sometoken

${OAUTH_ENCRIPTION_ALGORITHM}    HS256
${JOB_PERMITTED_SCOPE}    nfvmanologm:v2:log_job
${JOB_NOT_PERMITTED_SCOPE}    nfvmanologm:v2:log_job:readonly
${REPORT_PERMITTED_SCOPE}    nfvmanologm:v2:log_report
${SUBSCRIPTIONS_PERMITTED_SCOPE}    nfvmanologm:v2:subscriptions
${NOT_PERMITTED_SCOPE}    nfvmanologm:v2:nvalid

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