From 40eb3a885893603374d73f664fc1c142aa0473b8 Mon Sep 17 00:00:00 2001
From: Giacomo Bernini <g.bernini@nextworks.it>
Date: Wed, 13 Jan 2021 12:01:45 +0100
Subject: [PATCH] fixes to  NSInstanceUsageNotification-API

---
 .../IndividualSubscription.robot              |  1 +
 .../NSInstanceUsageNotificationKeywords.robot | 35 +++++++++++++++++++
 .../Subscriptions.robot                       |  8 +++--
 3 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/SOL011/NSInstanceUsageNotification-API/IndividualSubscription.robot b/SOL011/NSInstanceUsageNotification-API/IndividualSubscription.robot
index c742db50..5f8fa000 100644
--- a/SOL011/NSInstanceUsageNotification-API/IndividualSubscription.robot
+++ b/SOL011/NSInstanceUsageNotification-API/IndividualSubscription.robot
@@ -67,6 +67,7 @@ DELETE an individual subscription
     ...    Post-Conditions: The NS instance usage notification subscription is not available anymore on NFVO
     DELETE Individual Subscription
     Check HTTP Response Status Code Is    204
+    Check Postcondition Individual Subscription is Deleted
     
 GET Information about an individual subscription - NOT FOUND
      [Documentation]    Test ID: 9.3.4.2.6
diff --git a/SOL011/NSInstanceUsageNotification-API/NSInstanceUsageNotificationKeywords.robot b/SOL011/NSInstanceUsageNotification-API/NSInstanceUsageNotificationKeywords.robot
index 0a71abbb..dd619445 100644
--- a/SOL011/NSInstanceUsageNotification-API/NSInstanceUsageNotificationKeywords.robot
+++ b/SOL011/NSInstanceUsageNotification-API/NSInstanceUsageNotificationKeywords.robot
@@ -225,3 +225,38 @@ Get subscriptions with exclude_default and fields attribute selector
     GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions?fields=${fields}&exclude_default
     ${output}=    Output    response
     Set Suite Variable    ${response}    ${output}
+
+Check Postcondition Individual Subscription is Deleted
+    Log    Check Postcondition Subscription is deleted
+    GET individual Subscription
+    Check HTTP Response Status Code Is    404 
+
+Check Postcondition Subscription Is Set
+    Log    Check Postcondition subscription exist
+    Log    Trying to get the subscription
+    Set Headers    {"Accept": "${ACCEPT_JSON}"}
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
+    GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${response['body']['id']}
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+    Check HTTP Response Status Code Is    200
+
+Check Postcondition Subscription Resource Returned in Location Header Is Available
+    Log    Going to check postcondition
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
+    GET    ${response['headers']['Location']}
+    Integer    response status    200
+    Log    Received a 200 OK as expected
+    ${contentType}=    Output    response headers Content-Type
+    Should Contain    ${contentType}    application/json
+    ${result}=    Output    response body
+    Validate Json    NsdmSubscription.schema.json    ${result}
+    Log    Validated NsdmSubscription schema
+    ${body}=    Get File    jsons/subscriptions.json
+    ${subscription}=    evaluate    json.loads('''${body}''')    json
+    Should Be Equal    ${result['callbackUri']}    ${subscription['callbackUri']}
+    Log    Validated Issued subscription is same as original
+
+Check Postcondition Subscriptions Exist
+    Log    Checking that subscriptions exists
+    Get Subscriptions 
\ No newline at end of file
diff --git a/SOL011/NSInstanceUsageNotification-API/Subscriptions.robot b/SOL011/NSInstanceUsageNotification-API/Subscriptions.robot
index dd9d259e..efde683f 100644
--- a/SOL011/NSInstanceUsageNotification-API/Subscriptions.robot
+++ b/SOL011/NSInstanceUsageNotification-API/Subscriptions.robot
@@ -21,6 +21,7 @@ POST Create a new subscription
     Check HTTP Response Header Contains    Location
     Check HTTP Response Body Json Schema Is    subscription
     Check HTTP Response Header Contains Resource URI
+    Check Postcondition Subscription Is Set 
 
 POST Create a new Subscription - DUPLICATION
     [Documentation]    Test ID: 9.3.4.1.2
@@ -36,6 +37,7 @@ POST Create a new Subscription - DUPLICATION
     Check HTTP Response Status Code Is    201
     Check HTTP Response Header Contains    Location
     Check HTTP Response Body Json Schema Is    subscription 
+    Check Postcondition Subscription Resource Returned in Location Header Is Available
     
 POST Create a new Subscription - NO-DUPLICATION
     [Documentation]    Test ID: 9.3.4.1.3
@@ -50,6 +52,7 @@ POST Create a new Subscription - NO-DUPLICATION
     Check Subscription Existence
     Check HTTP Response Status Code Is    303
     Check HTTP Response Header Contains    Location
+    Check Postcondition Subscription Is Set
     
 GET Subscriptions
     [Documentation]    Test ID: 9.3.4.1.4
@@ -203,6 +206,7 @@ DELETE subscriptions - Method not implemented
     ...    Post-Conditions: Subscriptions are not deleted
     DELETE subscriptions
     Check HTTP Response Status Code Is    405
+    Check Postcondition Subscriptions Exist
     
 GET subscriptions with "exclude_default" and "fields" attribute selector
     [Documentation]    Test ID: 9.3.4.1.16
@@ -211,8 +215,8 @@ GET subscriptions with "exclude_default" and "fields" attribute selector
     ...    Pre-conditions: 
     ...    Reference: Clause 8.5.3.3.2 - ETSI GS NFV-SOL 011 [6] v3.3.1
     ...    Config ID: Config_prod_NFVO
-    ...    Applicability:  
-    ...    Post-Conditions: 
+    ...    Applicability: none 
+    ...    Post-Conditions: none
     Get subscriptions with exclude_default and fields attribute selector
     Check HTTP Response Status Code Is    200
     Check HTTP Response Body Json Schema Is   subscriptions  
\ No newline at end of file
-- 
GitLab