From 1d5f607bc633d74bf533f8523b689edd909e9761 Mon Sep 17 00:00:00 2001
From: Abbas Ahmad <abbas.ahmad@eglobalmark.com>
Date: Fri, 3 May 2019 15:23:18 +0200
Subject: [PATCH] SOL003 updates on VRQAN-Api

---
 .../IndividualSubscription.robot              | 101 +++++++++---------
 .../VRQANOperationKeywords.robot              |  80 ++++++++++++++
 .../environment/variables.txt                 |  57 +++++-----
 3 files changed, 161 insertions(+), 77 deletions(-)
 create mode 100644 SOL003/VirtualisedResourcesQuotaAvailableNotification-API/VRQANOperationKeywords.robot

diff --git a/SOL003/VirtualisedResourcesQuotaAvailableNotification-API/IndividualSubscription.robot b/SOL003/VirtualisedResourcesQuotaAvailableNotification-API/IndividualSubscription.robot
index 63a19e9b..34da7e49 100644
--- a/SOL003/VirtualisedResourcesQuotaAvailableNotification-API/IndividualSubscription.robot
+++ b/SOL003/VirtualisedResourcesQuotaAvailableNotification-API/IndividualSubscription.robot
@@ -1,69 +1,72 @@
 *** Settings ***
-Resource    environment/variables.txt 
+Resource    environment/variables.txt
+Resource    VRQANOperationKeywords.robot 
 Library    OperatingSystem
 Library    JSONLibrary
 Library    JSONSchemaLibrary    schemas/
 Library    REST    ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}
 Documentation    This resource represents an individual subscription. The client can use this resource to read and to terminate a
 ...    subscription to notifications related to the availability of the virtualised resources quotas.
-Suite Setup    Check resource existance
+Suite Setup    Check Individual Subscription existance
 
 *** Test Cases ***
 Post Individual Subscription - Method not implemented
-    log    Trying to perform a POST. This method should not be implemented
-    Set Headers  {"Accept":"${ACCEPT}"}
-    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
-    Post    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}  
-    Log    Validate Status code
-    Integer    response status    405
+    [Documentation]    Test ID: 7.3.7.1
+    ...    Test title: Post Individual Subscription - Method not implemented
+    ...    Test objective: The objective is to test that POST method is not allowed to create a new individual subscription instance on NFV 
+    ...    Pre-conditions: A NFV instance is instantiated
+    ...    Reference:  section 11.4.3.3.1 - SOL003 v2.4.1
+    ...    Config ID: Config_prod_VE
+    ...    Applicability: none
+    ...    Post-Conditions: none
+    Do Post Individual Subscription
+    Check HTTP Response Status Code Is    405
 
 Get Information about an individual subscription
-    [Documentation]    Test ID: 11.4.3.1
-    ...    Test title: Retrieve the resource quota subscriptions
-    ...    Test objective: The objective is to read an individual subscription for resource quota subscribed by the client
+    [Documentation]    Test ID: 7.3.7.2
+    ...    Test title: Get Information about an individual subscription
+    ...    Test objective: The objective is to read an individual subscription subscribed by the client
     ...    Pre-conditions: The subscription with the given id exists
-    ...    Reference: section 11.4.3 - SOL003 v2.4.1
+    ...    Reference: section 11.4.3.3.2 - SOL003 v2.4.1
     ...    Config ID: Config_prod_VNFM
-    ...    Applicability:  
-    ...    Post-Conditions: 
-    log    Trying to get information about an individual subscription
-    Set Headers    {"Accept":"${ACCEPT}"}  
-    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
-    Get    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}
-    Log    Validate Status code
-    Integer    response status    200
-    ${result}=    Output    response body
-    Validate Json    VrQuotaAvailSubscription.schema.json    ${result}
-    Log    Validation OK
+    ...    Applicability: none 
+    ...    Post-Conditions: none
+    Do Get individual subscription
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Body Json Schema Is    VrQuotaAvailSubscription.schema.json
 
 PUT an individual subscription - Method not implemented
