diff options
author | Yaron Yogev <yaronyogev@gmail.com> | 2017-07-27 09:02:54 +0300 |
---|---|---|
committer | Yaron Yogev <yaronyogev@gmail.com> | 2017-07-27 14:56:25 +0300 |
commit | 7e83d0876ddb84a45e130eeba28bc40ef53c074b (patch) | |
tree | 47d76239ae7658d87c66abd142df92709427e7dd /app/test/api/responders_test/test_data | |
parent | 378ecbd8947589b9cbb39013a0c2e2aa201e03bd (diff) |
Calipso initial release for OPNFV
Change-Id: I7210c244b0c10fa80bfa8c77cb86c9d6ddf8bc88
Signed-off-by: Yaron Yogev <yaronyogev@gmail.com>
Diffstat (limited to 'app/test/api/responders_test/test_data')
-rw-r--r-- | app/test/api/responders_test/test_data/__init__.py | 10 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/aggregates.py | 67 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/base.py | 179 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/clique_constraints.py | 74 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/clique_types.py | 170 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/cliques.py | 171 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/constants.py | 23 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/environment_configs.py | 221 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/inventory.py | 37 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/links.py | 90 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/messages.py | 108 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/monitoring_config_templates.py | 98 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/scans.py | 187 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/scheduled_scans.py | 138 | ||||
-rw-r--r-- | app/test/api/responders_test/test_data/tokens.py | 83 |
15 files changed, 1656 insertions, 0 deletions
diff --git a/app/test/api/responders_test/test_data/__init__.py b/app/test/api/responders_test/test_data/__init__.py new file mode 100644 index 0000000..1e85a2a --- /dev/null +++ b/app/test/api/responders_test/test_data/__init__.py @@ -0,0 +1,10 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### + diff --git a/app/test/api/responders_test/test_data/aggregates.py b/app/test/api/responders_test/test_data/aggregates.py new file mode 100644 index 0000000..52ce985 --- /dev/null +++ b/app/test/api/responders_test/test_data/aggregates.py @@ -0,0 +1,67 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +URL = "/aggregates" + +CONSTANT_TYPE = "constant" +ENV_TYPE = "environment" +MESSAGE_TYPE = "message" +UNKNOWN_TYPE = "unknown" + +CONSTANT_AGGREGATES = [ + {"name": "type_drivers", "total": 5}, + {"name": "environment_monitoring_types", "total": 1}, + {"name": "link_states", "total": 2} +] +ENVIRONMENT_AGGREGATES = [ + {'_id': 'otep', 'total': 3}, + {'_id': 'instance', 'total': 2}, + {'_id': 'network_agent', 'total': 6} +] +MESSAGE_ENV_AGGREGATES = [ + {'_id': 'Mirantis-Liberty-API', 'total': 15} +] +MESSAGE_LEVEL_AGGREGATES = [ + {'_id': 'info', 'total': 15} +] + +CONSTANT_AGGREGATES_RESPONSE = { + "type": "constant", + "aggregates": { + "names": { + "type_drivers": 5, + "environment_monitoring_types": 1, + "link_states": 2 + } + } + } + +ENVIRONMENT_AGGREGATES_RESPONSE = { + "aggregates": { + "object_types": { + "otep": 3, + "instance": 2, + "network_agent": 6 + } + }, + "env_name": "Mirantis-Liberty-API", + "type": "environment" +} + +MESSAGE_AGGREGATES_RESPONSE = { + "aggregates": { + "environments": { + "Mirantis-Liberty-API": 15 + }, + "levels": { + "info": 15 + } + }, + "type": "message" + } diff --git a/app/test/api/responders_test/test_data/base.py b/app/test/api/responders_test/test_data/base.py new file mode 100644 index 0000000..1e85800 --- /dev/null +++ b/app/test/api/responders_test/test_data/base.py @@ -0,0 +1,179 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +# HTTP status code +SUCCESSFUL_CODE = "200" +NOT_FOUND_CODE = "404" +CONFLICT_CODE = "409" +BAD_REQUEST_CODE = "400" +UNAUTHORIZED_CODE = "401" +CREATED_CODE = "201" + +ENV_NAME = "Mirantis-Liberty-API" +UNKNOWN_ENV = "Unkown-Environment" +NON_INT_PAGE = 1.4 +INT_PAGE = 1 +NON_INT_PAGESIZE = 2.4 +INT_PAGESIZE = 2 + +WRONG_LINK_TYPE = "instance-host" +CORRECT_LINK_TYPE= "instance-vnic" + +WRONG_LINK_STATE = "wrong" +CORRECT_LINK_STATE = "up" + +WRONG_SCAN_STATUS = "error" +CORRECT_SCAN_STATUS = "completed" + +WRONG_MONITORING_SIDE = "wrong-side" +CORRECT_MONITORING_SIDE = "client" + +WRONG_MESSAGE_SEVERITY = "wrong-severity" +CORRECT_MESSAGE_SEVERITY = "warn" + +WRONG_TYPE_DRIVER = "wrong_type" +CORRECT_TYPE_DRIVER = "local" + +WRONG_MECHANISM_DRIVER = "wrong-mechanism-dirver" +CORRECT_MECHANISM_DRIVER = "ovs" + +WRONG_LOG_LEVEL = "wrong-log-level" +CORRECT_LOG_LEVEL = "critical" + +WRONG_OBJECT_TYPE = "wrong-object-type" +CORRECT_OBJECT_TYPE = "vnic" + +WRONG_ENV_TYPE = "" +CORRECT_ENV_TYPE = "development" + +WRONG_DISTRIBUTION = "wrong-environment" +CORRECT_DISTRIBUTION = "Mirantis-6.0" + +WRONG_OBJECT_ID = "58a2406e6a283a8bee15d43" +CORRECT_OBJECT_ID = "58a2406e6a283a8bee15d43f" + +WRONG_FORMAT_TIME = "2017-01-25T23:34:333+TX0012" +CORRECT_FORMAT_TIME = "2017-01-25T14:28:32.400Z" + +NON_BOOL = "falses" +BOOL = False +NON_DICT_OBJ = "" + +# fake constants +CONSTANTS_BY_NAMES = { + "link_types": [ + "instance-vnic", + "otep-vconnector", + "otep-pnic", + "pnic-network", + "vedge-otep", + "vnic-vconnector", + "vconnector-pnic", + "vconnector-vedge", + "vnic-vedge", + "vedge-pnic", + "vservice-vnic" + ], + "link_states": [ + "up", + "down" + ], + "scan_statuses": [ + "draft", + "pending", + "running", + "completed", + "failed", + "aborted" + ], + "monitoring_sides": [ + "client", + "server" + ], + "messages_severity": [ + "panic", + "alert", + "crit", + "error", + "warn", + "notice", + "info", + "debug" + ], + "type_drivers": [ + "local", + "vlan", + "vxlan", + "gre", + "flat" + ], + "mechanism_drivers": [ + "ovs", + "vpp", + "LinuxBridge", + "Arista", + "Nexus" + ], + "log_levels": [ + "critical", + "error", + "warning", + "info", + "debug", + "notset" + ], + "object_types": [ + "vnic", + "vconnector", + "vedge", + "instance", + "vservice", + "pnic", + "network", + "port", + "otep", + "agent" + ], + "env_types": [ + "development", + "testing", + "staging", + "production" + ], + "distributions": [ + "Mirantis-6.0", + "Mirantis-7.0", + "Mirantis-8.0", + "Mirantis-9.0", + "RDO-Juno" + ], + "environment_operational_status": [ + "stopped", + "running", + "error" + ], + "environment_provision_types": [ + "None", + "Deploy", + "Files", + "DB" + ], + "environment_monitoring_types": [ + "Sensu" + ] +} + +# path info +RESPONDER_BASE_PATH = "api.responders.responder_base.ResponderBase" +RESPONDER_BASE_GET_OBJECTS_LIST = RESPONDER_BASE_PATH + ".get_objects_list" +RESPONDER_BASE_GET_OBJECT_BY_ID = RESPONDER_BASE_PATH + ".get_object_by_id" +RESPONDER_BASE_CHECK_ENVIRONMENT_NAME = RESPONDER_BASE_PATH + ".check_environment_name" +RESPONDER_BASE_READ = RESPONDER_BASE_PATH + ".read" +RESPONDER_BASE_WRITE = RESPONDER_BASE_PATH + ".write" +RESPONDER_BASE_AGGREGATE = RESPONDER_BASE_PATH + ".aggregate" diff --git a/app/test/api/responders_test/test_data/clique_constraints.py b/app/test/api/responders_test/test_data/clique_constraints.py new file mode 100644 index 0000000..6f867ae --- /dev/null +++ b/app/test/api/responders_test/test_data/clique_constraints.py @@ -0,0 +1,74 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from test.api.responders_test.test_data import base + +URL = "/clique_constraints" + +WRONG_ID = base.WRONG_OBJECT_ID +NONEXISTENT_ID = "576a4176a83d5313f21971f0" +CORRECT_ID = base.CORRECT_OBJECT_ID + +WRONG_FOCAL_POINT_TYPE = base.WRONG_OBJECT_TYPE +CORRECT_FOCAL_POINT_TYPE = base.CORRECT_OBJECT_TYPE + +CONSTRAINT = "network" + +CLIQUE_CONSTRAINTS_WITH_SPECIFIC_ID = [ + { + "id": CORRECT_ID + } +] + +CLIQUE_CONSTRAINTS_WITH_SPECIFIC_FOCAL_POINT_TYPE = [ + { + "id": "576a4176a83d5313f21971f5", + "focal_point_type": CORRECT_FOCAL_POINT_TYPE + }, + { + "id": "576ac7069f6ba3074882b2eb", + "focal_point_type": CORRECT_FOCAL_POINT_TYPE + } +] + +CLIQUE_CONSTRAINTS_WITH_SPECIFIC_FOCAL_POINT_TYPE_RESPONSE = { + "clique_constraints": CLIQUE_CONSTRAINTS_WITH_SPECIFIC_FOCAL_POINT_TYPE +} + +CLIQUE_CONSTRAINTS_WITH_SPECIFIC_CONSTRAINT = [ + { + "id": "576a4176a83d5313f21971f5", + "constraints": [ + CONSTRAINT + ] + }, + { + "id": "576ac7069f6ba3074882b2eb", + "constraints": [ + CONSTRAINT + ] + } +] + +CLIQUE_CONSTRAINTS_WITH_SPECIFIC_CONSTRAINT_RESPONSE = { + "clique_constraints": CLIQUE_CONSTRAINTS_WITH_SPECIFIC_CONSTRAINT +} + +CLIQUE_CONSTRAINTS = [ + { + "id": "576a4176a83d5313f21971f5" + }, + { + "id": "576ac7069f6ba3074882b2eb" + } +] + +CLIQUE_CONSTRAINTS_RESPONSE = { + "clique_constraints": CLIQUE_CONSTRAINTS +} diff --git a/app/test/api/responders_test/test_data/clique_types.py b/app/test/api/responders_test/test_data/clique_types.py new file mode 100644 index 0000000..0fbe839 --- /dev/null +++ b/app/test/api/responders_test/test_data/clique_types.py @@ -0,0 +1,170 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from test.api.responders_test.test_data import base + + +URL = "/clique_types" + +WRONG_ID = base.WRONG_OBJECT_ID +NONEXISTENT_ID = "58ca73ae3a8a836d10ff3b44" +CORRECT_ID = base.CORRECT_OBJECT_ID + +WRONG_FOCAL_POINT_TYPE = base.WRONG_OBJECT_TYPE +CORRECT_FOCAL_POINT_POINT_TYPE = base.CORRECT_OBJECT_TYPE + +WRONG_LINK_TYPE = base.WRONG_LINK_TYPE +NONEXISTENT_LINK_TYPE = "otep-pnic" +CORRECT_LINK_TYPE = base.CORRECT_LINK_TYPE + +CLIQUE_TYPES_WITH_SPECIFIC_ID = [ + { + "environment": "Mirantis-Liberty-API", + "focal_point_type": "pnic", + "id": CORRECT_ID + } +] + +CLIQUE_TYPES_WITH_SPECIFIC_FOCAL_POINT_TYPE = [ + { + "environment": "Mirantis-Liberty-API", + "focal_point_type": CORRECT_FOCAL_POINT_POINT_TYPE, + "id": "58ca73ae3a8a836d10ff3b80" + }, + { + "environment": "Mirantis-Liberty-API", + "focal_point_type": CORRECT_FOCAL_POINT_POINT_TYPE, + "id": "58ca73ae3a8a836d10ff3b81" + } +] + +CLIQUE_TYPES_WITH_SPECIFIC_FOCAL_POINT_TYPE_RESPONSE = { + "clique_types": CLIQUE_TYPES_WITH_SPECIFIC_FOCAL_POINT_TYPE +} + +CLIQUE_TYPES_WITH_SPECIFIC_LINK_TYPE = [ + { + "environment": "Mirantis-Liberty-API", + "link_types": [ + CORRECT_LINK_TYPE + ], + "id": "58ca73ae3a8a836d10ff3b80" + }, + { + "environment": "Mirantis-Liberty-API", + "link_types": [ + CORRECT_LINK_TYPE + ], + "id": "58ca73ae3a8a836d10ff3b81" + } +] + +CLIQUE_TYPES_WITH_SPECIFIC_LINK_TYPE_RESPONSE = { + "clique_types": CLIQUE_TYPES_WITH_SPECIFIC_LINK_TYPE +} + +CLIQUE_TYPES = [ + { + "environment": "Mirantis-Liberty-API", + "focal_point_type": "vnic", + "id": "58ca73ae3a8a836d10ff3b80" + }, + { + "environment": "Mirantis-Liberty-API", + "focal_point_type": "vnic", + "id": "58ca73ae3a8a836d10ff3b81" + } +] + +CLIQUE_TYPES_RESPONSE = { + "clique_types": CLIQUE_TYPES +} + +NON_DICT_CLIQUE_TYPE = base.NON_DICT_OBJ + +CLIQUE_TYPE_WITHOUT_ENVIRONMENT = { + "name": "instance_vconnector_clique", + "link_types": [ + "instance-vnic", + "vnic-vconnector" + ], + "focal_point_type": "instance" +} + +CLIQUE_TYPE_WITH_UNKNOWN_ENVIRONMENT = { + "environment": base.UNKNOWN_ENV, + "id": "589a3969761b0555a3ef6093", + "name": "instance_vconnector_clique", + "link_types": [ + "instance-vnic", + "vnic-vconnector" + ], + "focal_point_type": "instance" +} + +CLIQUE_TYPE_WITHOUT_FOCAL_POINT_TYPE = { + "environment": "Mirantis-Liberty-API", + "name": "instance_vconnector_clique", + "link_types": [ + "instance-vnic", + "vnic-vconnector" + ] +} + +CLIQUE_TYPE_WITH_WRONG_FOCAL_POINT_TYPE = { + "environment": "Mirantis-Liberty-API", + "name": "instance_vconnector_clique", + "link_types": [ + "instance-vnic", + "vnic-vconnector" + ], + "focal_point_type": WRONG_FOCAL_POINT_TYPE +} + +CLIQUE_TYPE_WITHOUT_LINK_TYPES = { + "environment": "Mirantis-Liberty-API", + "name": "instance_vconnector_clique", + "focal_point_type": "instance" +} + +CLIQUE_TYPE_WITH_NON_LIST_LINK_TYPES = { + "environment": "Mirantis-Liberty-API", + "name": "instance_vconnector_clique", + "link_types": "instance-vnic", + "focal_point_type": "instance" +} + +CLIQUE_TYPE_WITH_WRONG_LINK_TYPE = { + "environment": "Mirantis-Liberty-API", + "name": "instance_vconnector_clique", + "link_types": [ + WRONG_LINK_TYPE, + "vnic-vconnector" + ], + "focal_point_type": "instance" +} + +CLIQUE_TYPE_WITHOUT_NAME = { + "environment": "Mirantis-Liberty-API", + "link_types": [ + "instance-vnic", + "vnic-vconnector", + ], + "focal_point_type": "instance" +} + +CLIQUE_TYPE = { + "environment": "Mirantis-Liberty-API", + "name": "instance_vconnector_clique", + "link_types": [ + "instance-vnic", + "vnic-vconnector" + ], + "focal_point_type": "instance" +} diff --git a/app/test/api/responders_test/test_data/cliques.py b/app/test/api/responders_test/test_data/cliques.py new file mode 100644 index 0000000..e1995cd --- /dev/null +++ b/app/test/api/responders_test/test_data/cliques.py @@ -0,0 +1,171 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from test.api.responders_test.test_data import base + +URL = "/cliques" + +WRONG_CLIQUE_ID = "58a2406e6a283a8bee15d43" +CORRECT_CLIQUE_ID = "58a2406e6a283a8bee15d43f" +NONEXISTENT_CLIQUE_ID = "58a2406e6a283a8bee15d43e" + +WRONG_FOCAL_POINT = "58a2406e6a283a8bee15d43" +CORRECT_FOCAL_POINT = "58a2406e6a283a8bee15d43f" + +WRONG_LINK_ID = "58a2406e6a283a8bee15d43" +CORRECT_LINK_ID = "58a2406e6a283a8bee15d43f" +NONEXISTENT_LINK_ID = "58a2406e6a283a8bee15d43e" + +WRONG_FOCAL_POINT_TYPE = base.WRONG_OBJECT_TYPE +CORRECT_FOCAL_POINT_TYPE = base.CORRECT_OBJECT_TYPE + +WRONG_LINK_TYPE = base.WRONG_LINK_TYPE +CORRECT_LINK_TYPE = base.CORRECT_LINK_TYPE + +CLIQUES_WITH_SPECIFIC_ID = [ + { + "environment": "Mirantis-Liberty-API", + "focal_point_type": "vnic", + "id": CORRECT_CLIQUE_ID + } +] + +CLIQUES_WITH_SPECIFIC_FOCAL_POINT_TYPE = [ + { + "environment": "Mirantis-Liberty-API", + "focal_point_type": CORRECT_FOCAL_POINT_TYPE, + "id": "576c119a3f4173144c7a75c5" + }, + { + "environment": "Mirantis-Liberty-API", + "focal_point_type": CORRECT_FOCAL_POINT_TYPE, + "id": "576c119a3f4173144c7a75cc6" + } +] + +CLIQUES_WITH_SPECIFIC_FOCAL_POINT_TYPE_RESPONSE = { + "cliques": CLIQUES_WITH_SPECIFIC_FOCAL_POINT_TYPE +} + +CLIQUES_WITH_SPECIFIC_FOCAL_POINT = [ + { + "environment": "Mirantis-Liberty-API", + "focal_point": CORRECT_FOCAL_POINT, + "id": "576c119a3f4173144c7a75c5" + }, + { + "environment": "Mirantis-Liberty-API", + "focal_point": CORRECT_FOCAL_POINT, + "id": "576c119a3f4173144c7a758e" + } +] + +CLIQUES_WITH_SPECIFIC_FOCAL_POINT_RESPONSE = { + "cliques": CLIQUES_WITH_SPECIFIC_FOCAL_POINT +} + +CLIQUES_WITH_SPECIFIC_LINK_TYPE = [ + { + "links_detailed": [ + { + "link_type": CORRECT_LINK_TYPE, + "_id": "58a2405a6a283a8bee15d42f" + }, + { + "link_type": "vnic-vconnector", + "_id": "58a240056a283a8bee15d3f2" + } + ], + "environment": "Mirantis-Liberty-API", + "focal_point_type": "vnic", + "id": "576c119a3f4173144c7a75c5" + }, + { + "links_detailed": [ + { + "link_type": CORRECT_LINK_TYPE, + "_id": "58a2405a6a283a8bee15d42f" + } + ], + "environment": "Mirantis-Liberty-API", + "focal_point_type": "pnic", + "id": "576c119a3f4173144c7a75c7" + } +] + +CLIQUES_WITH_SPECIFIC_LINK_TYPE_RESPONSE = { + "cliques": CLIQUES_WITH_SPECIFIC_LINK_TYPE +} + +CLIQUES_WITH_SPECIFIC_LINK_ID = [ + { + "links_detailed": [ + { + "_id": CORRECT_LINK_ID + }, + { + "_id": "58a240056a283a8bee15d3f2" + } + ], + "environment": "Mirantis-Liberty-API", + "focal_point_type": "vnic", + "id": "576c119a3f4173144c7a75c5" + }, + { + "links_detailed": [ + { + "_id": CORRECT_LINK_ID + } + ], + "environment": "Mirantis-Liberty-API", + "focal_point_type": "pnic", + "id": "576c119a3f4173144c7a75c7" + } +] + +CLIQUES_WITH_SPECIFIC_LINK_ID_RESPONSE = { + "cliques": CLIQUES_WITH_SPECIFIC_LINK_ID +} + +# response +CLIQUES = [{ + "links_detailed": [ + { + "link_type": "instance-vnic", + "_id": "58a2405a6a283a8bee15d42f" + }, + { + "link_type": "vnic-vconnector", + "_id": "58a240056a283a8bee15d3f2" + } + ], + "environment": "Mirantis-Liberty-API", + "focal_point_type": "vnic", + "id": "576c119a3f4173144c7a75c5" + }, + { + "links_detailed": [ + { + "link_type": "instance-vnic", + "_id": "58a2405a6a283a8bee15d42f" + }, + { + "link_type": "vnic-vconnector", + "_id": "58a240056a283a8bee15d3f2" + } + ], + "environment": "Miratis-Liberty-API", + "focal_point_type": "pnic", + "id": "576c119a3f4173144c7a75c6" + } +] + +CLIQUES_RESPONSE = { + "cliques": CLIQUES +} diff --git a/app/test/api/responders_test/test_data/constants.py b/app/test/api/responders_test/test_data/constants.py new file mode 100644 index 0000000..9293209 --- /dev/null +++ b/app/test/api/responders_test/test_data/constants.py @@ -0,0 +1,23 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +URL = "/constants" +UNKNOWN_NAME = "unknown constant" +NAME = "distributions" +CONSTANTS_WITH_SPECIFIC_NAME = [{ + "id": "YmPDAQAchr39KjECQ", + "name": NAME, + "data": [{ + "value": "Canonical-icehouse", + "label": "Canonical-icehouse" + }, { + "value": "Canonical-juno", + "label": "Canonical-juno" + }], +}] diff --git a/app/test/api/responders_test/test_data/environment_configs.py b/app/test/api/responders_test/test_data/environment_configs.py new file mode 100644 index 0000000..2a67fb6 --- /dev/null +++ b/app/test/api/responders_test/test_data/environment_configs.py @@ -0,0 +1,221 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from test.api.responders_test.test_data import base + + +URL = "/environment_configs" + +NAME = "Mirantis-Liberty-API" +UNKNOWN_NAME = "UNKNOWN NAME" +WRONG_DISTRIBUTION = base.WRONG_DISTRIBUTION +CORRECT_DISTRIBUTION = base.CORRECT_DISTRIBUTION +WRONG_MECHANISM_DRIVER = base.WRONG_MECHANISM_DRIVER +CORRECT_MECHANISM_DRIVER = base.CORRECT_MECHANISM_DRIVER +WRONG_TYPE_DRIVER = base.WRONG_TYPE_DRIVER +CORRECT_TYPE_DRIVER = base.CORRECT_TYPE_DRIVER +USER = "WS7j8oTbWPf3LbNne" +NON_BOOL_LISTEN = NON_BOOL_SCANNED = \ + NON_BOOL_MONITORING_SETUP_DONE = base.NON_BOOL + +BOOL_LISTEN = BOOL_SCANNED = \ + BOOL_MONITORING_SETUP_DONE = base.BOOL + +ENV_CONFIGS = [ + { + "distribution": "Mirantis-8.0", + "name": "Mirantis-Liberty-API" + }, + { + "distribution": "Mirantis-9.0", + "name": "Mirantis-Liberty" + } +] + +ENV_CONFIGS_RESPONSE = { + "environment_configs": ENV_CONFIGS +} + +ENV_CONFIGS_WITH_SPECIFIC_NAME = [ + { + "distribution": "Mirantis-8.0", + "name": NAME + } +] + +ENV_CONFIGS_WITH_SPECIFIC_DISTRIBUTION = [ + { + "distribution": CORRECT_DISTRIBUTION, + "name": "Mirantis-Liberty-API", + }, + { + "distribution": CORRECT_DISTRIBUTION, + "name": "Mirantis-Liberty" + } +] + +ENV_CONFIGS_WITH_SPECIFIC_DISTRIBUTION_RESPONSE = { + "environment_configs": ENV_CONFIGS_WITH_SPECIFIC_DISTRIBUTION +} + +ENV_CONFIGS_WITH_SPECIFIC_MECHANISM_DRIVER = [ + { + "name": "Mirantis-Liberty-API", + "mechanism_drivers": [ + CORRECT_MECHANISM_DRIVER + ] + }, + { + "name": "Mirantis-Liberty", + "mechanism_drivers": [ + CORRECT_MECHANISM_DRIVER + ] + } +] + +ENV_CONFIGS_WITH_SPECIFIC_MECHANISM_DRIVER_RESPONSE = { + "environment_configs": ENV_CONFIGS_WITH_SPECIFIC_MECHANISM_DRIVER +} + +ENV_CONFIGS_WITH_SPECIFIC_TYPE_DRIVER = [ + { + "type_drivers": CORRECT_TYPE_DRIVER, + "name": "Mirantis-Liberty-API", + }, + { + "type_drivers": CORRECT_TYPE_DRIVER, + "name": "Mirantis-Liberty" + } +] + +ENV_CONFIGS_WITH_SPECIFIC_TYPE_DRIVER_RESPONSE = { + 'environment_configs': ENV_CONFIGS_WITH_SPECIFIC_TYPE_DRIVER +} + +ENV_CONFIGS_WITH_SPECIFIC_USER = [ + { + "user": USER, + "name": "Mirantis-Liberty-API", + }, + { + "user": USER, + "name": "Mirantis-Liberty" + } +] + +ENV_CONFIGS_WITH_SPECIFIC_USER_RESPONSE = { + "environment_configs": ENV_CONFIGS_WITH_SPECIFIC_USER +} + +ENV_CONFIGS_WITH_SPECIFIC_LISTEN = [ + { + "listen": BOOL_LISTEN, + "name": "Mirantis-Liberty-API", + }, + { + "listen": BOOL_LISTEN, + "name": "Mirantis-Liberty" + } +] + +ENV_CONFIGS_WITH_SPECIFIC_LISTEN_RESPONSE = { + "environment_configs": ENV_CONFIGS_WITH_SPECIFIC_LISTEN +} + +ENV_CONFIGS_WITH_SPECIFIC_SCANNED = [ + { + "scanned": BOOL_SCANNED, + "name": "Mirantis-Liberty-API", + }, + { + "scanned": BOOL_SCANNED, + "name": "Mirantis-Liberty" + } +] + +ENV_CONFIGS_WITH_SPECIFIC_SCANNED_RESPONSE = { + "environment_configs": ENV_CONFIGS_WITH_SPECIFIC_SCANNED +} + +ENV_CONFIGS_WITH_SPECIFIC_MONITORING_SETUP_DONE = [ + { + "monitoring_setup_done": BOOL_MONITORING_SETUP_DONE, + "name": "Mirantis-Liberty-API", + }, + { + "monitoring_setup_done": BOOL_MONITORING_SETUP_DONE, + "name": "Mirantis-Liberty" + } +] + +ENV_CONFIGS_WITH_SPECIFIC_MONITORING_SETUP_DONE_RESPONSE = { + "environment_configs": ENV_CONFIGS_WITH_SPECIFIC_MONITORING_SETUP_DONE +} + +ENV_CONFIG = { + "app_path": "/home/korenlev/Calipso/app/", + "configuration": [ + { + "host": "10.56.20.239", + "name": "mysql", + "password": "G1VKEbcqKZXoPthrtNma2D9Y", + "port": "3307", + "user": "root" + }, + { + "name": "OpenStack", + "host": "10.56.20.239", + "admin_token": "wLWefGuD0uYJ7tqkeEScdnNo", + "port": "5000", + "user": "admin", + "pwd": "admin" + }, + { + "host": "10.56.20.239", + "key": "/etc/calipso/keys/Mirantis-Liberty-id_rsa", + "name": "CLI", + "user": "root" + }, + { + "host": "10.56.20.239", + "name": "AMQP", + "password": "YVWMiKMshZhlJCGqFu5PdT9d", + "port": "5673", + "user": "nova" + }, + { + "config_folder": "/tmp/sensu_test", + "provision": "None", + "env_type": "development", + "name": "Monitoring", + "api_port": "4567", + "rabbitmq_port": "5671", + "rabbitmq_pass": "sensuaccess", + "rabbitmq_user": "sensu", + "ssh_port": "20022", + "ssh_user": "root", + "ssh_password": "calipso", + "server_ip": "korlev-calipso-staging1.cisco.com", + "server_name": "calipso-sensu", + "type": "Sensu" + } + ], + "distribution": "Mirantis-8.0", + "last_scanned": "2017-03-16T11:14:54Z", + "listen": True, + "mechanism_drivers": [ + "ovs" + ], + "name": "Mirantis-Liberty", + "operational": "running", + "scanned": True, + "type": "environment", + "type_drivers": "vxlan", + "user": "WS7j8oTbWPf3LbNne" +} diff --git a/app/test/api/responders_test/test_data/inventory.py b/app/test/api/responders_test/test_data/inventory.py new file mode 100644 index 0000000..47d611d --- /dev/null +++ b/app/test/api/responders_test/test_data/inventory.py @@ -0,0 +1,37 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +URL = "/inventory" + +ID = "RegionOne-aggregates" +NONEXISTENT_ID = "Unkown-Id" + + +OBJECTS_LIST = [ + { + "id": "Mirantis-Liberty-regions", + "name": "Regions", + "name_path": "/Mirantis-Liberty-API/Regions" + }, + { + "id": "Mirantis-Liberty-projects", + "name": "Projects", + "name_path": "/Mirantis-Liberty-API/Projects" + } +] + +OBJECT_IDS_RESPONSE = { + "objects": OBJECTS_LIST +} + + +OBJECTS = [{ + "environment": "Mirantis-Liberty-API", + "id": "RegionOne-aggregates" +}] diff --git a/app/test/api/responders_test/test_data/links.py b/app/test/api/responders_test/test_data/links.py new file mode 100644 index 0000000..e71c02d --- /dev/null +++ b/app/test/api/responders_test/test_data/links.py @@ -0,0 +1,90 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from test.api.responders_test.test_data import base + + +URL = "/links" + +UNKNOWN_HOST = "unknown host" + +WRONG_TYPE = base.WRONG_LINK_TYPE +CORRECT_TYPE = base.CORRECT_LINK_TYPE + +WRONG_STATE = base.WRONG_LINK_STATE +CORRECT_STATE = base.CORRECT_LINK_STATE + +LINK_ID = "58ca73ae3a8a836d10ff3b45" +WRONG_LINK_ID = "58ca73ae3a8a836d10ff3b4" +NONEXISTENT_LINK_ID = "58ca73ae3a8a836d10ff3b46" + +LINKS_WITH_SPECIFIC_TYPE = [ + { + "id": "58ca73ae3a8a836d10ff3bb5", + "host": "node-1.cisco.com", + "link_type": CORRECT_TYPE, + "link_name": "Segment-103", + "environment": "Mirantis-Liberty-API" + }, + { + "id": "58ca73ae3a8a836d10ff3b4d", + "host": "node-1.cisco.com", + "link_type": CORRECT_TYPE, + "link_name": "Segment-104", + "environment": "Mirantis-Liberty-API" + } +] + + +LINKS_WITH_SPECIFIC_STATE = [ + { + "id": "58ca73ae3a8a836d10ff3bb5", + "host": "node-1.cisco.com", + "state": CORRECT_STATE, + "environment": "Mirantis-Liberty-API" + }, + { + "id": "58ca73ae3a8a836d10ff3b4d", + "host": "node-1.cisco.com", + "state": CORRECT_STATE, + "environment": "Mirantis-Liberty-API" + } +] + +LINKS_WITH_SPECIFIC_STATE_RESPONSE = { + "links": LINKS_WITH_SPECIFIC_STATE +} + +LINKS_WITH_SPECIFIC_TYPE_RESPONSE = { + "links": LINKS_WITH_SPECIFIC_TYPE +} + +LINKS_WITH_SPECIFIC_ID = [ + { + "id": LINK_ID, + "host": "node-1.cisco.com", + "link_type": "pnic-network", + "link_name": "Segment-103", + "environment": "Mirantis-Liberty-API" + } +] + +LINKS = [ + { + "id": "58ca73ae3a8a836d10ff3b45", + "host": "node-1.cisco.com", + "link_type": "pnic-network", + "link_name": "Segment-103", + "environment": "Mirantis-Liberty-API" + } +] + +LINKS_LIST_RESPONSE = { + "links": LINKS +} diff --git a/app/test/api/responders_test/test_data/messages.py b/app/test/api/responders_test/test_data/messages.py new file mode 100644 index 0000000..b7b5abd --- /dev/null +++ b/app/test/api/responders_test/test_data/messages.py @@ -0,0 +1,108 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from test.api.responders_test.test_data import base + +# url +URL = "/messages" + +NONEXISTENT_MESSAGE_ID = "80b5e074-0f1a-4b67-810c-fa9c92d41a9f" +MESSAGE_ID = "80b5e074-0f1a-4b67-810c-fa9c92d41a98" + +WRONG_SEVERITY = base.WRONG_MESSAGE_SEVERITY +CORRECT_SEVERITY = base.CORRECT_MESSAGE_SEVERITY + +WRONG_RELATED_OBJECT_TYPE = base.WRONG_OBJECT_TYPE +CORRECT_RELATED_OBJECT_TYPE = base.CORRECT_OBJECT_TYPE + +RELATED_OBJECT = "instance" +NONEXISTENT_RELATED_OBJECT = "nonexistent-instance" + +WRONG_FORMAT_TIME = base.WRONG_FORMAT_TIME +CORRECT_FORMAT_TIME = base.CORRECT_FORMAT_TIME + +MESSAGES_WITH_SPECIFIC_TIME = [ + { + "level": "info", + "environment": "Mirantis-Liberty-API", + "id": "3c64fe31-ca3b-49a3-b5d3-c485d7a452e7", + "source_system": "OpenStack", + "timestamp": CORRECT_FORMAT_TIME + } +] + +MESSAGES_WITH_SPECIFIC_TIME_RESPONSE = { + "messages": MESSAGES_WITH_SPECIFIC_TIME +} + +MESSAGES_WITH_SPECIFIC_SEVERITY = [ + { + "level": CORRECT_SEVERITY, + "environment": "Mirantis-Liberty-API", + "id": "3c64fe31-ca3b-49a3-b5d3-c485d7a452e7", + "source_system": "OpenStack" + }, + { + "level": CORRECT_SEVERITY, + "environment": "Mirantis-Liberty-API", + "id": "c7071ec0-04db-4820-92ff-3ed2b916738f", + "source_system": "OpenStack" + }, +] + +MESSAGES_WITH_SPECIFIC_SEVERITY_RESPONSE = { + "messages": MESSAGES_WITH_SPECIFIC_SEVERITY +} + +MESSAGES_WITH_SPECIFIC_RELATED_OBJECT_TYPE = [ + { + "level": "info", + "environment": "Mirantis-Liberty-API", + "related_object_type": CORRECT_RELATED_OBJECT_TYPE, + "id": "3c64fe31-ca3b-49a3-b5d3-c485d7a452e7" + }, + { + "level": "error", + "environment": "Mirantis-Liberty-API", + "related_object_type": CORRECT_RELATED_OBJECT_TYPE, + "id": "c7071ec0-04db-4820-92ff-3ed2b916738f" + }, +] + +MESSAGES_WITH_SPECIFIC_RELATED_OBJECT_TYPE_RESPONSE = { + "messages": MESSAGES_WITH_SPECIFIC_RELATED_OBJECT_TYPE +} + +MESSAGES_WITH_SPECIFIC_ID = [ + { + "level": "info", + "environment": "Mirantis-Liberty", + "id": MESSAGE_ID, + "source_system": "OpenStack" + } +] + +MESSAGES = [ + { + "level": "info", + "environment": "Mirantis-Liberty", + "id": "3c64fe31-ca3b-49a3-b5d3-c485d7a452e7", + "source_system": "OpenStack" + }, + { + "level": "info", + "environment": "Mirantis-Liberty", + "id": "c7071ec0-04db-4820-92ff-3ed2b916738f", + "source_system": "OpenStack" + }, +] + +MESSAGES_RESPONSE = { + "messages": MESSAGES +} diff --git a/app/test/api/responders_test/test_data/monitoring_config_templates.py b/app/test/api/responders_test/test_data/monitoring_config_templates.py new file mode 100644 index 0000000..0f387a4 --- /dev/null +++ b/app/test/api/responders_test/test_data/monitoring_config_templates.py @@ -0,0 +1,98 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from test.api.responders_test.test_data import base + + +URL = "/monitoring_config_templates" + +WRONG_ID = base.WRONG_OBJECT_ID +UNKNOWN_ID = "583711893e149c14785d6da5" +CORRECT_ID = base.CORRECT_OBJECT_ID + +NON_INT_ORDER = 1.3 +INT_ORDER = 1 + +WRONG_SIDE = base.WRONG_MONITORING_SIDE +CORRECT_SIDE = base.CORRECT_MONITORING_SIDE + +TYPE = "client.json" + +TEMPLATES_WITH_SPECIFIC_ORDER = [ + { + "order": INT_ORDER, + "id": "583711893e149c14785d6daa" + }, + { + "order": INT_ORDER, + "id": "583711893e149c14785d6da7" + } +] + +TEMPLATES_WITH_SPECIFIC_ORDER_RESPONSE = { + "monitoring_config_templates": + TEMPLATES_WITH_SPECIFIC_ORDER +} + +TEMPLATES_WITH_SPECIFIC_SIDE = [ + { + "side": CORRECT_SIDE, + "id": "583711893e149c14785d6daa" + }, + { + "side": CORRECT_SIDE, + "id": "583711893e149c14785d6da7" + } +] + +TEMPLATES_WITH_SPECIFIC_SIDE_RESPONSE = { + "monitoring_config_templates": + TEMPLATES_WITH_SPECIFIC_SIDE +} + +TEMPLATES_WITH_SPECIFIC_TYPE = [ + { + "type": TYPE, + "id": "583711893e149c14785d6daa" + }, + { + "type": TYPE, + "id": "583711893e149c14785d6da7" + } +] + +TEMPLATES_WITH_SPECIFIC_TYPE_RESPONSE = { + "monitoring_config_templates": + TEMPLATES_WITH_SPECIFIC_TYPE +} + +TEMPLATES_WITH_SPECIFIC_ID = [ + { + "type": "rabbitmq.json", + "side": "client", + "id": CORRECT_ID + } +] + +TEMPLATES = [ + { + "type": "rabbitmq.json", + "side": "client", + "id": "583711893e149c14785d6daa" + }, + { + "type": "rabbitmq.json", + "side": "client", + "id": "583711893e149c14785d6da7" + } +] + +TEMPLATES_RESPONSE = { + "monitoring_config_templates": TEMPLATES +} diff --git a/app/test/api/responders_test/test_data/scans.py b/app/test/api/responders_test/test_data/scans.py new file mode 100644 index 0000000..479d371 --- /dev/null +++ b/app/test/api/responders_test/test_data/scans.py @@ -0,0 +1,187 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from test.api.responders_test.test_data import base + +URL = "/scans" + +WRONG_ID = base.WRONG_OBJECT_ID +NONEXISTENT_ID = "58c96a075eb66a121cc4e750" +CORRECT_ID = base.CORRECT_OBJECT_ID + +BASE_OBJECT = "node-2.cisco.com" + +WRONG_STATUS = base.WRONG_SCAN_STATUS +CORRECT_STATUS = base.CORRECT_SCAN_STATUS + +SCANS = [ + { + "status": "pending", + "environment": "Mirantis-Liberty-API", + "id": "58c96a075eb66a121cc4e75f", + }, + { + "status": "completed", + "environment": "Mirantis-Liberty-API", + "id": "58c96a075eb66a121cc4e75e", + "scan_completed": True + } +] + +SCANS_RESPONSE = { + "scans": SCANS +} + +SCANS_WITH_SPECIFIC_ID = [ + { + "status": "pending", + "environment": "Mirantis-Liberty-API", + "id": CORRECT_ID, + } +] + +SCANS_WITH_SPECIFIC_BASE_OBJ = [ + { + "status": "pending", + "environment": "Mirantis-Liberty-API", + "id": "58c96a075eb66a121cc4e75f", + "object_id": BASE_OBJECT + }, + { + "status": "completed", + "environment": "Mirantis-Liberty-API", + "id": "58c96a075eb66a121cc4e75e", + "object_id": BASE_OBJECT, + "scan_completed": True + } +] + +SCANS_WITH_SPECIFIC_BASE_OBJ_RESPONSE = { + "scans": SCANS_WITH_SPECIFIC_BASE_OBJ +} + +SCANS_WITH_SPECIFIC_STATUS = [ + { + "status": CORRECT_STATUS, + "environment": "Mirantis-Liberty-API", + "id": "58c96a075eb66a121cc4e75f", + "scan_completed": True + }, + { + "status": CORRECT_STATUS, + "environment": "Mirantis-Liberty-API", + "id": "58c96a075eb66a121cc4e75e", + "scan_completed": True + } +] + +SCANS_WITH_SPECIFIC_STATUS_RESPONSE = { + "scans": SCANS_WITH_SPECIFIC_STATUS +} + +NON_DICT_SCAN = base.NON_DICT_OBJ + +SCAN = { + "status": "pending", + "log_level": "warning", + "clear": True, + "scan_only_inventory": True, + "environment": "Mirantis-Liberty-API", + "inventory": "inventory", + "object_id": "ff" +} + +SCAN_WITHOUT_ENV = { + "status": "pending", + "log_level": "warning", + "clear": True, + "scan_only_inventory": True, + "inventory": "inventory", + "object_id": "ff" +} + +SCAN_WITH_UNKNOWN_ENV = { + "status": "pending", + "log_level": "warning", + "clear": True, + "scan_only_inventory": True, + "environment": base.UNKNOWN_ENV, + "inventory": "inventory", + "object_id": "ff" +} + +SCAN_WITHOUT_STATUS = { + "log_level": "warning", + "clear": True, + "scan_only_inventory": True, + "environment": "Mirantis-Liberty-API", + "inventory": "inventory", + "object_id": "ff" +} + +SCAN_WITH_WRONG_STATUS = { + "status": WRONG_STATUS, + "log_level": "warning", + "clear": True, + "scan_only_inventory": True, + "environment": "Mirantis-Liberty-API", + "inventory": "inventory", + "object_id": "ff" +} + +SCAN_WITH_WRONG_LOG_LEVEL = { + "status": "pending", + "log_level": base.WRONG_LOG_LEVEL, + "clear": True, + "scan_only_inventory": True, + "environment": "Mirantis-Liberty-API", + "inventory": "inventory", + "object_id": "ff" +} + +SCAN_WITH_NON_BOOL_CLEAR = { + "status": "pending", + "log_level": "warning", + "clear": base.NON_BOOL, + "scan_only_inventory": True, + "environment": "Mirantis-Liberty-API", + "inventory": "inventory", + "object_id": "ff" +} + + +SCAN_WITH_NON_BOOL_SCAN_ONLY_INVENTORY = { + "status": "pending", + "log_level": "warning", + "clear": True, + "scan_only_inventory": base.NON_BOOL, + "environment": "Mirantis-Liberty-API", + "inventory": "inventory", + "object_id": "ff" +} + +SCAN_WITH_NON_BOOL_SCAN_ONLY_LINKS = { + "status": "pending", + "log_level": "warning", + "clear": True, + "scan_only_links": base.NON_BOOL, + "environment": "Mirantis-Liberty-API", + "inventory": "inventory", + "object_id": "ff" +} + +SCAN_WITH_NON_BOOL_SCAN_ONLY_CLIQUES = { + "status": "pending", + "log_level": "warning", + "clear": True, + "scan_only_cliques": base.NON_BOOL, + "environment": "Mirantis-Liberty-API", + "inventory": "inventory", + "object_id": "ff" +} diff --git a/app/test/api/responders_test/test_data/scheduled_scans.py b/app/test/api/responders_test/test_data/scheduled_scans.py new file mode 100644 index 0000000..1019572 --- /dev/null +++ b/app/test/api/responders_test/test_data/scheduled_scans.py @@ -0,0 +1,138 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +from test.api.responders_test.test_data import base + +URL = "/scheduled_scans" +WRONG_FREQ = "wrong_freq" +CORRECT_FREQ = "WEEKLY" +WRONG_ID = base.WRONG_OBJECT_ID +NONEXISTENT_ID = "58c96a075eb66a121cc4e750" +CORRECT_ID = "ff4d3e80e42e886bef13a084" +NON_DICT_SCHEDULED_SCAN = "" + + +SCHEDULED_SCANS = [ + { + "id": "ff4d3e80e42e886bef13a084", + "environment": base.ENV_NAME, + "scheduled_timestamp": "2017-07-24T12:45:03.784+0000", + "freq": "WEEKLY" + }, + { + "id": "58e4e1aa6df71e971324ea62", + "environment": base.ENV_NAME, + "scheduled_timestamp": "2017-07-24T12:45:03.784+0000", + "freq": "WEEKLY" + } +] + +SCHEDULED_SCANS_RESPONSE = { + "scheduled_scans": SCHEDULED_SCANS +} + +SCHEDULED_SCAN_WITH_SPECIFIC_FREQ = [{ + "id": "ff4d3e80e42e886bef13a084", + "environment": base.ENV_NAME, + "scheduled_timestamp": "2017-07-24T12:45:03.784+0000", + "freq": CORRECT_FREQ +}] + +SCHEDULED_SCAN_WITH_SPECIFIC_FREQ_RESPONSE = { + "scheduled_scans": SCHEDULED_SCAN_WITH_SPECIFIC_FREQ +} + +SCHEDULED_SCAN_WITH_SPECIFIC_ID = [{ + "id": CORRECT_ID, + "environment": base.ENV_NAME, + "scheduled_timestamp": "2017-07-24T12:45:03.784+0000", + "freq": CORRECT_FREQ +}] + +SCHEDULED_SCAN = { + "environment": base.ENV_NAME, + "freq": CORRECT_FREQ, + "submit_timestamp": "2017-07-24T12:45:03.784+0000" +} + +SCHEDULED_SCAN_WITHOUT_ENV = { + "freq": CORRECT_FREQ, + "submit_timestamp": "2017-07-24T12:45:03.784+0000" +} + +SCHEDULED_SCAN_WITH_UNKNOWN_ENV = { + "environment": base.UNKNOWN_ENV, + "freq": CORRECT_FREQ, + "submit_timestamp": "2017-07-24T12:45:03.784+0000" +} + +SCHEDULED_SCAN_WITHOUT_FREQ = { + "environment": base.ENV_NAME, + "submit_timestamp": "2017-07-24T12:45:03.784+0000" +} + +SCHEDULED_SCAN_WITHOUT_SUBMIT_TIMESTAMP = { + "environment": base.ENV_NAME, + "freq": CORRECT_FREQ, +} + +SCHEDULED_SCAN_WITH_WRONG_FREQ = { + "environment": base.ENV_NAME, + "freq": WRONG_FREQ, + "submit_timestamp": "2017-07-24T12:45:03.784+0000" +} + +SCHEDULED_SCAN_WITH_WRONG_LOG_LEVEL = { + "environment": base.ENV_NAME, + "freq": CORRECT_FREQ, + "log_level": base.WRONG_LOG_LEVEL, + "submit_timestamp": "2017-07-24T12:45:03.784+0000" +} + +SCHEDULED_SCAN_WITH_WRONG_SUBMIT_TIMESTAMP = { + "environment": base.ENV_NAME, + "freq": CORRECT_FREQ, + "submit_timestamp": base.WRONG_FORMAT_TIME +} + +SCHEDULED_SCAN_WITH_NON_BOOL_CLEAR = { + "environment": base.ENV_NAME, + "freq": CORRECT_FREQ, + "submit_timestamp": "2017-07-24T12:45:03.784+0000", + "clear": base.NON_BOOL +} + +SCHEDULED_SCAN_WITH_NON_BOOL_SCAN_ONLY_LINKS = { + "environment": base.ENV_NAME, + "freq": CORRECT_FREQ, + "submit_timestamp": "2017-07-24T12:45:03.784+0000", + "scan_only_links": base.NON_BOOL +} + +SCHEDULED_SCAN_WITH_NON_BOOL_SCAN_ONLY_CLIQUES = { + "environment": base.ENV_NAME, + "freq": CORRECT_FREQ, + "submit_timestamp": "2017-07-24T12:45:03.784+0000", + "scan_only_cliques": base.NON_BOOL +} + +SCHEDULED_SCAN_WITH_NON_BOOL_SCAN_ONLY_INVENTORY = { + "environment": base.ENV_NAME, + "freq": CORRECT_FREQ, + "submit_timestamp": "2017-07-24T12:45:03.784+0000", + "scan_only_inventory": base.NON_BOOL +} + +SCHEDULED_SCAN_WITH_EXTRA_SCAN_ONLY_FLAGS = { + "environment": base.ENV_NAME, + "freq": CORRECT_FREQ, + "submit_timestamp": "2017-07-24T12:45:03.784+0000", + "scan_only_links": True, + "scan_only_inventory": True +} diff --git a/app/test/api/responders_test/test_data/tokens.py b/app/test/api/responders_test/test_data/tokens.py new file mode 100644 index 0000000..8d9960d --- /dev/null +++ b/app/test/api/responders_test/test_data/tokens.py @@ -0,0 +1,83 @@ +############################################################################### +# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) # +# and others # +# # +# All rights reserved. This program and the accompanying materials # +# are made available under the terms of the Apache License, Version 2.0 # +# which accompanies this distribution, and is available at # +# http://www.apache.org/licenses/LICENSE-2.0 # +############################################################################### +URL = '/auth/tokens' + +AUTH_OBJ_WITHOUT_AUTH = { + +} + +AUTH_OBJ_WITHOUT_METHODS = { + 'auth': {} +} + +AUTH_OBJ_WITHOUT_CREDENTIALS = { + 'auth': { + 'methods': ['credentials'] + } +} + +AUTH_OBJ_WITHOUT_TOKEN = { + 'auth': { + 'methods': ['token'] + } +} + +AUTH_OBJ_WITH_WRONG_CREDENTIALS = { + 'auth': { + 'methods': ['credentials'], + 'credentials': { + 'username': 'wrong_user', + 'password': 'password' + } + } +} + +AUTH_OBJ_WITH_WRONG_TOKEN = { + 'auth': { + 'methods': ['token'], + 'token': 'wrong_token' + } +} + +AUTH_OBJ_WITH_CORRECT_CREDENTIALS = { + 'auth': { + 'methods': ['credentials'], + 'credentials': { + 'username': 'wrong_user', + 'password': 'password' + } + } +} + +AUTH_OBJ_WITH_CORRECT_TOKEN = { + 'auth': { + 'methods': ['token'], + 'token': '17dfa88789aa47f6bb8501865d905f13' + } +} + +HEADER_WITHOUT_TOKEN = { + +} + +HEADER_WITH_WRONG_TOKEN = { + 'X-Auth-Token': 'wrong token' +} + +HEADER_WITH_CORRECT_TOKEN = { + 'X-Auth-Token': '17dfa88789aa47f6bb8501865d905f13' +} + +AUTH_BASE_PATH = 'api.auth.auth.Auth' +AUTH_GET_TOKEN = AUTH_BASE_PATH + '.get_token' +AUTH_WRITE_TOKEN = AUTH_BASE_PATH + '.write_token' +AUTH_DELETE_TOKEN = AUTH_BASE_PATH + '.delete_token' +AUTH_VALIDATE_CREDENTIALS = AUTH_BASE_PATH + '.validate_credentials' +AUTH_VALIDATE_TOKEN = AUTH_BASE_PATH + '.validate_token' |