Commit 511cd51f authored by Giacomo Bernini's avatar Giacomo Bernini Committed by Giacomo Bernini
Browse files

updated policy related tests (subscriptions, ..)

parent 0fd124ff
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -75,7 +75,7 @@ PATCH an individual policy - Conflict
    ...    Config ID: Config_prod_NFV-MANO
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Applicability: none
    ...    Post-Conditions: none
    ...    Post-Conditions: none
    PATCH Individual Subscription
    PATCH Individual Policy
    Check HTTP Response Status Code Is    409
    Check HTTP Response Status Code Is    409
    Check HTTP Response Body Json Schema Is   ProblemDetails
    Check HTTP Response Body Json Schema Is   ProblemDetails


@@ -102,8 +102,7 @@ DELETE an individual policy - CONFLICT
    ...    Config ID: Config_prod_NFV-MANO
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Applicability: none
    ...    Post-Conditions: The individual policy is not deleted.
    ...    Post-Conditions: The individual policy is not deleted.
    Check Activation Status of Policy Is    ACTIVATED
    DELETE Individual Policy in status ACTIVATED
    DELETE Individual Policy
    Check HTTP Response Status Code Is    409
    Check HTTP Response Status Code Is    409
    Check HTTP Response Body Json Schema Is   ProblemDetails    
    Check HTTP Response Body Json Schema Is   ProblemDetails    
    Check Postcondition Individual Policy is Not Deleted
    Check Postcondition Individual Policy is Not Deleted
 No newline at end of file
+52 −4
Original line number Original line Diff line number Diff line
@@ -5,8 +5,15 @@ Library OperatingSystem
Library    JSONLibrary
Library    JSONLibrary
Library    JSONSchemaLibrary    schemas/
Library    JSONSchemaLibrary    schemas/
Library    String
Library    String
Library    MockServerLibrary
Library    Process


*** Keywords ***
*** Keywords ***
Create Sessions
    Start Process  java  -jar  ../../bin/mockserver-netty-5.5.0-jar-with-dependencies.jar  -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
    Create Mock Session  ${callback_uri}:${callback_port} 

POST API Version
POST API Version
    Set Headers    {"Accept":"${ACCEPT_JSON}"} 
    Set Headers    {"Accept":"${ACCEPT_JSON}"} 
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
@@ -116,6 +123,13 @@ Check Postcondition Individual Subscription Resource Returned in Location Header
    Should Be Equal    ${result['callbackUri']}    ${subscription['callbackUri']}
    Should Be Equal    ${result['callbackUri']}    ${subscription['callbackUri']}
    Log    Validated Issued subscription is same as original
    Log    Validated Issued subscription is same as original


Check Postcondition Policy subscription is created
    Log    Going to check postcondition
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${response['body']['id']}
    Integer    response status    200
    Log    Received a 200 OK as expected
    
Check HTTP Response Header Contains Link
Check HTTP Response Header Contains Link
    ${linkURL}=    Get Value From Json    ${response['headers']}    $..Link
    ${linkURL}=    Get Value From Json    ${response['headers']}    $..Link
    Should Not Be Empty    ${linkURL}
    Should Not Be Empty    ${linkURL}
@@ -130,9 +144,19 @@ POST subscriptions
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    ${body}=    Get File    jsons/PolicySubscriptionRequest.json
    ${body}=    Get File    jsons/PolicySubscriptionRequest.json
    ${body}=    Replace String    ${body}    \${callback_uri}    ${callback_uri}
    ${body}=    Replace String    ${body}    \${callback_port}    ${callback_port}
    ${body}=    Replace String    ${body}    \${callback_endpoint}    ${callback_endpoint}
    Log  Creating mock request and response to handle GET operation on notification endpoint
    &{notification_request}=  Create Mock Request Matcher	GET  ${callback_endpoint}
    &{notification_response}=  Create Mock Response	status_code=204
    Log    Issue the subscription request
    Create Mock Expectation  ${notification_request}  ${notification_response}
    Post    ${apiRoot}/${apiName}/${apiVersion}/subscriptions    ${body}    
    Post    ${apiRoot}/${apiName}/${apiVersion}/subscriptions    ${body}    
	${outputResponse}=    Output    response
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
	Set Global Variable    ${response}    ${outputResponse}
	Clear Requests    ${callback_endpoint}



POST subscriptions NO DUPLICATION
POST subscriptions NO DUPLICATION
    Log    Trying to create a subscription with an already created content
    Log    Trying to create a subscription with an already created content