-    log    Trying to perform a PUT. This method should not be implemented
-    Set Headers  {"Accept":"${ACCEPT}"}
-    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
-    Put    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}    
-    Log    Validate Status code
-    Integer    response status    405
+    [Documentation]    Test ID: 7.3.7.3
+    ...    Test title: Put Individual Subscription - Method not implemented
+    ...    Test objective: The objective is to test that PUT method is not allowed to update a existing individual subscription instance on NFV 
+    ...    Pre-conditions: A NFV instance is instantiated
+    ...    Reference:  section 11.4.3.3.3 - SOL003 v2.4.1
+    ...    Config ID: Config_prod_VE
+    ...    Applicability: none
+    ...    Post-Conditions: none
+    Do Put Individual Subscription
+    Check HTTP Response Status Code Is    405
 
 PATCH an individual subscription - Method not implemented
-    log    Trying to perform a PATCH. This method should not be implemented
-    Set Headers  {"Accept":"${ACCEPT}"}  
-    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
-    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
-    Patch    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}    
-    Log    Validate Status code
-    Integer    response status    405
+    [Documentation]    Test ID: 7.3.7.4
+    ...    Test title: Patch Individual Subscription - Method not implemented
+    ...    Test objective: The objective is to test that PATCH method is not allowed to modify a existing individual subscription instance on NFV 
+    ...    Pre-conditions: A NFV instance is instantiated
+    ...    Reference:  section 11.4.3.3.4 - SOL003 v2.4.1
+    ...    Config ID: Config_prod_VE
+    ...    Applicability: none
+    ...    Post-Conditions: none
+    Do Patch Individual Subscription
+    Check HTTP Response Status Code Is    405
     
 DELETE an individual subscription
