Commit f72b9fa2 authored by Hammad Zafar's avatar Hammad Zafar Committed by Giacomo Bernini
Browse files

Notification Endpoint resource added in SOL012 PM-API

parent 25b7b4ba
Loading
Loading
Loading
Loading
+79 −0
Original line number Diff line number Diff line
*** Settings ***
Suite Setup       Create Sessions
Suite Teardown    Terminate All Processes    kill=true
Resource          environment/variables.txt
Library           MockServerLibrary
Library           Process
Library           OperatingSystem
Library           Collections

*** Test Cases ***
Policy Change Notification
    [Documentation]    Test ID: 10.3.1.8.1
    ...    Test title: Policy Change Notification
    ...    Test objective: The objective is to test the dispatch of Policy Change Notification when the policy is changed, and perform a JSON schema and content validation of the delivered notification. The action that triggers the notification under test is an explicit test step, but it is not performed by the test system.
    ...    Pre-conditions: A subscription for policy change notification is available in the NFV-MANO.
    ...    Reference: Clause 5.5.9.3.1 - ETSI GS NFV-SOL 012 [7] v3.4.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none 
    Trigger a change in Policy (external action) 
    Check Policy Management Notification Http POST Request Body Json Schema Is    PolicyChangeNotification
    Check Policy Management Notification Http POST Request Body notificationType attribute Is    PolicyChangeNotification
    
Policy Conflict Notification
    [Documentation]    Test ID: 10.3.1.8.2
    ...    Test title: Policy Conflict Notification
    ...    Test objective: The objective is to test the dispatch of Policy Conflict Notification when a conflict in policy is detected, and perform a JSON schema and content validation of the delivered notification. The action that triggers the notification under test is an explicit test step, but it is not performed by the test system.
    ...    Pre-conditions: A subscription for policy conflict notification is available in the NFV-MANO.
    ...    Reference: Clause 5.5.9.3.1 - ETSI GS NFV-SOL 012 [7] v3.4.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none 
    Trigger a conflict in Policy (external action) 
    Check Policy Management Notification Http POST Request Body Json Schema Is    PolicyConflictNotification
    Check Policy Management Notification Http POST Request Body notificationType attribute Is    PolicyConflictNotification
    
*** Keywords ***
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}:${callback_port}
    
Trigger a change in Policy (external action) 
    #do nothing
    Log    do nothing
    
Trigger a conflict in Policy (external action) 
    #do nothing
    Log    do nothing

Configure Notification Forward
    [Arguments]    ${schema}    ${endpoint}    ${endpoint_fwd}    
    Log  Creating mock Http POST forward to handle ${schema}
    &{notification_tmp}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON_SCHEMA"    body=${schema}
    &{notification_fwd}=  Create Mock Http Forward	${endpoint_fwd}
    Create Mock Expectation With Http Forward  ${notification_tmp}  ${notification_fwd}

Configure Policy Management Notification Handler
    [Arguments]    ${endpoint}    ${type}
    ${json}=    evaluate    {}
    set to dictionary   ${json}    notificationType    ${type}
    ${BODY}=    evaluate    json.dumps(${json})    json
    Log  Creating mock request and response to handle status notification
    &{notification_request}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
    &{notification_response}=  Create Mock Response	headers="Content-Type: application/json"  status_code=204
    Create Mock Expectation  ${notification_request}  ${notification_response}
    
Check Policy Management Notification Http POST Request Body Json Schema Is 
    [Arguments]    ${element}
    ${schema}=	Get File	schemas/${element}.schema.json
    Configure Notification Forward    ${schema}    ${callback_endpoint}    ${callback_endpoint_fwd}
    
Check Policy Management Notification Http POST Request Body notificationType attribute Is
    [Arguments]    ${type}
    Configure Policy Management Notification Handler    ${callback_endpoint_fwd}    ${type}
    Wait Until Keyword Succeeds    2 min   10 sec   Verify Mock Expectation    ${notification_request}
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}
   
 No newline at end of file