@@ -140,11 +164,19 @@ POST subscriptions NO DUPLICATION
    Pass Execution If    ${NFVMANO_DUPLICATION} == 1    NFVMANO allows creation of redundant subscriptions
    Pass Execution If    ${NFVMANO_DUPLICATION} == 1    NFVMANO allows creation of redundant subscriptions
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    ${body}=    Get File    jsons/PolicySubscriptionRequest.json
    ${body}=    Get File    jsons/PolicySubscriptionRequest.json
    ${body}=    Replace String    ${body}    \${callback_uri}    ${callback_uri}
    ${body}=    Replace String    ${body}    \${callback_port}    ${callback_port}
    ${body}=    Replace String    ${body}    \${callback_endpoint}    ${callback_endpoint}
    Log  Creating mock request and response to handle GET operation on notification endpoint
    &{notification_request}=  Create Mock Request Matcher	GET  ${callback_endpoint}
    &{notification_response}=  Create Mock Response	status_code=204
    Log    Issue the subscription request
    Create Mock Expectation  ${notification_request}  ${notification_response}
    Post    ${apiRoot}/${apiName}/${apiVersion}/subscriptions    ${body}    
    Post    ${apiRoot}/${apiName}/${apiVersion}/subscriptions    ${body}    
	${outputResponse}=    Output    response
	${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
	Set Global Variable    ${response}    ${outputResponse}
	Clear Requests    ${callback_endpoint}
	
	
POST subscriptions with Invalid Request
POST subscriptions with Invalid Request
    Log    Trying to create a subscription with invalid request body
    Log    Trying to create a subscription with invalid request body
@@ -512,6 +544,16 @@ DELETE Individual Policy
    ${outputResponse}=    Output    response
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
	Set Global Variable    ${response}    ${outputResponse}


DELETE Individual Policy in status ACTIVATED
    Check Activation Status of Policy Is    ACTIVATED    
    log    Trying to delete an individual policy, no conflict
    Set Headers  {"Accept":"${ACCEPT}"}  
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Delete    ${apiRoot}/${apiName}/${apiVersion}/policies/${policyId}   
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}


Check Postcondition Individual Policy is Deleted
Check Postcondition Individual Policy is Deleted
    Log    Check Postcondition individual policy is deleted
    Log    Check Postcondition individual policy is deleted
    GET individual Policy
    GET individual Policy
@@ -519,7 +561,13 @@ Check Postcondition Individual Policy is Deleted


Check Activation Status of Policy Is
Check Activation Status of Policy Is
    [Arguments]    ${status}
    [Arguments]    ${status}
    Get Individual Policy
    Log    Check Activation Status
    Set Headers    {"Accept":"${ACCEPT}"}  
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/policies/${policyIdInActivatedStatus}  
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   Policy
    Check HTTP Response Body Json Schema Is   Policy
    Should be equal as strings    ${response['body']['activationStatus']}    ${status}
    Should be equal as strings    ${response['body']['activationStatus']}    ${status}


+4 −0
Original line number Original line Diff line number Diff line
*** Settings ***
*** Settings ***
Suite Setup    Create Sessions
Suite Teardown    Terminate All Processes    kill=true
Library    Process
Resource   environment/variables.txt 
Resource   environment/variables.txt 
Resource   PolicyManagementKeywords.robot 
Resource   PolicyManagementKeywords.robot 


@@ -16,6 +19,7 @@ POST Create a new subscription
    Check HTTP Response Status Code Is    201
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is    PolicySubscription
    Check HTTP Response Body Json Schema Is    PolicySubscription
    Check HTTP Response Header Contains    Location
    Check HTTP Response Header Contains    Location
    Check Postcondition Policy subscription is created
        
        
POST Create a new Subscription - DUPLICATION NOT ALLOWED
POST Create a new Subscription - DUPLICATION NOT ALLOWED
    [Documentation]    Test ID: 10.3.1.6.2
    [Documentation]    Test ID: 10.3.1.6.2
+1 −0
Original line number Original line Diff line number Diff line
@@ -44,6 +44,7 @@ ${policyId}
${policyId1}
${policyId1}
${policyId2}
${policyId2}
${policyVersion}
${policyVersion}
${policyIdInActivatedStatus}


${callbackResp}		127.0.0.1
${callbackResp}		127.0.0.1


+6 −5
Original line number Original line Diff line number Diff line
{
{
  "id": "",
  "filter": {
  "timeStamp": "",
    "notificationTypes": "PolicyChangeNotification",
  "status": "START",
    "policyIds": "",
  "callbackUri": "http://127.0.0.1/subscribe",
    "changeTypes": "CREATE_POLICY"
  "_links": ""
  },
  "callbackUri": "http://not-reachable-uri"
}
}
 No newline at end of file
Loading