Enhance vid CSIT tests, added for scaleout

Issue-ID: VID-323
Change-Id: I31ad377ee766eaf66c848ad802c33e21ea1dfe76
Signed-off-by: Sandra Koblosz <sandra.koblosz@nokia.com>
diff --git a/tests/vid/https-connection/__init__.robot b/tests/vid/https-connection/__init__.robot
index e69de29..dcb082f 100644
--- a/tests/vid/https-connection/__init__.robot
+++ b/tests/vid/https-connection/__init__.robot
@@ -0,0 +1,2 @@
+*** Settings ***
+Documentation    VID - Checking connection to other component using HTTPS
diff --git a/tests/vid/https-connection/keywords.py b/tests/vid/https-connection/keywords.py
deleted file mode 100755
index 85bca10..0000000
--- a/tests/vid/https-connection/keywords.py
+++ /dev/null
@@ -1,125 +0,0 @@
-import ast
-
-import requests
-from assertpy import assert_that
-from robot.api import logger
-from robot.api.deco import keyword
-
-JSESSIONID_COOKIE = "JSESSIONID"
-
-_vid_to_so_request_details = {
-    "requestDetails": {
-        "cloudConfiguration": {
-            "lcpCloudRegionId": "RegionOne",
-            "tenantId": "982c540f6e69488eb6be5664255e00c0"
-        },
-        "modelInfo": {
-            "modelInvariantId": "41b3c314-dfab-4501-9c5e-1c9fe5d8e151",
-            "modelName": "SoWs1..base_ws..module-0",
-            "modelType": "vfModule",
-            "modelVersion": "1",
-            "modelVersionId": "7ea96ae9-9eac-4eaa-882e-077478a6c44a"
-        },
-        "relatedInstanceList": [{
-            "relatedInstance": {
-                "instanceId": "0d8a98d8-d7ca-4c26-b7ab-81d3729e3b6c",
-                "modelInfo": {
-                    "modelInvariantId": "a4413616-cf96-4615-a94e-0dc5a6a65430",
-                    "modelName": "SC_WS_SW_2",
-                    "modelType": "service",
-                    "modelVersion": "3.0",
-                    "modelVersionId": "0fdaaf44-3c6c-4d81-9c57-b2ce7224dbb9"
-                }
-            }
-        },
-            {
-                "relatedInstance": {
-                    "instanceId": "61c19619-2714-46f8-90c9-39734e4f545f",
-                    "modelInfo": {
-                        "modelCustomizationName": "SO_WS_1 0",
-                        "modelInvariantId": "3b2c9dcb-6ef8-4c3c-8d5b-43d5776f7110",
-                        "modelName": "SO_WS_1",
-                        "modelType": "vnf",
-                        "modelVersion": "1.0",
-                        "modelVersionId": "0fdaaf44-3c6c-4d81-9c57-b2ce7224dbb9"
-                    }
-                }
-            }
-        ],
-        "requestInfo": {
-            "source": "VID",
-            "suppressRollback": False,
-            "requestorId": "az2016",
-            "instanceName": "SC_WS_VNF_1_2"
-        },
-        "requestParameters": {
-            "controllerType": "SDNC",
-            "userParams": []
-        }
-
-    }
-}
-
-_expected_so_response = {
-    "status": 202,
-    "entity": {
-        "requestReferences": {
-            "instanceId": "fffcbb6c-1983-42df-9ca8-89ae8b3a46c1",
-            "requestId": "b2197d7e-3a7d-410e-82ba-7b7e8191bc46"
-        }
-    }
-}
-
-
-def _extract_cookie_from_headers(headers):
-    for i in headers["Set-Cookie"].split(";"):
-        if JSESSIONID_COOKIE in i:
-            return i
-    raise RuntimeError("No cookie when logging in to VID")
-
-
-def _log_request(response):
-    logger.console(
-        "\n=========\n"
-        "Performing request to : {} \nBODY: {}\nHEADERS: {}"
-            .format(str(response.request.url), str(response.request.body), str(response.request.headers)))
-    logger.console(
-        "---------\n"
-        "Got response\n BODY: {} \n HEADERS: {}"
-        "\n=========\n".format(str(response.headers), str(response.content)))
-
-
-@keyword('Login To VID')
-def login_to_vid():
-    headers = {'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0',
-               'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
-               'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
-               'Accept-Encoding': 'gzip, deflate', 'Referer': 'http://localhost:8080/vid/login.htm',
-               'Content-Type': 'application/x-www-form-urlencoded',
-               'Content-Length': '36',
-               'Cookie': 'JSESSIONID=1B4AF817AA4BCB87C07BB5B49EFE8526',
-               'Connection': 'keep-alive',
-               'Upgrade-Insecure-Requests': '1'}
-    response = requests.post("https://localhost:8443/vid/login_external", data="loginId=demo&password=Kp8bJ4SXszM0WX",
-                             headers=headers, allow_redirects=False, verify=False)
-    logger.console("Performing login")
-    _log_request(response)
-    return _extract_cookie_from_headers(response.headers)
-
-
-@keyword('Send create VF module instance request to VID')
-def send_create_vfmodule_instance_request_to_vid(jsession_cookie):
-    response = requests.post(
-        "https://localhost:8443/vid/mso/mso_create_vfmodule_instance/0d8a98d8-d7ca-4c26-b7ab-81d3729e3b6c/vnfs/61c19619-2714-46f8-90c9-39734e4f545f ",
-        headers={"Cookie": jsession_cookie}, json=_vid_to_so_request_details, verify=False)
-    content = ast.literal_eval(response.content)
-    logger.console("Triggering VF module instance creation")
-    _log_request(response)
-    return content
-
-
-@keyword('Response should contain valid entity')
-def expect_response_from_so_was_correctly_propageted(content):
-    logger.console("\nActual entity" + str(content['entity']))
-    logger.console("Expected entity" + str(_expected_so_response))
-    assert_that(content['entity']).is_equal_to(_expected_so_response)
diff --git a/tests/vid/https-connection/test1.robot b/tests/vid/https-connection/test1.robot
index 2173757..a7f6c4b 100644
--- a/tests/vid/https-connection/test1.robot
+++ b/tests/vid/https-connection/test1.robot
@@ -1,16 +1,29 @@
 *** Settings ***