+127 −0
Original line number Diff line number Diff line
{
	"description": "This type represents a notification about policy change. It shall comply with the provisions  defined in table 5.6.2.7-1. This notification shall be triggered by the API producer when a policy has been changed as  the result of an operation of creating, transferring, deleting or modifying a policy.\n",
	"type": "object",
	"properties": {
		"id": {
			"description": "An identifier with the intention of being globally unique.\n",
			"type": "string"
		},
		"notificationType": {
			"description": "A string defined in IETF RFC 8259.\n",
			"type": "string"
		},
		"subscriptionId": {
			"description": "An identifier with the intention of being globally unique.\n",
			"type": "string"
		},
		"timeStamp": {
			"description": "Date-time stamp. Representation: String formatted according to IETF RFC 3339.\n",
			"type": "string",
			"format": "date-time"
		},
		"policyId": {
			"description": "An identifier with the intention of being globally unique.\n",
			"type": "string"
		},
		"affectedVersion": {
			"description": "A version.\n",
			"type": "string"
		},
		"previousSelectedVersion": {
			"description": "A version.\n",
			"type": "string"
		},
		"policyModifications": {
			"description": "This type represents the parameters for modifying a policy. It shall comply with the provisions defined in table 5.6.2.4-1\n",
			"type": "object",
			"properties": {
				"activationStatus": {
					"description": "The enumeration ActivationStatus shall comply with the provisions defined in table 5.6.4.3-1. It indicates the activation status of a policy.\n",
					"type": "string",
					"enum": [
						"ACTIVATED",
						"DEACTIVATED"
					]
				},
				"selectedVersion": {
					"description": "A version.\n",
					"type": "string"
				},
				"addAssociations": {
					"description": "Identifiers of entities to be added to the “associations” attribute in the “Policy” data structure which represents the policy. The API producer shall ignore the identifiers that already exist in the \"associations\" attribute in the “Policy” data structure. Shall be absent when the association feature is not applicable for the PF.\n",
					"type": "array",
					"items": {
						"description": "An identifier with the intention of being globally unique.\n",
						"type": "string"
					}
				},
				"removeAssociations": {
					"description": "Identifiers of entities to be removed from the “associations” attribute in the “Policy” data structure which represents the policy. The API producer shall ignore the identifiers that do not exist in the \"associations\" attribute in the “Policy” data structure. Shall be absent when the association feature is not applicable for the PF.\n",
					"type": "array",
					"items": {
						"description": "An identifier with the intention of being globally unique.\n",
						"type": "string"
					}
				},
				"removeAllAssociations": {
					"description": "Shall be set to TRUE if the policy is no longer associated to any specific entities managed by the PF. Shall be absent when the association feature is not applicable for the PF. If \"removeAllAssociations\" is set to TRUE, neither \"addAssociations\" nor “removeAssociations” attributes shall be present. Once all associations have been removed, how the PF determines the scope of applicability of the policy is outside the scope of the present document.\n",
					"type": "boolean"
				}
			}
		},
		"changeType": {
			"description": "The enumeration PolicyOperationType shall comply with the provisions defined in table 5.6.4.4-1.  It indicates the type of the policy change. Permitted values: * CREATE_POLICY:\tThe policy is created. * TRANSFER_POLICY:\tThe policy is transferred. * DELETE_POLICY:\tThe policy is deleted. * MODIFY_POLICY:\tThe policy is modified.\n",
			"type": "string",
			"enum": [
				"CREATE_POLICY",
				"TRANSFER_POLICY",
				"DELETE_POLICY",
				"MODIFY_POLICY"
			]
		},
		"_links": {
			"description": "Links to resources related to this notification.\n",
			"type": "object",
			"properties": {
				"subscription": {
					"description": "This type represents a link to a resource in a notification, using an absolute or relative URI.\n",
					"type": "object",
					"required": [
						"href"
					],
					"properties": {
						"href": {
							"description": "String formatted according to IETF RFC 3986.\n",
							"type": "string"
						}
					}
				},
				"objectInstance": {
					"description": "This type represents a link to a resource in a notification, using an absolute or relative URI.\n",
					"type": "object",
					"required": [
						"href"
					],
					"properties": {
						"href": {
							"description": "String formatted according to IETF RFC 3986.\n",
							"type": "string"
						}
					}
				}
			},
			"required": [
				"subscription"
			]
		}
	},
	"required": [
		"id",
		"notificationType",
		"subscriptionId",
		"timeStamp",
		"policyId",
		"changeType",
		"_links"
	]
}
 No newline at end of file
+96 −0
Original line number Diff line number Diff line
{
	"description": "This type represents a notification about policy conflict. It shall comply with the provisions  defined in table 5.6.2.8-1. This notification shall be triggered by the API producer when a policy conflict is detected,  and any of the policies specified in an associated notification subscription is impacted  by the conflict.\n",
	"type": "object",
	"properties": {
		"id": {
			"description": "An identifier with the intention of being globally unique.\n",
			"type": "string"
		},
		"notificationType": {
			"description": "A string defined in IETF RFC 8259.\n",
			"type": "string"
		},
		"subscriptionId": {
			"description": "An identifier with the intention of being globally unique.\n",
			"type": "string"
		},
		"timeStamp": {
			"description": "Date-time stamp. Representation: String formatted according to IETF RFC 3339.\n",
			"type": "string",
			"format": "date-time"
		},
		"policyIds": {
			"description": "Identifiers of the conflicting policies.  The policy identifier and the corresponding selected version are mapped by the order  in the array.\n",
			"type": "array",
			"items": {
				"description": "An identifier with the intention of being globally unique.\n",
				"type": "string"
			},
			"minItems": 2
		},
		"selectedVersions": {
			"description": "Selected versions of the conflicting policies.  The policy identifier and the corresponding selected version are mapped by the order  in the array.\n",
			"type": "array",
			"items": {
				"description": "A version.\n",
				"type": "string"
			},
			"minItems": 2
		},
		"conflictDescription": {
			"description": "A string defined in IETF RFC 8259.\n",
			"type": "string"
		},
		"_links": {
			"description": "Links to resources related to this notification.\n",
			"type": "object",
			"properties": {
				"subscription": {
					"description": "This type represents a link to a resource in a notification, using an absolute or relative URI.\n",
					"type": "object",
					"required": [
						"href"
					],
					"properties": {
						"href": {
							"description": "String formatted according to IETF RFC 3986.\n",
							"type": "string"
						}
					}
				},
				"objectInstances": {
					"description": "Link to the resources representing the policies to which the notified conflict applies.\n",
					"type": "array",
					"items": {
						"description": "This type represents a link to a resource in a notification, using an absolute or relative URI.\n",
						"type": "object",
						"required": [
							"href"
						],
						"properties": {
							"href": {
								"description": "String formatted according to IETF RFC 3986.\n",
								"type": "string"
							}
						}
					},
					"minItems": 2
				}
			},
			"required": [
				"subscription",
				"objectInstances"
			]
		}
	},
	"required": [
		"id",
		"notificationType",
		"subscriptionId",
		"timeStamp",
		"policyIds",
		"selectedVersions",
		"conflictDescription",
		"_links"
	]
}
 No newline at end of file