-    log    Try to delete an individual subscription
-    Set Headers  {"Accept":"${ACCEPT}"}  
-    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
-    Delete    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}    
-    Log    Validate Status code
-    Integer    response status    204
-
-*** Keywords ***
-Check resource existance
-    Set Headers    {"Accept":"${ACCEPT}"}
-    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
-    Get    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId} 
-    Integer    response status    200
\ No newline at end of file
+        [Documentation]    Test ID: 7.3.7.5
+    ...    Test title: Delete an Individual Subscription
+    ...    Test objective: The objective is to test that Delete method is allowed to remove a existing individual subscription instance on NFV 
+    ...    Pre-conditions: The subscription with the given id exists
+    ...    Reference:  section 11.4.3.3.5 - SOL003 v2.4.1
+    ...    Config ID: Config_prod_VE
+    ...    Applicability: none
+    ...    Post-Conditions: none
+    Do Delete an individual subscription 
+    Check HTTP Response Status Code Is    204
\ No newline at end of file
diff --git a/SOL003/VirtualisedResourcesQuotaAvailableNotification-API/VRQANOperationKeywords.robot b/SOL003/VirtualisedResourcesQuotaAvailableNotification-API/VRQANOperationKeywords.robot
new file mode 100644
index 00000000..2080e17e
--- /dev/null
+++ b/SOL003/VirtualisedResourcesQuotaAvailableNotification-API/VRQANOperationKeywords.robot
@@ -0,0 +1,80 @@
+*** Settings ***
+Resource    environment/variables.txt
+Library    REST     ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}
+Library    JSONLibrary
+Library    JSONSchemaLibrary    schemas/
+Library    OperatingSystem
+#Suite Teardown    Terminate All Processes    kill=true
+
+Library    Process
+
+*** Keywords ***
+Check Individual Subscription existance
+    Set Headers    {"Accept":"${ACCEPT}"}
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
+    Get    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId} 
+    Integer    response status    200
+
+Check HTTP Response Status Code Is
+    [Arguments]    ${expected_status}
+    Log    Validate Status code    
+    Should Be Equal    ${response[0]['status']}    ${expected_status}
+    Log    Status code validated 
+    
+Check HTTP Response Header Contains
+    [Arguments]    ${HEADER_TOCHECK}
+    Should Contain     ${response[0]['headers']}    ${HEADER_TOCHECK}
+    Log    Header is present    
+    
+Check HTTP Response Body Json Schema Is
+    [Arguments]    ${schema}
+    Validate Json    ${schema}    ${response[0]['body']}
+    Log    Json Schema Validation OK
+    
+Check HTTP Response Header ContentType is 
+    [Arguments]    ${expected_contentType}
+    Log    Validate content type
+    Should Be Equal    ${response[0]['headers']['Content-Type']}    ${expected_contentType}
+    Log    Content Type validated 
+
+Do Post Individual Subscription
+    log    Trying to perform a POST. This method should not be implemented
+    Set Headers  {"Accept":"${ACCEPT}"}
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
+    Post    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}
+    ${outputResponse}=    Output    response 
+    Set Global Variable    @{response}    ${outputResponse}
+    
+Do Put Individual Subscription
+    log    Trying to perform a PUT. This method should not be implemented
+    Set Headers  {"Accept":"${ACCEPT}"}
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
+    Put    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}
+    ${outputResponse}=    Output    response 
+    Set Global Variable    @{response}    ${outputResponse}
+    
+Do Patch Individual Subscription
+    log    Trying to perform a Patch. This method should not be implemented
+    Set Headers  {"Accept":"${ACCEPT}"}
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
+    Patch    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}
+    ${outputResponse}=    Output    response 
+    Set Global Variable    @{response}    ${outputResponse}
+    
+Do Get individual subscription
+    log    Trying to get information about an individual subscription
+    Set Headers    {"Accept":"${ACCEPT}"}  
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
+    Get    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}
+    ${outputResponse}=    Output    response 
+    Set Global Variable    @{response}    ${outputResponse}
+      
+Do Delete an individual subscription
+    log    Try to delete an individual subscription
+    Set Headers  {"Accept":"${ACCEPT}"}  
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
+    Delete    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}   
+    ${outputResponse}=    Output    response 
+    Set Global Variable    @{response}    ${outputResponse}   
+    
+     
\ No newline at end of file
diff --git a/SOL003/VirtualisedResourcesQuotaAvailableNotification-API/environment/variables.txt b/SOL003/VirtualisedResourcesQuotaAvailableNotification-API/environment/variables.txt
index 37fd830e..9b62468a 100644
--- a/SOL003/VirtualisedResourcesQuotaAvailableNotification-API/environment/variables.txt
+++ b/SOL003/VirtualisedResourcesQuotaAvailableNotification-API/environment/variables.txt
@@ -1,28 +1,29 @@
-*** Variables ***
-${NFVO_HOST}      localhost    # Hostname of the NFVO
-${NFVO_PORT}      8081    # Listening port of the NFVO
-${NFVO_SCHEMA}    https
-${AUTHORIZATION}    Bearer    QWxhZGRpbjpvcGVuIHNlc2FtZQ==
-${CONTENT_TYPE}    application/json
-${AUTH_USAGE}     1
-${ACCEPT}         application/json
-${NFVO_DUPLICATION}    0
-${subscriptionId}    6fc3539c-e602-4afa-8e13-962fb5a7d81f
-
-
-${sub_filter}    filter
-${sub_filter_invalid}    filter_invalid
-
-${callback_endpoint}    /notification
-${callback_port}    9091
-${callback_uri}     http://localhost
-${sleep_interval}    20s
-
-
-${apiRoot}        /
-${apiName}        vrqan
-${apiVersion}     v1
-
-${VrQuotaAvailNotification}    {}
-${MOCK_SERVER_JAR}    ../../../bin/mockserver-netty-5.5.0-jar-with-dependencies.jar
-
+*** Variables ***
+${NFVO_HOST}      localhost    # Hostname of the NFVO
+${NFVO_PORT}      8081    # Listening port of the NFVO
+${NFVO_SCHEMA}    https
+${AUTHORIZATION}    Bearer    QWxhZGRpbjpvcGVuIHNlc2FtZQ==
+${CONTENT_TYPE}    application/json
+${AUTH_USAGE}     1
+${ACCEPT}         application/json
+${NFVO_DUPLICATION}    0
+${subscriptionId}    6fc3539c-e602-4afa-8e13-962fb5a7d81f
+
+
+${sub_filter}    filter
+${sub_filter_invalid}    filter_invalid
+
+${callback_endpoint}    /notification
+${callback_port}    9091
+${callback_uri}     http://localhost
+${sleep_interval}    20s
+
+
+${apiRoot}        /
+${apiName}        vrqan
+${apiVersion}     v1
+
+${VrQuotaAvailNotification}    {}
+${MOCK_SERVER_JAR}    ../../../bin/mockserver-netty-5.5.0-jar-with-dependencies.jar
+
+${response}    {}
\ No newline at end of file
-- 
GitLab