aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/tools/build/scripts/action_library_client/test
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
committerMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
commitf5f13c4f6b6fe3b4d98e349dfd7db59339803436 (patch)
tree72caffc93fab394ffa3b761505775331f1c559b9 /openecomp-be/tools/build/scripts/action_library_client/test
parent451a3400b76511393c62a444f588a4ed15f4a549 (diff)
push addional code
Change-Id: Ia427bb3460cda3a896f8faced2de69eaf3807b74 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'openecomp-be/tools/build/scripts/action_library_client/test')
-rw-r--r--openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Backout.json45
-rw-r--r--openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Copy_image.json45
-rw-r--r--openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Healthcheck.json45
-rw-r--r--openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Reboot.json45
-rw-r--r--openecomp-be/tools/build/scripts/action_library_client/test/seq.txt1
-rw-r--r--openecomp-be/tools/build/scripts/action_library_client/test/test_action_library_client.py154
-rw-r--r--openecomp-be/tools/build/scripts/action_library_client/test/test_action_library_client_integration.py329
7 files changed, 664 insertions, 0 deletions
diff --git a/openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Backout.json b/openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Backout.json
new file mode 100644
index 0000000000..12b7b4dd2c
--- /dev/null
+++ b/openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Backout.json
@@ -0,0 +1,45 @@
+{
+ "name": "Backout",
+ "displayName": "Backout",
+ "description": "MCAP Backout",
+ "vendorList": ["BROCADE"],
+ "categoryList": ["Upgrade"],
+ "endpointURI": "engine-rest/process-definition/key/Backout/start",
+ "supportedModels": [{
+ "versionID": "AA56B177-9383-4934-8543-0F91A7A04971",
+ "versionInvariantUUID": "CC87B177-9383-4934-8543-0F91A7A07193",
+ "name": "vCE",
+ "version": "2.1",
+ "category": "cpe"
+ }],
+ "supportedComponents": [{
+ "ID": "BB47B177-9383-4934-8543-0F91A7A06448",
+ "componentName": "appc"
+ }],
+ "inputParameters": [{
+ "name": "VNF_NAME",
+ "description": "VNF name",
+ "type": "STRING",
+ "max-length": "50",
+ "optional": true,
+ "allowed_values": ["string1", "string2"]
+ }],
+ "outputParameters": [{
+ "name": "STATUS",
+ "defaultValue": "Default Value",
+ "type": "STRING",
+ "description": "The status of execution"
+ }],
+ "operationalData": {
+ "outageDuration": "0",
+ "approxDuration": "5",
+ "staticFields": {},
+ "updatableFields": {}
+ },
+ "serverList": [{
+ "name": "appcserver",
+ "hostName": "cm-server1.client.com",
+ "port": "666"
+ }],
+ "updatedBy": "AUTHusername"
+}
diff --git a/openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Copy_image.json b/openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Copy_image.json
new file mode 100644
index 0000000000..06da2ae48f
--- /dev/null
+++ b/openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Copy_image.json
@@ -0,0 +1,45 @@
+{
+ "name": "Copy_image",
+ "displayName": "Copy_image",
+ "description": "MCAP Copy Image",
+ "vendorList": ["BROCADE"],
+ "categoryList": ["Upgrade"],
+ "endpointURI": "engine-rest/process-definition/key/Copy_image/start",
+ "supportedModels": [{
+ "versionID": "AA56B177-9383-4934-8543-0F91A7A04971",
+ "versionInvariantUUID": "CC87B177-9383-4934-8543-0F91A7A07193",
+ "name": "vCE",
+ "version": "2.1",
+ "category": "cpe"
+ }],
+ "supportedComponents": [{
+ "ID": "BB47B177-9383-4934-8543-0F91A7A06448",
+ "componentName": "appc"
+ }],
+ "inputParameters": [{
+ "name": "VNF_NAME",
+ "description": "VNF name",
+ "type": "STRING",
+ "max-length": "50",
+ "optional": true,
+ "allowed_values": ["string1", "string2"]
+ }],
+ "outputParameters": [{
+ "name": "STATUS",
+ "defaultValue": "Default Value",
+ "type": "STRING",
+ "description": "The status of execution"
+ }],
+ "operationalData": {
+ "outageDuration": "0",
+ "approxDuration": "5",
+ "staticFields": {},
+ "updatableFields": {}
+ },
+ "serverList": [{
+ "name": "appcserver",
+ "hostName": "cm-server1.client.com",
+ "port": "666"
+ }],
+ "updatedBy": "AUTHusername"
+}
diff --git a/openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Healthcheck.json b/openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Healthcheck.json
new file mode 100644
index 0000000000..b1be8f77df
--- /dev/null
+++ b/openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Healthcheck.json
@@ -0,0 +1,45 @@
+{
+ "name": "Healthcheck",
+ "displayName": "Healthcheck",
+ "description": "MCAP Healthcheck",
+ "vendorList": ["BROCADE"],
+ "categoryList": ["Upgrade"],
+ "endpointURI": "engine-rest/process-definition/key/Healthcheck/start",
+ "supportedModels": [{
+ "versionID": "AA56B177-9383-4934-8543-0F91A7A04971",
+ "versionInvariantUUID": "CC87B177-9383-4934-8543-0F91A7A07193",
+ "name": "vCE",
+ "version": "2.1",
+ "category": "cpe"
+ }],
+ "supportedComponents": [{
+ "ID": "BB47B177-9383-4934-8543-0F91A7A06448",
+ "componentName": "appc"
+ }],
+ "inputParameters": [{
+ "name": "VNF_NAME",
+ "description": "VNF name",
+ "type": "STRING",
+ "max-length": "50",
+ "optional": true,
+ "allowed_values": ["string1", "string2"]
+ }],
+ "outputParameters": [{
+ "name": "STATUS",
+ "defaultValue": "Default Value",
+ "type": "STRING",
+ "description": "The status of execution"
+ }],
+ "operationalData": {
+ "outageDuration": "0",
+ "approxDuration": "5",
+ "staticFields": {},
+ "updatableFields": {}
+ },
+ "serverList": [{
+ "name": "appcserver",
+ "hostName": "cm-server1.client.com",
+ "port": "666"
+ }],
+ "updatedBy": "AUTHusername"
+}
diff --git a/openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Reboot.json b/openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Reboot.json
new file mode 100644
index 0000000000..72cbb659e3
--- /dev/null
+++ b/openecomp-be/tools/build/scripts/action_library_client/test/scenarios/Reboot.json
@@ -0,0 +1,45 @@
+{
+ "name": "Reboot",
+ "displayName": "Reboot",
+ "description": "MCAP Reboot",
+ "vendorList": ["BROCADE"],
+ "categoryList": ["Upgrade"],
+ "endpointURI": "engine-rest/process-definition/key/Reboot/start",
+ "supportedModels": [{
+ "versionID": "AA56B177-9383-4934-8543-0F91A7A04971",
+ "versionInvariantUUID": "CC87B177-9383-4934-8543-0F91A7A07193",
+ "name": "vCE",
+ "version": "2.1",
+ "category": "cpe"
+ }],
+ "supportedComponents": [{
+ "ID": "BB47B177-9383-4934-8543-0F91A7A06448",
+ "componentName": "appc"
+ }],
+ "inputParameters": [{
+ "name": "VNF_NAME",
+ "description": "VNF name",
+ "type": "STRING",
+ "max-length": "50",
+ "optional": true,
+ "allowed_values": ["string1", "string2"]
+ }],
+ "outputParameters": [{
+ "name": "STATUS",
+ "defaultValue": "Default Value",
+ "type": "STRING",
+ "description": "The status of execution"
+ }],
+ "operationalData": {
+ "outageDuration": "0",
+ "approxDuration": "5",
+ "staticFields": {},
+ "updatableFields": {}
+ },
+ "serverList": [{
+ "name": "appcserver",
+ "hostName": "cm-server1.client.com",
+ "port": "666"
+ }],
+ "updatedBy": "AUTHusername"
+}
diff --git a/openecomp-be/tools/build/scripts/action_library_client/test/seq.txt b/openecomp-be/tools/build/scripts/action_library_client/test/seq.txt
new file mode 100644
index 0000000000..b18fcc5ba2
--- /dev/null
+++ b/openecomp-be/tools/build/scripts/action_library_client/test/seq.txt
@@ -0,0 +1 @@
+535 \ No newline at end of file
diff --git a/openecomp-be/tools/build/scripts/action_library_client/test/test_action_library_client.py b/openecomp-be/tools/build/scripts/action_library_client/test/test_action_library_client.py
new file mode 100644
index 0000000000..dc1161c184
--- /dev/null
+++ b/openecomp-be/tools/build/scripts/action_library_client/test/test_action_library_client.py
@@ -0,0 +1,154 @@
+import unittest
+import os
+import tempfile
+import ConfigParser
+import action_library_client as ALC
+
+
+class D(dict):
+
+ def __init__(self, *args, **kwargs):
+ super(D, self).__init__(*args, **kwargs)
+ self.__dict__ = self
+
+
+class UnitTest(unittest.TestCase):
+
+ def __write_config_file(self, map):
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as tmp:
+ config = ConfigParser.ConfigParser()
+ config.add_section("action_library_client")
+ for k, v in map.items():
+ section = config.set("action_library_client", k, v)
+ config.write(tmp)
+ tmp.flush()
+ return tmp.name
+
+ def test_argument_parser(self):
+ # nothing = ALC.ArgumentParser().parse_args([])
+ # self.assertEquals(nothing.help, None)
+ # self.assertEquals(nothing.version, None)
+ # self.assertEquals(nothing.verbose, None)
+ #
+ # help = ALC.ArgumentParser().parse_args(["--help"])
+ # self.assertEquals(help.help, True)
+
+ uuidx = ALC.ArgumentParser().parse_args(["--uuid", "abc"])
+ self.assertEquals(uuidx.uuid, "abc")
+
+
+ def test_settings_get(self):
+
+ os.environ["a"] = "aa"
+ os.environ["b"] = "WILL_BE_OVERRIDDEN"
+
+ section = dict()
+ section['ALC_HTTP_USER'] = "batman"
+ section['ECOMP_INSTANCE_ID'] = "acdc"
+ section['b'] = "bb"
+ filename = self.__write_config_file(section)
+
+ # with tempfile.NamedTemporaryFile(mode="w", delete=False) as tmp:
+ # config = configparser.ConfigParser()
+ # config.add_section("action_library_client")
+ # section = config["action_library_client"]
+ # config.write(tmp)
+ # tmp.flush()
+
+ settings = ALC.Settings(ALC.Runner.parse_args(["--config", filename]))
+ self.assertEquals("aa", settings.get("a"))
+ self.assertEquals("bb", settings.get("b"))
+ self.assertEquals("batman", settings.get("ALC_HTTP_USER"))
+ self.assertEquals("batman", settings.get(ALC.Constants.ENV_HTTP_USER))
+ self.assertEquals("ALC_ECOMP_INSTANCE_ID", settings.get("c", ALC.Constants.ENV_ECOMP_INSTANCE_ID))
+
+ os.remove(filename)
+
+ def test_parse_args(self):
+ c1 = ALC.Runner.parse_args(["--version"])
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as tmp:
+ config = ConfigParser.ConfigParser()
+ config.add_section("action_library_client")
+ config.set("action_library_client", "ALC_HTTP_USER", "batman")
+ config.write(tmp)
+ tmp.flush()
+ self.assertEquals(c1.version, True)
+
+ def test_get_http_insecure(self):
+ c = ALC.DryRunRESTClient(ALC.Runner.parse_args([]))
+ self.assertEquals(False, c.get_http_insecure())
+
+ def test_get_http_cafile(self):
+ c1 = ALC.DryRunRESTClient(ALC.Runner.parse_args([]))
+ self.assertEquals(False, c1.get_http_insecure())
+ self.assertIsNone(c1.get_http_cafile())
+
+ filename = self.__write_config_file({"ALC_HTTP_CAFILE": "/tmp/x"})
+ c2 = ALC.DryRunRESTClient(ALC.Runner.parse_args(["--config", filename]))
+ self.assertEquals(False, c2.get_http_insecure())
+ self.assertEquals("/tmp/x", c2.get_http_cafile())
+
+ def test_get_timeout_seconds(self):
+ args = ALC.Runner.parse_args(["--version"])
+ self.assertEquals(30, ALC.DryRunRESTClient(args).get_timeout_seconds())
+
+ def test_get_basic_credentials(self):
+ try:
+ saved_user = os.environ["ALC_HTTP_USER"]
+ saved_pass = os.environ["ALC_HTTP_PASS"]
+ except KeyError:
+ saved_user = ""
+ saved_pass = ""
+ try:
+ os.environ["ALC_HTTP_USER"] = "AUTH-DELETE"
+ os.environ["ALC_HTTP_PASS"] = "test"
+ c = ALC.DryRunRESTClient(ALC.Runner.parse_args([]))
+ c1 = c.get_basic_credentials()
+ self.assertEqual(c1, "QVVUSC1ERUxFVEU6dGVzdA==")
+ os.environ["ALC_HTTP_USER"] = "AUTH-DELETE"
+ os.environ["ALC_HTTP_PASS"] = "death"
+ c2 = c.get_basic_credentials()
+ self.assertNotEqual(c2, "QVVUSC1ERUxFVEU6dGVzdA==")
+ finally:
+ os.environ["ALC_HTTP_USER"] = saved_user
+ os.environ["ALC_HTTP_PASS"] = saved_pass
+
+ def test_get_rest_client(self):
+ uuid = ALC.IRESTClient.new_uuid()
+ c1 = ALC.Runner.get_rest_client(ALC.Runner.parse_args(["--dryrun"]))
+ self.assertTrue(isinstance(c1, ALC.DryRunRESTClient))
+ c2 = ALC.Runner.get_rest_client(ALC.Runner.parse_args(["--curl"]))
+ self.assertTrue(isinstance(c2, ALC.CURLRESTClient))
+ c3 = ALC.Runner.get_rest_client(ALC.Runner.parse_args(["--uuid", uuid]))
+ self.assertTrue(isinstance(c3, ALC.NativeRESTClient))
+
+ def test_get_logger(self):
+ logger = ALC.Runner.get_logger()
+ logger.info("idotlogger")
+
+ def test_new_uuid(self):
+ uuid = ALC.IRESTClient.new_uuid()
+ self.assertEqual(len(uuid), 36)
+
+ def test_make_service_url(self):
+ uuid = ALC.IRESTClient.new_uuid()
+
+ args1 = ALC.Runner.parse_args(["--url", "http://banana"])
+ client1 = ALC.DryRunRESTClient(args1)
+ self.assertEqual(client1.make_service_url(),
+ "http://banana/onboarding-api/workflow/v1.0/actions")
+
+ args2 = ALC.Runner.parse_args(["--url", "http://banana/"])
+ client2 = ALC.DryRunRESTClient(args2)
+ self.assertEqual(client2.make_service_url(),
+ "http://banana/onboarding-api/workflow/v1.0/actions")
+
+ args3 = ["--url", "http://banana/onboarding-api/workflow/v1.1/actions", "--uuid", uuid]
+ client3 = ALC.DryRunRESTClient(ALC.Runner.parse_args(args3))
+ self.assertEqual(client3.make_service_url(),
+ "http://banana/onboarding-api/workflow/v1.1/actions/{}".format(uuid))
+
+ def test_debug_curl_cmd(self):
+ cmd = ["curl", "--header", "banana", "http://something/somewhere"]
+ debug = ALC.CURLRESTClient.debug_curl_cmd(cmd)
+ self.assertEqual("curl --header \"banana\" \"http://something/somewhere\" ", debug) \ No newline at end of file
diff --git a/openecomp-be/tools/build/scripts/action_library_client/test/test_action_library_client_integration.py b/openecomp-be/tools/build/scripts/action_library_client/test/test_action_library_client_integration.py
new file mode 100644
index 0000000000..b6418e617e
--- /dev/null
+++ b/openecomp-be/tools/build/scripts/action_library_client/test/test_action_library_client_integration.py
@@ -0,0 +1,329 @@
+import sys
+import os
+import unittest
+import uuid
+import json
+import tempfile
+import action_library_client
+
+class IntegrationTest(unittest.TestCase):
+
+ HTTP = "http://10.147.97.199:8080"
+ HTTPS = "https://10.147.97.199:8443"
+
+ def setUp(self):
+ os.environ["ALC_HTTP_USER"] = "AUTH-DELETE"
+ os.environ["ALC_HTTP_PASS"] = "test"
+
+ def tearDown(self):
+ os.environ["ALC_HTTP_INSECURE"] = ""
+ os.environ["ALC_HTTP_USER"] = ""
+ os.environ["ALC_HTTP_PASS"] = ""
+
+ @staticmethod
+ def __prepare(testcase, name):
+ with open(testcase, 'r') as fin:
+ jsonk = json.loads(fin.read())
+ jsonk['name'] = name
+ with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp:
+ temp.write(json.dumps(jsonk))
+ temp.flush()
+ return temp.name
+
+ @staticmethod
+ def __get_sequence():
+ with open(r'./seq.txt', 'r+') as f:
+ value = int(f.read())
+ f.seek(0)
+ f.write(str(value + 1))
+ return value
+
+ def __print_separator(self):
+ logger = action_library_client.Runner.get_logger()
+ logger.info("==================================================")
+
+ def __list(self, stdargs):
+ logger = action_library_client.Runner.get_logger()
+ list_response = action_library_client.execute(["--list"] + stdargs)
+ logger.info("--list response: {}".format(list_response))
+ self.assertTrue(isinstance(list_response, dict))
+ return list_response
+
+ def __get_action(self, list_response, ai_uuid):
+ for action in list_response['actionList']:
+ if action['actionInvariantUUID'] == ai_uuid:
+ return action
+
+ def __create_delete(self, extraargs):
+
+ logger = action_library_client.Runner.get_logger()
+
+ # Setup.
+
+ seq = IntegrationTest.__get_sequence()
+ name = "Backout{}".format(seq)
+ path = IntegrationTest.__prepare("scenarios/Backout.json", name)
+ stdargs = ["--url", self.HTTP, "--verbose"]
+ if extraargs:
+ stdargs.extend(extraargs)
+
+ # List actions.
+
+ self.__print_separator()
+ list_response1 = self.__list(stdargs)
+ self.assertTrue(isinstance(list_response1, dict))
+
+ # CREATE action.
+
+ self.__print_separator()
+ create_response = action_library_client.execute(["--create", "--in", path] + stdargs)
+ logger.info("--create response: {}".format(create_response))
+ self.assertTrue(isinstance(create_response, dict))
+ ai_uuid = create_response['actionInvariantUUID']
+ self.assertTrue(ai_uuid)
+ self.assertEquals(create_response['status'], 'Locked')
+ self.assertEquals(create_response['version'], '0.1')
+
+ # UPDATE action #1.
+
+ self.__print_separator()
+ update_response1 = action_library_client.execute(["--update", "--in", path, "--uuid", ai_uuid] + stdargs)
+ logger.info("--update response: {}".format(update_response1))
+ self.assertTrue(isinstance(update_response1, dict))
+
+ # UPDATE action #2.
+
+ self.__print_separator()
+ update_response2 = action_library_client.execute(["--update", "--in", path, "--uuid", ai_uuid] + stdargs)
+ logger.info("--update response: {}".format(update_response2))
+ self.assertTrue(isinstance(update_response2, dict))
+
+ # CHECKOUT action (usage unknown).
+
+ self.__print_separator()
+ try:
+ action_library_client.execute(["--checkout", "--uuid", ai_uuid] + stdargs)
+ self.fail("--checkout should fail")
+ except Exception as err:
+ print(err)
+
+ # CHECKIN action.
+
+ self.__print_separator()
+ checkin_response = action_library_client.execute(["--checkin", "--in", path, "--uuid", ai_uuid] + stdargs)
+ logger.info("--checkin response: {}".format(checkin_response))
+ self.assertTrue(isinstance(checkin_response, dict))
+ self.assertEquals(checkin_response['status'], 'Available')
+ self.assertEquals(checkin_response['version'], '0.1')
+
+ # SUBMIT action.
+
+ self.__print_separator()
+ submit_response = action_library_client.execute(["--submit", "--in", path, "--uuid", ai_uuid] + stdargs)
+ logger.info("--submit response: {}".format(submit_response))
+ self.assertTrue(isinstance(submit_response, dict))
+ self.assertEquals(submit_response['status'], 'Final')
+ self.assertEquals(submit_response['version'], '1.0')
+
+ # LIST again
+
+ self.__print_separator()
+ list_response2 = self.__list(stdargs)
+ action_found2 = self.__get_action(list_response2, ai_uuid)
+ self.assertTrue(action_found2)
+
+ # DELETE action.
+
+ self.__print_separator()
+ delete_response = action_library_client.execute(["--delete", "--uuid", ai_uuid] + stdargs)
+ logger.info("--delete response: {}".format(delete_response))
+ self.assertEqual(delete_response, action_library_client.ResponseCodes.OK)
+
+ # LIST yet again
+
+ self.__print_separator()
+ list_response3 = self.__list(stdargs)
+ action_found3 = self.__get_action(list_response3, ai_uuid)
+ self.assertFalse(action_found3)
+
+ def __create_undo(self, extraargs):
+
+ # Setup
+
+ logger = action_library_client.Runner.get_logger()
+ seq = IntegrationTest.__get_sequence()
+ name = "Backout{}".format(seq)
+ path = IntegrationTest.__prepare("scenarios/Backout.json", name)
+ stdargs = ["--url", self.HTTP, "--verbose"]
+
+ # CREATE action.
+
+ self.__print_separator()
+ create_response = action_library_client.execute(["--create", "--in", path] + stdargs + extraargs)
+ logger.info("--create response: {}".format(create_response))
+ self.assertTrue(isinstance(create_response, dict))
+ ai_uuid = create_response['actionInvariantUUID']
+ self.assertTrue(ai_uuid)
+ self.assertEquals(create_response['status'], 'Locked')
+ self.assertEquals(create_response['version'], '0.1')
+
+ # UNDOCHECKOUT action
+
+ self.__print_separator()
+ undocheckout_response = action_library_client.execute(["--undocheckout", "--uuid", ai_uuid] + stdargs + extraargs)
+ self.assertTrue(isinstance(undocheckout_response, dict))
+
+ def __create_list(self, extraargs):
+ # Setup
+
+ logger = action_library_client.Runner.get_logger()
+ seq = IntegrationTest.__get_sequence()
+ name = "Backout{}".format(seq)
+ path = IntegrationTest.__prepare("scenarios/Backout.json", name)
+ stdargs = ["--url", self.HTTP, "--verbose"]
+
+ # CREATE action.
+
+ self.__print_separator()
+ create_response = action_library_client.execute(["--create", "--in", path] + stdargs + extraargs)
+ logger.info("--create response: {}".format(create_response))
+ self.assertTrue(isinstance(create_response, dict))
+ ai_uuid = create_response['actionInvariantUUID']
+ self.assertTrue(ai_uuid)
+ self.assertEquals(create_response['status'], 'Locked')
+ self.assertEquals(create_response['version'], '0.1')
+
+ # CHECKIN action.
+
+ self.__print_separator()
+ checkin_response = action_library_client.execute(["--checkin", "--in", path, "--uuid", ai_uuid] +
+ stdargs + extraargs)
+ logger.info("--checkin response: {}".format(checkin_response))
+ self.assertTrue(isinstance(checkin_response, dict))
+ self.assertEquals(checkin_response['status'], 'Available')
+ self.assertEquals(checkin_response['version'], '0.1')
+
+ try:
+ # LIST.
+
+ self.__print_separator()
+ list_response1 = self.__list(stdargs + extraargs)
+ action_found1 = self.__get_action(list_response1, ai_uuid)
+ self.assertTrue(action_found1)
+
+ # LIST with UUID.
+
+ self.__print_separator()
+ list_response2 = self.__list(stdargs + extraargs + ["--uuid", ai_uuid])
+ self.assertFalse(hasattr(list_response2, 'actionList'))
+ self.assertEquals(len(list_response2['versions']), 1)
+
+ # LIST with bad UUID.
+
+ self.__print_separator()
+ list_response3 = action_library_client.execute(["--list"] + stdargs + extraargs +
+ ["--uuid", "where_the_wind_blows"])
+ if isinstance(list_response3, int):
+ self.assertEquals(action_library_client.ResponseCodes.HTTP_NOT_FOUND_ERROR, list_response3)
+ else:
+ self.assertEquals("ACT1045", list_response3["code"])
+
+ finally:
+
+ # DELETE action
+
+ self.__print_separator()
+ action_library_client.execute(["--delete", "--uuid", ai_uuid] + stdargs + extraargs)
+
+ def __http_secure(self, extraargs):
+ os.environ["ALC_HTTP_INSECURE"] = ""
+ try:
+ self.__list(["--url", self.HTTPS, "--verbose"] + extraargs)
+ if not (sys.version_info[0] == 2 and sys.version_info[1] == 6):
+ self.fail("Should fail (non-2.6) for TLS + secure")
+ except Exception:
+ pass
+
+ def __http_insecure(self, extraargs):
+ os.environ["ALC_HTTP_INSECURE"] = True
+ self.__list(["--url", self.HTTPS, "--verbose"] + extraargs)
+
+ def __no_credentials(self, extraargs):
+
+ args = ["--url", self.HTTP] + extraargs
+ self.__list(args)
+ print("OK")
+
+ os.environ["ALC_HTTP_USER"] = ""
+ os.environ["ALC_HTTP_PASS"] = ""
+ try:
+ action_library_client.execute(["--list"] + args)
+ self.fail("Should fail for missing credentials")
+ except Exception as e:
+ self.assertEquals("REST service credentials not found", e.message)
+
+ def __bad_credentials(self, extraargs):
+
+ args = ["--url", self.HTTP] + extraargs
+ self.__list(args)
+
+ os.environ["ALC_HTTP_USER"] = "wakey_wakey"
+ os.environ["ALC_HTTP_PASS"] = "rise_and_shine"
+ code = action_library_client.execute(["--list"] + args)
+ self.assertEquals(action_library_client.ResponseCodes.HTTP_FORBIDDEN_ERROR, code)
+
+ ################################################################################
+
+ def test_https_insecure_local_fail(self):
+ self.__http_secure([])
+
+ def test_https_insecure_remote_fail(self):
+ self.__http_secure(["--curl"])
+
+ def test_https_native(self):
+ self.__http_secure([])
+
+ def test_https_curl(self):
+ self.__http_secure(["--curl"])
+
+ def test_undo_checkout_native(self):
+ self.__create_undo([])
+
+ def test_undo_checkout_curl(self):
+ self.__create_undo(["--curl"])
+
+ def test_create_delete_native(self):
+ self.__create_delete([])
+
+ def test_create_delete_curl(self):
+ self.__create_delete(["--curl"])
+
+ def test_create_list_native(self):
+ self.__create_list([])
+
+ def test_create_list_curl(self):
+ self.__create_list(["--curl"])
+
+ def test_bad_credentials_native(self):
+ self.__bad_credentials([])
+
+ def test_bad_credentials_curl(self):
+ self.__bad_credentials(["--curl"])
+ #
+ def test_no_credentials_native(self):
+ self.__no_credentials([])
+
+ def test_no_credentials_curl(self):
+ self.__no_credentials(["--curl"])
+
+ def test_create_to_delete_dryrun(self):
+ ai_uuid = str(uuid.uuid4())
+ path = IntegrationTest.__prepare("scenarios/Backout.json", "Backout{}".format("001"))
+ stdargs = ["--url", self.HTTP, "--verbose", "--dryrun"]
+ action_library_client.execute(["--create", "--in", path] + stdargs)
+ action_library_client.execute(["--update", "--in", path, "--uuid", ai_uuid] + stdargs)
+ action_library_client.execute(["--checkout", "--uuid", ai_uuid] + stdargs)
+ action_library_client.execute(["--undocheckout", "--uuid", ai_uuid] + stdargs)
+ action_library_client.execute(["--checkin", "--uuid", ai_uuid] + stdargs)
+ action_library_client.execute(["--submit", "--uuid", ai_uuid] + stdargs)
+ action_library_client.execute(["--list"] + stdargs)