-Library     keywords.py
-Library     Collections
+Library       SeleniumLibrary
+Library 	  RequestsLibrary
+Library       OperatingSystem
+Library       json
+Resource      ../../common.robot
+Resource      ../resources/keywords/scaleout_vid_keywords.robot
+
 
 *** Variables ***
+${VID_TEST_ASSET_DIR}              %{WORKSPACE}/tests/vid/resources/simulators/test_data_assets
+${EXPECTED_SO_RESPONSES_FILEPATH}  ${VID_TEST_ASSET_DIR}/expected_so_responses.json
+${EXPECTED_SO_REQUESTS_FILEPATH}   ${VID_TEST_ASSET_DIR}/expected_so_requests.json
+${SO_SIMULATOR_BASE_URL}           http://${SO_SIMULATOR_IP}:8443
+${VID_HTTP_BASE_URL}               http://${VID_IP}:8080
+${VID_SCALEOUT_ENDPOINT}           vid/mso/mso_create_vfmodule_instance/0d8a98d8-d7ca-4c26-b7ab-81d3729e3b6c/vnfs/61c19619-2714-46f8-90c9-39734e4f545f
+${VALID_SCALEOUT_REQ_FILEPATH}     ${VID_TEST_ASSET_DIR}/vid_create_vfmodule_request.json
+${VALID_SCALEOUT_RESP_FILEPATH}    ${VID_TEST_ASSET_DIR}/so_action_response.json
 
 
 *** Test Cases ***
-Connection to SO is performed using HTTPS
-     ${cookies}=  Login To VID
-     ${response}=  Send create VF module instance request to VID  ${cookies}
-     Dictionary Should Contain Item  ${response}  status  200
-     Response should contain valid entity  ${response}
-
-
-*** Keywords ***
+Triggering create vfmodule operation in SO is performed using HTTPS
+    Setup Expected Data In SO Simulator  ${EXPECTED_SO_RESPONSES_FILEPATH}  ${SO_SIMULATOR_BASE_URL}  setResponse
+    ${jsessionIdCookie}=  Login to VID Internally  ${VID_HTTP_BASE_URL}/vid/login.htm  demo  Kp8bJ4SXszM0WX
+    Log to console  loginResponse:  ${jsessionIdCookie}
+    ${soExpectedJsonResp}=  json_from_file  ${VALID_SCALEOUT_RESP_FILEPATH}
+    ${soResponse}=  Send Post request from VID FE  ${VID_HTTP_BASE_URL}  ${VID_SCALEOUT_ENDPOINT}  ${VALID_SCALEOUT_REQ_FILEPATH}  ${VALID_SCALEOUT_RESP_FILEPATH}  ${jsessionIdCookie}
+    Dictionaries Should Be Equal  ${soExpectedJsonResp}  ${soResponse.json()['entity']}
+    [Teardown]    Close Browser
\ No newline at end of file