From fdbd23f311e339998ebc6c92276bdfbf735417c6 Mon Sep 17 00:00:00 2001 From: Santi Manero Date: Wed, 13 Sep 2023 10:36:37 +0200 Subject: [PATCH 1/4] [OPT-684] OTM 0.2.0 - Multiple tz with type field --- otm/otm/entity/otm.py | 18 +- otm/otm/entity/trustzone.py | 1 + slp_base/slp_base/otm_processor.py | 2 - slp_base/slp_base/otm_trustzone_unifier.py | 34 -- ...omponents_with_trustzones_of_same_type.otm | 17 +- .../otm/cloudformation_minimal_content.otm | 13 +- .../otm/expected_altsource_components.otm | 3 +- ...xpected_orphan_component_is_not_mapped.otm | 3 +- .../otm/minimal_otm_expected_result.otm | 2 +- .../resources/otm/otm_expected_result.otm | 4 +- ...only_default_trustzone_expected_result.otm | 3 +- .../mtmt/MTMT_example_coordinates.otm | 24 +- ...T_example_coordinates_1_line_trustzone.otm | 24 +- .../MTMT_example_coordinates_1_orphan.otm | 32 +- slp_mtmt/tests/resources/otm/MTMT_MVP.otm | 16 +- .../resources/otm/missing_coordinates.otm | 19 +- slp_mtmt/tests/resources/otm/nested_tz.otm | 21 +- .../tests/resources/otm/nested_tz_line.otm | 21 +- .../expected_extra_modules.otm | 3 +- .../expected_mapping_modules.otm | 3 +- ...omponents_with_trustzones_of_same_type.otm | 17 +- ...explicit_mapping_and_catchall_expected.otm | 3 +- .../catchall/tf_only_catchall_expected.otm | 3 +- .../tf_singleton_and_catchall_expected.otm | 3 +- .../tf_skip_and_catchall_expected.otm | 3 +- .../resources/otm/expected_aws_dataflows.otm | 3 +- ...xpected_aws_parent_children_components.otm | 3 +- ...xpected_aws_security_groups_components.otm | 4 +- .../resources/otm/expected_elb_example.otm | 3 +- ...pping_skipped_component_without_parent.otm | 3 +- .../resources/otm/expected_no_resources.otm | 3 +- ...xpected_orphan_component_is_not_mapped.otm | 3 +- .../otm/expected_run_valid_mappings.otm | 3 +- .../expected_separated_network_components.otm | 4 +- .../expected_aws_altsource_components.otm | 3 +- .../expected_aws_singleton_components.otm | 3 +- .../otm/minimal_otm_expected_result.otm | 2 +- ...only_default_trustzone_expected_result.otm | 3 +- .../otm/terraform_minimal_content.otm | 11 +- ...f-file-referenced-vars-expected-result.otm | 4 +- .../tests/resources/otm/expected-elb.otm | 7 +- .../tests/resources/otm/expected-official.otm | 21 +- .../tests/resources/otm/expected-sgs.otm | 7 +- .../resources/otm/aws-with-tz-and-vpc.otm | 18 +- .../otm/bidirectional-connectors.otm | 17 +- .../otm/boundary-and-component-tzs.otm | 12 +- .../otm/boundary-tz-and-default-tz.otm | 12 +- .../resources/otm/expected_aws_shapes.otm | 15 +- .../otm/expected_bidirectional_connectors.otm | 3 +- .../expected_boundary_tz_and_default_tz.otm | 4 +- .../otm/expected_complex_diagram.otm | 2 +- ...expected_empty_mapping_and_visio_files.otm | 2 +- .../otm/expected_empty_mapping_file.otm | 2 +- .../otm/expected_empty_visio_file.otm | 3 +- .../otm/expected_extraneous_elements.otm | 4 +- .../otm/expected_generic_elements.otm | 3 +- .../resources/otm/expected_generic_shapes.otm | 9 +- .../expected_manually_modified_connectors.otm | 3 +- .../otm/expected_master_unique_id.otm | 9 +- .../otm/expected_multiple_pages_diagram.otm | 3 +- .../otm/expected_origin_target_trustzone.otm | 33 +- .../otm/expected_origin_trustzone.otm | 33 +- .../otm/expected_overlapped_boundary_tzs.otm | 12 +- .../otm/expected_prune_orphan_connectors.otm | 3 +- .../otm/expected_self_pointing_connectors.otm | 3 +- .../otm/expected_simple_boundary_tzs.otm | 12 +- .../expected_visio_extraneous_elements.otm | 18 +- .../otm/expected_visio_nested_tzs.otm | 60 +-- ...cted_visio_nested_tzs_inside_component.otm | 12 +- ...xpected_visio_self_pointing_connectors.otm | 9 +- .../otm/modified-single-connectors.otm | 49 +- .../resources/otm/multiple-pages-diagram.otm | 17 +- .../resources/otm/visio-orphan-dataflows.otm | 17 +- .../test_representation_calculator.py | 8 +- .../test_otm_controller_diagram_lucid.py | 420 ++---------------- .../test_otm_controller_diagram_visio.py | 131 +++--- .../test_otm_controller_iac_cloudformation.py | 147 +++--- .../test_otm_controller_iac_terraform.py | 143 +++--- .../cloudformation_for_mappings_tests.otm | 3 +- .../lucid/lucid-aws-with-tz-and-vpc.otm | 33 +- .../lucid/lucid-aws-with-tz-default.otm | 48 +- tests/resources/lucid/lucid-aws-with-tz.otm | 33 +- .../otm_empty_file_cloudformation_example.otm | 3 +- .../otm/otm_empty_file_terraform_example.otm | 3 +- .../terraform/aws_simple_components.otm | 3 +- tests/resources/test_resource_paths.py | 185 ++++---- tests/resources/visio/aws-shapes.otm | 15 +- tests/resources/visio/aws-with-tz-and-vpc.otm | 16 +- .../visio/visio-orphan-dataflows.otm | 17 +- ...visio_create_otm_ok_both_mapping_files.otm | 230 ---------- ...sio_create_otm_ok_only_default_mapping.otm | 18 +- tests/unit/test_otm_unifier.py | 48 -- 92 files changed, 954 insertions(+), 1331 deletions(-) delete mode 100644 slp_base/slp_base/otm_trustzone_unifier.py delete mode 100644 tests/resources/visio/visio_create_otm_ok_both_mapping_files.otm delete mode 100644 tests/unit/test_otm_unifier.py diff --git a/otm/otm/entity/otm.py b/otm/otm/entity/otm.py index edf790e1..16a93672 100644 --- a/otm/otm/entity/otm.py +++ b/otm/otm/entity/otm.py @@ -1,9 +1,9 @@ from typing import List -from otm.otm.entity.component import Component -from otm.otm.entity.dataflow import Dataflow -from otm.otm.entity.representation import Representation, DiagramRepresentation, RepresentationType -from otm.otm.entity.trustzone import Trustzone +from .component import Component +from .dataflow import Dataflow +from .representation import Representation, DiagramRepresentation, RepresentationType +from .trustzone import Trustzone REPRESENTATIONS_SIZE_DEFAULT_HEIGHT = 1000 REPRESENTATIONS_SIZE_DEFAULT_WIDTH = 1000 @@ -19,7 +19,7 @@ def __init__(self, project_name, project_id, provider): self.dataflows: List[Dataflow] = [] self.threats = [] self.mitigations = [] - self.version = "0.1.0" + self.version = "0.2.0" self.__provider = provider self.add_default_representation() @@ -71,13 +71,13 @@ def add_component(self, id, name, type, parent, parent_type, source=None, attributes=None, tags=None): self.components.append( Component(component_id=id, name=name, component_type=type, parent=parent, parent_type=parent_type, - source=source, attributes=attributes, tags=tags)) + source=source, attributes=attributes, tags=tags)) def add_dataflow(self, id, name, source_node, destination_node, bidirectional=None, source=None, attributes=None, tags=None): self.dataflows.append(Dataflow(dataflow_id=id, name=name, bidirectional=bidirectional, source_node=source_node, - destination_node=destination_node, source=source, attributes=attributes, - tags=tags)) + destination_node=destination_node, source=source, attributes=attributes, + tags=tags)) def add_representation(self, id_=None, name=None, type_=None): self.representations.append(Representation(id_=id_, name=name, type_=type_)) @@ -86,7 +86,7 @@ def add_diagram_representation(self, id_=None, name=None, type_=None, size=None) self.representations.append(DiagramRepresentation(id_=id_, name=name, type_=type_, size=size)) def add_default_representation(self): - if not self.__provider.provider_type == RepresentationType.DIAGRAM: + if self.__provider.provider_type != RepresentationType.DIAGRAM: self.add_representation(id_=self.__provider.provider_name, name=self.__provider.provider_name, type_=self.__provider.provider_type) diff --git a/otm/otm/entity/trustzone.py b/otm/otm/entity/trustzone.py index 7c0390f6..f997dcb5 100644 --- a/otm/otm/entity/trustzone.py +++ b/otm/otm/entity/trustzone.py @@ -28,6 +28,7 @@ def json(self): json = { "id": self.id, "name": self.name, + "type": self.type, "risk": { "trustRating": self.trustrating } diff --git a/slp_base/slp_base/otm_processor.py b/slp_base/slp_base/otm_processor.py index 105d17e8..98dfeb53 100644 --- a/slp_base/slp_base/otm_processor.py +++ b/slp_base/slp_base/otm_processor.py @@ -4,7 +4,6 @@ from otm.otm.otm_pruner import OTMPruner from slp_base.slp_base.mapping import MappingLoader, MappingValidator from slp_base.slp_base.otm_representations_pruner import OTMRepresentationsPruner -from slp_base.slp_base.otm_trustzone_unifier import OTMTrustZoneUnifier from slp_base.slp_base.otm_validator import OTMValidator from slp_base.slp_base.provider_loader import ProviderLoader from slp_base.slp_base.provider_parser import ProviderParser @@ -43,7 +42,6 @@ def process(self) -> OTM: self._clean_resources() OTMRepresentationsPruner(otm).prune() - OTMTrustZoneUnifier(otm).unify() OTMValidator().validate(otm.json()) return otm diff --git a/slp_base/slp_base/otm_trustzone_unifier.py b/slp_base/slp_base/otm_trustzone_unifier.py deleted file mode 100644 index 35c34ac6..00000000 --- a/slp_base/slp_base/otm_trustzone_unifier.py +++ /dev/null @@ -1,34 +0,0 @@ -import logging - -from otm.otm.entity.otm import OTM - -logger = logging.getLogger(__name__) - - -class OTMTrustZoneUnifier: - - def __init__(self, otm: OTM): - self.otm: OTM = otm - - def unify(self): - - for tz in self.otm.trustzones: - valid_id = tz.type - old_id = tz.id - self.change_childs(old_id, valid_id) - tz.id = valid_id - - self.delete_duplicated_tz() - - def change_childs(self, old_id, valid_id): - for child in self.otm.components + self.otm.trustzones: - if child.parent == old_id: - child.parent = valid_id - - def delete_duplicated_tz(self): - deduplicated = dict() - for tz in self.otm.trustzones: - id_ = tz.id - if id_ not in deduplicated: - deduplicated[id_] = tz - self.otm.trustzones = [v for k, v in deduplicated.items()] diff --git a/slp_cft/tests/resources/otm/cft_components_with_trustzones_of_same_type.otm b/slp_cft/tests/resources/otm/cft_components_with_trustzones_of_same_type.otm index cc4a2cf4..8b5edceb 100644 --- a/slp_cft/tests/resources/otm/cft_components_with_trustzones_of_same_type.otm +++ b/slp_cft/tests/resources/otm/cft_components_with_trustzones_of_same_type.otm @@ -4,7 +4,7 @@ "id": "public-cloud-01.customvpc", "name": "CustomVPC", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "public-cloud-01" }, "tags": [ "AWS::EC2::VPC" @@ -15,7 +15,7 @@ "id": "public-cloud-02.rdscluster", "name": "RDSCluster", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "public-cloud-02" }, "tags": [ "AWS::RDS::DBCluster" @@ -24,7 +24,7 @@ } ], "dataflows": [], - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "id": "id", "name": "name" @@ -38,7 +38,16 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "public-cloud-01", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "name": "Public Cloud", + "risk": { + "trustRating": 10 + } + }, + { + "id": "public-cloud-02", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_cft/tests/resources/otm/cloudformation_minimal_content.otm b/slp_cft/tests/resources/otm/cloudformation_minimal_content.otm index 2b114b86..c4cd1126 100644 --- a/slp_cft/tests/resources/otm/cloudformation_minimal_content.otm +++ b/slp_cft/tests/resources/otm/cloudformation_minimal_content.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -13,11 +13,20 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "public-cloud-01", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud 01", "risk": { "trustRating": 10 } + }, + { + "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "name": "Public Cloud 02", + "risk": { + "trustRating": 10 + } } ], "components": [], diff --git a/slp_cft/tests/resources/otm/expected_altsource_components.otm b/slp_cft/tests/resources/otm/expected_altsource_components.otm index 6e6d242c..4b0f59ec 100644 --- a/slp_cft/tests/resources/otm/expected_altsource_components.otm +++ b/slp_cft/tests/resources/otm/expected_altsource_components.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_cft/tests/resources/otm/expected_orphan_component_is_not_mapped.otm b/slp_cft/tests/resources/otm/expected_orphan_component_is_not_mapped.otm index ed32fa4e..9daba9c7 100644 --- a/slp_cft/tests/resources/otm/expected_orphan_component_is_not_mapped.otm +++ b/slp_cft/tests/resources/otm/expected_orphan_component_is_not_mapped.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_cft/tests/resources/otm/minimal_otm_expected_result.otm b/slp_cft/tests/resources/otm/minimal_otm_expected_result.otm index ef5110b0..46ae5e23 100644 --- a/slp_cft/tests/resources/otm/minimal_otm_expected_result.otm +++ b/slp_cft/tests/resources/otm/minimal_otm_expected_result.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" diff --git a/slp_cft/tests/resources/otm/otm_expected_result.otm b/slp_cft/tests/resources/otm/otm_expected_result.otm index af519de9..ddda7944 100644 --- a/slp_cft/tests/resources/otm/otm_expected_result.otm +++ b/slp_cft/tests/resources/otm/otm_expected_result.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "multiple-files", "id": "multiple-files" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -21,6 +22,7 @@ }, { "id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", + "type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", "name": "Internet", "risk": { "trustRating": 10 diff --git a/slp_cft/tests/resources/otm/otm_with_only_default_trustzone_expected_result.otm b/slp_cft/tests/resources/otm/otm_with_only_default_trustzone_expected_result.otm index 1de3e7c8..6d6b2e9c 100644 --- a/slp_cft/tests/resources/otm/otm_with_only_default_trustzone_expected_result.otm +++ b/slp_cft/tests/resources/otm/otm_with_only_default_trustzone_expected_result.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_mtmt/tests/resources/mtmt/MTMT_example_coordinates.otm b/slp_mtmt/tests/resources/mtmt/MTMT_example_coordinates.otm index ffb3573e..c0a1e479 100644 --- a/slp_mtmt/tests/resources/mtmt/MTMT_example_coordinates.otm +++ b/slp_mtmt/tests/resources/mtmt/MTMT_example_coordinates.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "Example Project", "id": "example-project" @@ -22,7 +22,8 @@ ], "trustZones": [ { - "id": "6376d53e-6461-412b-8e04-7b3fe2b397de", + "id": "13ffd9d9-53ea-4b63-afab-07b730697ddd", + "type": "6376d53e-6461-412b-8e04-7b3fe2b397de", "name": "Internet", "risk": { "trustRating": 10 @@ -48,7 +49,8 @@ ] }, { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "acafa4b0-f94d-4077-8a42-74b959bd0796", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Cloud", "risk": { "trustRating": 10 @@ -80,7 +82,7 @@ "name": "Accounting PostgreSQL", "type": "CD-MICROSOFT-AZURE-DB-POSTGRESQL", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Accounting PostgreSQL", @@ -141,7 +143,7 @@ "name": "Android", "type": "android-device-client", "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "13ffd9d9-53ea-4b63-afab-07b730697ddd" }, "attributes": { "Name": "Android", @@ -191,7 +193,7 @@ "name": "Public API v2", "type": "web-service", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Public API v2", @@ -883,7 +885,7 @@ "name": "Azure File Storage", "type": "azure-storage", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Azure File Storage", @@ -986,7 +988,7 @@ "name": "iOS", "type": "ios-device-client", "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "13ffd9d9-53ea-4b63-afab-07b730697ddd" }, "attributes": { "Name": "iOS", @@ -1036,7 +1038,7 @@ "name": "Browser", "type": "web-ui", "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "13ffd9d9-53ea-4b63-afab-07b730697ddd" }, "attributes": { "Name": "Browser", @@ -1085,7 +1087,7 @@ "name": "Web API", "type": "web-service", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Web API", @@ -1277,7 +1279,7 @@ "name": "Azure Storage", "type": "azure-storage", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Azure Storage", diff --git a/slp_mtmt/tests/resources/mtmt/MTMT_example_coordinates_1_line_trustzone.otm b/slp_mtmt/tests/resources/mtmt/MTMT_example_coordinates_1_line_trustzone.otm index f4e3fca7..45a16ace 100644 --- a/slp_mtmt/tests/resources/mtmt/MTMT_example_coordinates_1_line_trustzone.otm +++ b/slp_mtmt/tests/resources/mtmt/MTMT_example_coordinates_1_line_trustzone.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "Example Project", "id": "example-project" @@ -22,7 +22,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "acafa4b0-f94d-4077-8a42-74b959bd0796", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Cloud", "risk": { "trustRating": 10 @@ -33,7 +34,8 @@ } }, { - "id": "6376d53e-6461-412b-8e04-7b3fe2b397de", + "id": "c99b79b6-a658-4096-9919-27946d92e23f", + "type": "6376d53e-6461-412b-8e04-7b3fe2b397de", "name": "Generic Trust Line Boundary", "risk": { "trustRating": 10 @@ -50,7 +52,7 @@ "name": "Accounting PostgreSQL", "type": "CD-MICROSOFT-AZURE-DB-POSTGRESQL", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Accounting PostgreSQL", @@ -96,7 +98,7 @@ "name": "Android", "type": "android-device-client", "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "c99b79b6-a658-4096-9919-27946d92e23f" }, "attributes": { "Name": "Android", @@ -131,7 +133,7 @@ "name": "Public API v2", "type": "web-service", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Public API v2", @@ -808,7 +810,7 @@ "name": "Azure File Storage", "type": "azure-storage", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Azure File Storage", @@ -896,7 +898,7 @@ "name": "iOS", "type": "ios-device-client", "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "c99b79b6-a658-4096-9919-27946d92e23f" }, "attributes": { "Name": "iOS", @@ -931,7 +933,7 @@ "name": "Browser", "type": "web-ui", "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "c99b79b6-a658-4096-9919-27946d92e23f" }, "attributes": { "Name": "Browser", @@ -965,7 +967,7 @@ "name": "Web API", "type": "web-service", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Web API", @@ -1142,7 +1144,7 @@ "name": "Azure Storage", "type": "azure-storage", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Azure Storage", diff --git a/slp_mtmt/tests/resources/mtmt/MTMT_example_coordinates_1_orphan.otm b/slp_mtmt/tests/resources/mtmt/MTMT_example_coordinates_1_orphan.otm index 983aafdb..9b2fbdc8 100644 --- a/slp_mtmt/tests/resources/mtmt/MTMT_example_coordinates_1_orphan.otm +++ b/slp_mtmt/tests/resources/mtmt/MTMT_example_coordinates_1_orphan.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "Example Project", "id": "example-project" @@ -22,7 +22,8 @@ ], "trustZones": [ { - "id": "6376d53e-6461-412b-8e04-7b3fe2b397de", + "id": "13ffd9d9-53ea-4b63-afab-07b730697ddd", + "type": "6376d53e-6461-412b-8e04-7b3fe2b397de", "name": "Internet", "risk": { "trustRating": 10 @@ -33,7 +34,8 @@ } }, { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "acafa4b0-f94d-4077-8a42-74b959bd0796", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Cloud", "risk": { "trustRating": 10 @@ -42,6 +44,14 @@ "Name": "Cloud", "Dataflow Order": "0" } + }, + { + "id": "185f1c6f-3879-464c-89c9-dc6f0b0c2b21", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "name": "Default trustzone", + "risk": { + "trustRating": 10 + } } ], "components": [ @@ -50,7 +60,7 @@ "name": "Accounting PostgreSQL", "type": "CD-MICROSOFT-AZURE-DB-POSTGRESQL", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Accounting PostgreSQL", @@ -64,7 +74,7 @@ "name": "Android", "type": "android-device-client", "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "13ffd9d9-53ea-4b63-afab-07b730697ddd" }, "attributes": { "Name": "Android", @@ -77,7 +87,7 @@ "name": "Public API v2", "type": "web-service", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Public API v2", @@ -92,7 +102,7 @@ "name": "Azure File Storage", "type": "azure-storage", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Azure File Storage", @@ -108,7 +118,7 @@ "name": "iOS", "type": "ios-device-client", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "185f1c6f-3879-464c-89c9-dc6f0b0c2b21" }, "attributes": { "Name": "iOS", @@ -121,7 +131,7 @@ "name": "Browser", "type": "web-ui", "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "13ffd9d9-53ea-4b63-afab-07b730697ddd" }, "attributes": { "Name": "Browser", @@ -133,7 +143,7 @@ "name": "Web API", "type": "web-service", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Web API", @@ -148,7 +158,7 @@ "name": "Azure Storage", "type": "azure-storage", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796" }, "attributes": { "Name": "Azure Storage", diff --git a/slp_mtmt/tests/resources/otm/MTMT_MVP.otm b/slp_mtmt/tests/resources/otm/MTMT_MVP.otm index 8909fa4a..b244d6e5 100644 --- a/slp_mtmt/tests/resources/otm/MTMT_MVP.otm +++ b/slp_mtmt/tests/resources/otm/MTMT_MVP.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "Example Project", "id": "example-project" @@ -22,7 +22,8 @@ ], "trustZones": [ { - "id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", + "id": "75605184-4ca0-43be-ba4c-5fa5ad15e367", + "type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", "name": "Internet", "risk": { "trustRating": 10 @@ -48,7 +49,8 @@ ] }, { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "24cdf4da-ac7f-4a35-bab0-29256d4169bf", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -80,7 +82,7 @@ "name": "Accounting PostgreSQL", "type": "CD-MICROSOFT-AZURE-DB-POSTGRESQL", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "24cdf4da-ac7f-4a35-bab0-29256d4169bf" }, "attributes": { "Name": "Accounting PostgreSQL", @@ -141,7 +143,7 @@ "name": "Mobile Client", "type": "android-device-client", "parent": { - "trustZone": "f0ba7722-39b6-4c81-8290-a30a248bb8d9" + "trustZone": "75605184-4ca0-43be-ba4c-5fa5ad15e367" }, "attributes": { "Name": "Mobile Client", @@ -191,7 +193,7 @@ "name": "Public API v2", "type": "web-service", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "24cdf4da-ac7f-4a35-bab0-29256d4169bf" }, "attributes": { "Name": "Public API v2", @@ -533,7 +535,7 @@ "name": "Azure File Storage", "type": "azure-storage", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "24cdf4da-ac7f-4a35-bab0-29256d4169bf" }, "attributes": { "Name": "Azure File Storage", diff --git a/slp_mtmt/tests/resources/otm/missing_coordinates.otm b/slp_mtmt/tests/resources/otm/missing_coordinates.otm index 209f95ff..64c0dc3a 100644 --- a/slp_mtmt/tests/resources/otm/missing_coordinates.otm +++ b/slp_mtmt/tests/resources/otm/missing_coordinates.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "Example Project", "id": "example-project" @@ -22,7 +22,8 @@ ], "trustZones": [ { - "id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", + "id": "75605184-4ca0-43be-ba4c-5fa5ad15e367", + "type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", "name": "Internet", "risk": { "trustRating": 10 @@ -33,7 +34,8 @@ } }, { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "24cdf4da-ac7f-4a35-bab0-29256d4169bf", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -44,7 +46,8 @@ } }, { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "185f1c6f-3879-464c-89c9-dc6f0b0c2b21", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Default trustzone", "risk": { "trustRating": 10 @@ -57,7 +60,7 @@ "name": "Accounting PostgreSQL", "type": "CD-MICROSOFT-AZURE-DB-POSTGRESQL", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "24cdf4da-ac7f-4a35-bab0-29256d4169bf" }, "attributes": { "Name": "Accounting PostgreSQL", @@ -103,7 +106,7 @@ "name": "Mobile Client", "type": "android-device-client", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "185f1c6f-3879-464c-89c9-dc6f0b0c2b21" }, "attributes": { "Name": "Mobile Client", @@ -138,7 +141,7 @@ "name": "Public API v2", "type": "web-service", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "24cdf4da-ac7f-4a35-bab0-29256d4169bf" }, "attributes": { "Name": "Public API v2", @@ -465,7 +468,7 @@ "name": "Azure File Storage", "type": "azure-storage", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "24cdf4da-ac7f-4a35-bab0-29256d4169bf" }, "attributes": { "Name": "Azure File Storage", diff --git a/slp_mtmt/tests/resources/otm/nested_tz.otm b/slp_mtmt/tests/resources/otm/nested_tz.otm index d9517ff3..c4fe4a12 100644 --- a/slp_mtmt/tests/resources/otm/nested_tz.otm +++ b/slp_mtmt/tests/resources/otm/nested_tz.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "id": "example-project", "name": "Example Project" @@ -38,7 +38,7 @@ "id": "a38c22eb-fee8-4abd-b92c-457d6822ee86", "name": "Customer web client", "parent": { - "trustZone": "f0ba7722-39b6-4c81-8290-a30a248bb8d9" + "trustZone": "26e6fdb8-013f-4d59-bb11-208eec4d6bc9" }, "type": "web-client" }, @@ -59,7 +59,7 @@ "id": "eef31b72-49b3-4d5f-9452-7ae178344c6b", "name": "Main Application", "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "351f4038-244d-4de5-bfa0-00c17f2a1fa2" }, "type": "web-application-server-side" }, @@ -80,7 +80,7 @@ "id": "4820ec3a-9841-4baf-a38c-2fa596014274", "name": "Sandbox Mongo", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "9cbb5581-99cc-463b-a77a-c0dcae3b96d7" }, "type": "other-nosql-key-value-store" }, @@ -101,7 +101,7 @@ "id": "9668ae2e-403f-4182-8c4c-d83948ffc31b", "name": "Production Mongo", "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "351f4038-244d-4de5-bfa0-00c17f2a1fa2" }, "type": "other-nosql-key-value-store" } @@ -112,7 +112,8 @@ "Dataflow Order": "0", "Name": "Generic Trust Border Boundary" }, - "id": "6376d53e-6461-412b-8e04-7b3fe2b397de", + "id": "351f4038-244d-4de5-bfa0-00c17f2a1fa2", + "type": "6376d53e-6461-412b-8e04-7b3fe2b397de", "name": "Generic Trust Border Boundary", "risk": { "trustRating": 10 @@ -123,13 +124,14 @@ "Dataflow Order": "0", "Name": "Sandbox environment" }, - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "9cbb5581-99cc-463b-a77a-c0dcae3b96d7", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Sandbox environment", "risk": { "trustRating": 10 }, "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "351f4038-244d-4de5-bfa0-00c17f2a1fa2" } }, { @@ -139,7 +141,8 @@ "Configurable Attributes": {}, "Internet Boundary": {} }, - "id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", + "id": "26e6fdb8-013f-4d59-bb11-208eec4d6bc9", + "type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", "name": "Internet Boundary", "risk": { "trustRating": 10 diff --git a/slp_mtmt/tests/resources/otm/nested_tz_line.otm b/slp_mtmt/tests/resources/otm/nested_tz_line.otm index c490b195..e83c9e2e 100644 --- a/slp_mtmt/tests/resources/otm/nested_tz_line.otm +++ b/slp_mtmt/tests/resources/otm/nested_tz_line.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "id": "example-project", "name": "Example Project" @@ -38,7 +38,7 @@ "id": "a38c22eb-fee8-4abd-b92c-457d6822ee86", "name": "Customer web client", "parent": { - "trustZone": "f0ba7722-39b6-4c81-8290-a30a248bb8d9" + "trustZone": "26e6fdb8-013f-4d59-bb11-208eec4d6bc9" }, "type": "web-client" }, @@ -59,7 +59,7 @@ "id": "eef31b72-49b3-4d5f-9452-7ae178344c6b", "name": "Main Application", "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "e3ddc2c6-83d5-4363-9acb-52655317dafd" }, "type": "web-application-server-side" }, @@ -80,7 +80,7 @@ "id": "4820ec3a-9841-4baf-a38c-2fa596014274", "name": "Sandbox Mongo", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "9cbb5581-99cc-463b-a77a-c0dcae3b96d7" }, "type": "other-nosql-key-value-store" }, @@ -101,7 +101,7 @@ "id": "9668ae2e-403f-4182-8c4c-d83948ffc31b", "name": "Production Mongo", "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "e3ddc2c6-83d5-4363-9acb-52655317dafd" }, "type": "other-nosql-key-value-store" } @@ -112,13 +112,14 @@ "Dataflow Order": "0", "Name": "Sandbox environment" }, - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "9cbb5581-99cc-463b-a77a-c0dcae3b96d7", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Sandbox environment", "risk": { "trustRating": 10 }, "parent": { - "trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de" + "trustZone": "e3ddc2c6-83d5-4363-9acb-52655317dafd" } }, { @@ -128,7 +129,8 @@ "Configurable Attributes": {}, "Internet Boundary": {} }, - "id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", + "id": "26e6fdb8-013f-4d59-bb11-208eec4d6bc9", + "type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", "name": "Internet Boundary", "risk": { "trustRating": 10 @@ -139,7 +141,8 @@ "Generic Trust Line Boundary": {}, "Name": "Generic Trust Line Boundary" }, - "id": "6376d53e-6461-412b-8e04-7b3fe2b397de", + "id": "e3ddc2c6-83d5-4363-9acb-52655317dafd", + "type": "6376d53e-6461-412b-8e04-7b3fe2b397de", "name": "Generic Trust Line Boundary", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/calculate_modules/expected_extra_modules.otm b/slp_tf/tests/resources/otm/calculate_modules/expected_extra_modules.otm index 6c5aa2be..3aa36945 100644 --- a/slp_tf/tests/resources/otm/calculate_modules/expected_extra_modules.otm +++ b/slp_tf/tests/resources/otm/calculate_modules/expected_extra_modules.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/calculate_modules/expected_mapping_modules.otm b/slp_tf/tests/resources/otm/calculate_modules/expected_mapping_modules.otm index 9e96da57..067abbca 100644 --- a/slp_tf/tests/resources/otm/calculate_modules/expected_mapping_modules.otm +++ b/slp_tf/tests/resources/otm/calculate_modules/expected_mapping_modules.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/calculate_trustzones/tf_components_with_trustzones_of_same_type.otm b/slp_tf/tests/resources/otm/calculate_trustzones/tf_components_with_trustzones_of_same_type.otm index f512dd45..a6fabcd5 100644 --- a/slp_tf/tests/resources/otm/calculate_trustzones/tf_components_with_trustzones_of_same_type.otm +++ b/slp_tf/tests/resources/otm/calculate_trustzones/tf_components_with_trustzones_of_same_type.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -13,7 +13,16 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "public-cloud-01", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "name": "Public Cloud", + "risk": { + "trustRating": 10 + } + }, + { + "id": "public-cloud-02", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -25,7 +34,7 @@ "id": "public-cloud-01.aws_vpc-customvpc", "name": "CustomVPC", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "public-cloud-01" }, "tags": [ "aws_vpc" @@ -36,7 +45,7 @@ "id": "public-cloud-02.aws_rds_cluster-rdscluster", "name": "RDSCluster", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "public-cloud-02" }, "tags": [ "aws_rds_cluster" diff --git a/slp_tf/tests/resources/otm/catchall/tf_explicit_mapping_and_catchall_expected.otm b/slp_tf/tests/resources/otm/catchall/tf_explicit_mapping_and_catchall_expected.otm index ffa533ea..28a92f8b 100644 --- a/slp_tf/tests/resources/otm/catchall/tf_explicit_mapping_and_catchall_expected.otm +++ b/slp_tf/tests/resources/otm/catchall/tf_explicit_mapping_and_catchall_expected.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/catchall/tf_only_catchall_expected.otm b/slp_tf/tests/resources/otm/catchall/tf_only_catchall_expected.otm index d6136891..bb8eafd8 100644 --- a/slp_tf/tests/resources/otm/catchall/tf_only_catchall_expected.otm +++ b/slp_tf/tests/resources/otm/catchall/tf_only_catchall_expected.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/catchall/tf_singleton_and_catchall_expected.otm b/slp_tf/tests/resources/otm/catchall/tf_singleton_and_catchall_expected.otm index 5e88f2af..3e5cd1c5 100644 --- a/slp_tf/tests/resources/otm/catchall/tf_singleton_and_catchall_expected.otm +++ b/slp_tf/tests/resources/otm/catchall/tf_singleton_and_catchall_expected.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/catchall/tf_skip_and_catchall_expected.otm b/slp_tf/tests/resources/otm/catchall/tf_skip_and_catchall_expected.otm index 443af822..0930f8e2 100644 --- a/slp_tf/tests/resources/otm/catchall/tf_skip_and_catchall_expected.otm +++ b/slp_tf/tests/resources/otm/catchall/tf_skip_and_catchall_expected.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/expected_aws_dataflows.otm b/slp_tf/tests/resources/otm/expected_aws_dataflows.otm index 843536b6..e721cd7e 100644 --- a/slp_tf/tests/resources/otm/expected_aws_dataflows.otm +++ b/slp_tf/tests/resources/otm/expected_aws_dataflows.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/expected_aws_parent_children_components.otm b/slp_tf/tests/resources/otm/expected_aws_parent_children_components.otm index 1e43e6a4..9efa7133 100644 --- a/slp_tf/tests/resources/otm/expected_aws_parent_children_components.otm +++ b/slp_tf/tests/resources/otm/expected_aws_parent_children_components.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/expected_aws_security_groups_components.otm b/slp_tf/tests/resources/otm/expected_aws_security_groups_components.otm index 5e4461ca..8b62657e 100644 --- a/slp_tf/tests/resources/otm/expected_aws_security_groups_components.otm +++ b/slp_tf/tests/resources/otm/expected_aws_security_groups_components.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -21,6 +22,7 @@ }, { "id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", + "type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", "name": "Internet", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/expected_elb_example.otm b/slp_tf/tests/resources/otm/expected_elb_example.otm index 5f11da4c..fe5e3a2c 100644 --- a/slp_tf/tests/resources/otm/expected_elb_example.otm +++ b/slp_tf/tests/resources/otm/expected_elb_example.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -11,6 +11,7 @@ }], "trustZones": [{ "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/expected_mapping_skipped_component_without_parent.otm b/slp_tf/tests/resources/otm/expected_mapping_skipped_component_without_parent.otm index efaa5344..d1646534 100644 --- a/slp_tf/tests/resources/otm/expected_mapping_skipped_component_without_parent.otm +++ b/slp_tf/tests/resources/otm/expected_mapping_skipped_component_without_parent.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/expected_no_resources.otm b/slp_tf/tests/resources/otm/expected_no_resources.otm index 1258fd26..c9c40b9b 100644 --- a/slp_tf/tests/resources/otm/expected_no_resources.otm +++ b/slp_tf/tests/resources/otm/expected_no_resources.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/expected_orphan_component_is_not_mapped.otm b/slp_tf/tests/resources/otm/expected_orphan_component_is_not_mapped.otm index 90c450f9..a003722e 100644 --- a/slp_tf/tests/resources/otm/expected_orphan_component_is_not_mapped.otm +++ b/slp_tf/tests/resources/otm/expected_orphan_component_is_not_mapped.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/expected_run_valid_mappings.otm b/slp_tf/tests/resources/otm/expected_run_valid_mappings.otm index 9262096d..62c074fb 100644 --- a/slp_tf/tests/resources/otm/expected_run_valid_mappings.otm +++ b/slp_tf/tests/resources/otm/expected_run_valid_mappings.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -11,6 +11,7 @@ }], "trustZones": [{ "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/expected_separated_network_components.otm b/slp_tf/tests/resources/otm/expected_separated_network_components.otm index 033f17b5..72978eeb 100644 --- a/slp_tf/tests/resources/otm/expected_separated_network_components.otm +++ b/slp_tf/tests/resources/otm/expected_separated_network_components.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -11,12 +11,14 @@ }], "trustZones": [{ "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 } }, { "id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", + "type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", "name": "Internet", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/mapping_functions/expected_aws_altsource_components.otm b/slp_tf/tests/resources/otm/mapping_functions/expected_aws_altsource_components.otm index b4629b25..f78c2eb9 100644 --- a/slp_tf/tests/resources/otm/mapping_functions/expected_aws_altsource_components.otm +++ b/slp_tf/tests/resources/otm/mapping_functions/expected_aws_altsource_components.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/mapping_functions/expected_aws_singleton_components.otm b/slp_tf/tests/resources/otm/mapping_functions/expected_aws_singleton_components.otm index 32eb2ade..3a6f41da 100644 --- a/slp_tf/tests/resources/otm/mapping_functions/expected_aws_singleton_components.otm +++ b/slp_tf/tests/resources/otm/mapping_functions/expected_aws_singleton_components.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/minimal_otm_expected_result.otm b/slp_tf/tests/resources/otm/minimal_otm_expected_result.otm index aa596279..b8b7c15a 100644 --- a/slp_tf/tests/resources/otm/minimal_otm_expected_result.otm +++ b/slp_tf/tests/resources/otm/minimal_otm_expected_result.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" diff --git a/slp_tf/tests/resources/otm/otm_with_only_default_trustzone_expected_result.otm b/slp_tf/tests/resources/otm/otm_with_only_default_trustzone_expected_result.otm index 4e64edeb..b850f2b3 100644 --- a/slp_tf/tests/resources/otm/otm_with_only_default_trustzone_expected_result.otm +++ b/slp_tf/tests/resources/otm/otm_with_only_default_trustzone_expected_result.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/terraform_minimal_content.otm b/slp_tf/tests/resources/otm/terraform_minimal_content.otm index afe6c445..4673a1f5 100644 --- a/slp_tf/tests/resources/otm/terraform_minimal_content.otm +++ b/slp_tf/tests/resources/otm/terraform_minimal_content.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -12,8 +12,17 @@ } ], "trustZones": [ + { + "id": "public-cloud-01", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "name": "Public Cloud", + "risk": { + "trustRating": 10 + } + }, { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_tf/tests/resources/otm/tf-file-referenced-vars-expected-result.otm b/slp_tf/tests/resources/otm/tf-file-referenced-vars-expected-result.otm index f4f2047e..f5b4a2b9 100644 --- a/slp_tf/tests/resources/otm/tf-file-referenced-vars-expected-result.otm +++ b/slp_tf/tests/resources/otm/tf-file-referenced-vars-expected-result.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -11,12 +11,14 @@ }], "trustZones": [{ "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 } }, { "id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", + "type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", "name": "Internet", "risk": { "trustRating": 10 diff --git a/slp_tfplan/tests/resources/otm/expected-elb.otm b/slp_tfplan/tests/resources/otm/expected-elb.otm index 15338ddd..823d39cd 100644 --- a/slp_tfplan/tests/resources/otm/expected-elb.otm +++ b/slp_tfplan/tests/resources/otm/expected-elb.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -13,7 +13,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "349bc818-8b17-4f6a-b084-6396d932492c", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -59,7 +60,7 @@ "name": "foo", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "349bc818-8b17-4f6a-b084-6396d932492c" }, "tags": [ "aws_vpc" diff --git a/slp_tfplan/tests/resources/otm/expected-official.otm b/slp_tfplan/tests/resources/otm/expected-official.otm index 276170e0..4ca526a2 100644 --- a/slp_tfplan/tests/resources/otm/expected-official.otm +++ b/slp_tfplan/tests/resources/otm/expected-official.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -13,7 +13,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "349bc818-8b17-4f6a-b084-6396d932492c", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -26,7 +27,7 @@ "name": "click-logger-table", "type": "dynamodb", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "349bc818-8b17-4f6a-b084-6396d932492c" }, "tags": [ "aws_dynamodb_table" @@ -37,7 +38,7 @@ "name": "click_logger_firehose_delivery_stream", "type": "kinesis-data-firehose", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "349bc818-8b17-4f6a-b084-6396d932492c" }, "tags": [ "aws_kinesis_firehose_delivery_stream" @@ -48,7 +49,7 @@ "name": "lambda_clicklogger", "type": "aws-lambda-function", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "349bc818-8b17-4f6a-b084-6396d932492c" }, "tags": [ "aws_lambda_function" @@ -59,7 +60,7 @@ "name": "lambda_clicklogger_authorizer", "type": "aws-lambda-function", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "349bc818-8b17-4f6a-b084-6396d932492c" }, "tags": [ "aws_lambda_function" @@ -70,7 +71,7 @@ "name": "lambda_clicklogger_stream_consumer", "type": "aws-lambda-function", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "349bc818-8b17-4f6a-b084-6396d932492c" }, "tags": [ "aws_lambda_function" @@ -81,7 +82,7 @@ "name": "click_logger_firehose_delivery_s3_bucket", "type": "s3", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "349bc818-8b17-4f6a-b084-6396d932492c" }, "tags": [ "aws_s3_bucket" @@ -92,7 +93,7 @@ "name": "api-gateway (grouped)", "type": "api-gateway", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "349bc818-8b17-4f6a-b084-6396d932492c" }, "tags": [ "aws_api_gateway_authorizer", @@ -114,7 +115,7 @@ "name": "cloudwatch (grouped)", "type": "cloudwatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "349bc818-8b17-4f6a-b084-6396d932492c" }, "tags": [ "aws_cloudwatch_log_group" diff --git a/slp_tfplan/tests/resources/otm/expected-sgs.otm b/slp_tfplan/tests/resources/otm/expected-sgs.otm index 235daf04..07199a45 100644 --- a/slp_tfplan/tests/resources/otm/expected-sgs.otm +++ b/slp_tfplan/tests/resources/otm/expected-sgs.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "name", "id": "id" @@ -13,7 +13,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "349bc818-8b17-4f6a-b084-6396d932492c", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -114,7 +115,7 @@ "name": "CustomVPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "349bc818-8b17-4f6a-b084-6396d932492c" }, "tags": [ "aws_vpc" diff --git a/slp_visio/tests/resources/otm/aws-with-tz-and-vpc.otm b/slp_visio/tests/resources/otm/aws-with-tz-and-vpc.otm index 2960df56..ec91bb2b 100644 --- a/slp_visio/tests/resources/otm/aws-with-tz-and-vpc.otm +++ b/slp_visio/tests/resources/otm/aws-with-tz-and-vpc.otm @@ -4,7 +4,7 @@ "id": "1", "name": "Amazon EC2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { @@ -27,7 +27,7 @@ "id": "12", "name": "Custom machine", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { @@ -50,7 +50,7 @@ "id": "30", "name": "Private Database", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "48" }, "representations": [ { @@ -73,7 +73,7 @@ "id": "35", "name": "Amazon CloudWatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { @@ -96,7 +96,7 @@ "id": "41", "name": "Custom log system", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { @@ -142,7 +142,7 @@ "source": "12" } ], - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "id": "project-id", "name": "project-name" @@ -160,7 +160,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "47", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "representations": [ { @@ -182,7 +183,8 @@ } }, { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "48", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "representations": [ { diff --git a/slp_visio/tests/resources/otm/bidirectional-connectors.otm b/slp_visio/tests/resources/otm/bidirectional-connectors.otm index 501883b7..42f29d36 100644 --- a/slp_visio/tests/resources/otm/bidirectional-connectors.otm +++ b/slp_visio/tests/resources/otm/bidirectional-connectors.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -48,7 +49,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -71,7 +72,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -94,7 +95,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -117,7 +118,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -140,7 +141,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -163,7 +164,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/boundary-and-component-tzs.otm b/slp_visio/tests/resources/otm/boundary-and-component-tzs.otm index 79c671ba..3dfc3138 100644 --- a/slp_visio/tests/resources/otm/boundary-and-component-tzs.otm +++ b/slp_visio/tests/resources/otm/boundary-and-component-tzs.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", + "id": "66", + "type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", "name": "Internet", "risk": { "trustRating": 10 @@ -39,7 +40,8 @@ ] }, { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "64", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -67,7 +69,7 @@ "name": "Custom machine", "type": "ec2", "parent": { - "trustZone": "f0ba7722-39b6-4c81-8290-a30a248bb8d9" + "trustZone": "66" }, "representations": [ { @@ -90,7 +92,7 @@ "name": "Private Database", "type": "rds", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "64" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/boundary-tz-and-default-tz.otm b/slp_visio/tests/resources/otm/boundary-tz-and-default-tz.otm index 1e171f11..7255766b 100644 --- a/slp_visio/tests/resources/otm/boundary-tz-and-default-tz.otm +++ b/slp_visio/tests/resources/otm/boundary-tz-and-default-tz.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "64", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -39,7 +40,8 @@ ] }, { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -70,7 +72,7 @@ "name": "Custom machine", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -93,7 +95,7 @@ "name": "Private Database", "type": "rds", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "64" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/expected_aws_shapes.otm b/slp_visio/tests/resources/otm/expected_aws_shapes.otm index 0096616f..1d87d61f 100644 --- a/slp_visio/tests/resources/otm/expected_aws_shapes.otm +++ b/slp_visio/tests/resources/otm/expected_aws_shapes.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -48,7 +49,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -71,7 +72,7 @@ "name": "Custom machine", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -94,7 +95,7 @@ "name": "Private Database", "type": "rds", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -117,7 +118,7 @@ "name": "Amazon CloudWatch", "type": "cloudwatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -140,7 +141,7 @@ "name": "Custom log system", "type": "cloudwatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/expected_bidirectional_connectors.otm b/slp_visio/tests/resources/otm/expected_bidirectional_connectors.otm index aba9121d..98384975 100644 --- a/slp_visio/tests/resources/otm/expected_bidirectional_connectors.otm +++ b/slp_visio/tests/resources/otm/expected_bidirectional_connectors.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -18,6 +18,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_visio/tests/resources/otm/expected_boundary_tz_and_default_tz.otm b/slp_visio/tests/resources/otm/expected_boundary_tz_and_default_tz.otm index cd1b0229..25063027 100644 --- a/slp_visio/tests/resources/otm/expected_boundary_tz_and_default_tz.otm +++ b/slp_visio/tests/resources/otm/expected_boundary_tz_and_default_tz.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -18,6 +18,7 @@ "trustZones": [ { "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -25,6 +26,7 @@ }, { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_visio/tests/resources/otm/expected_complex_diagram.otm b/slp_visio/tests/resources/otm/expected_complex_diagram.otm index de3b0bcb..00e9b173 100644 --- a/slp_visio/tests/resources/otm/expected_complex_diagram.otm +++ b/slp_visio/tests/resources/otm/expected_complex_diagram.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" diff --git a/slp_visio/tests/resources/otm/expected_empty_mapping_and_visio_files.otm b/slp_visio/tests/resources/otm/expected_empty_mapping_and_visio_files.otm index 1cb569cf..405666cb 100644 --- a/slp_visio/tests/resources/otm/expected_empty_mapping_and_visio_files.otm +++ b/slp_visio/tests/resources/otm/expected_empty_mapping_and_visio_files.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" diff --git a/slp_visio/tests/resources/otm/expected_empty_mapping_file.otm b/slp_visio/tests/resources/otm/expected_empty_mapping_file.otm index d6778745..5db99b7d 100644 --- a/slp_visio/tests/resources/otm/expected_empty_mapping_file.otm +++ b/slp_visio/tests/resources/otm/expected_empty_mapping_file.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" diff --git a/slp_visio/tests/resources/otm/expected_empty_visio_file.otm b/slp_visio/tests/resources/otm/expected_empty_visio_file.otm index b71f5294..198ba3de 100644 --- a/slp_visio/tests/resources/otm/expected_empty_visio_file.otm +++ b/slp_visio/tests/resources/otm/expected_empty_visio_file.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -18,6 +18,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_visio/tests/resources/otm/expected_extraneous_elements.otm b/slp_visio/tests/resources/otm/expected_extraneous_elements.otm index bc24092f..c8b7a7ee 100644 --- a/slp_visio/tests/resources/otm/expected_extraneous_elements.otm +++ b/slp_visio/tests/resources/otm/expected_extraneous_elements.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -18,6 +18,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -40,6 +41,7 @@ }, { "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 diff --git a/slp_visio/tests/resources/otm/expected_generic_elements.otm b/slp_visio/tests/resources/otm/expected_generic_elements.otm index 59396586..d874fe67 100644 --- a/slp_visio/tests/resources/otm/expected_generic_elements.otm +++ b/slp_visio/tests/resources/otm/expected_generic_elements.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -18,6 +18,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_visio/tests/resources/otm/expected_generic_shapes.otm b/slp_visio/tests/resources/otm/expected_generic_shapes.otm index 4efa45f9..e1cefb57 100644 --- a/slp_visio/tests/resources/otm/expected_generic_shapes.otm +++ b/slp_visio/tests/resources/otm/expected_generic_shapes.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -48,7 +49,7 @@ "name": "Custom enterprise GW", "type": "empty-component", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -71,7 +72,7 @@ "name": "Custom web server", "type": "empty-component", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/expected_manually_modified_connectors.otm b/slp_visio/tests/resources/otm/expected_manually_modified_connectors.otm index db41e9c8..544e5b7c 100644 --- a/slp_visio/tests/resources/otm/expected_manually_modified_connectors.otm +++ b/slp_visio/tests/resources/otm/expected_manually_modified_connectors.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -18,6 +18,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_visio/tests/resources/otm/expected_master_unique_id.otm b/slp_visio/tests/resources/otm/expected_master_unique_id.otm index e4517fe7..268f7c8a 100644 --- a/slp_visio/tests/resources/otm/expected_master_unique_id.otm +++ b/slp_visio/tests/resources/otm/expected_master_unique_id.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -48,7 +49,7 @@ "name": "Amazon Redshift from AWS Analytics", "type": "empty-component", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -71,7 +72,7 @@ "name": "Amazon Redshift from AWS Database", "type": "redshift", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/expected_multiple_pages_diagram.otm b/slp_visio/tests/resources/otm/expected_multiple_pages_diagram.otm index d5ab034d..79025088 100644 --- a/slp_visio/tests/resources/otm/expected_multiple_pages_diagram.otm +++ b/slp_visio/tests/resources/otm/expected_multiple_pages_diagram.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -18,6 +18,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_visio/tests/resources/otm/expected_origin_target_trustzone.otm b/slp_visio/tests/resources/otm/expected_origin_target_trustzone.otm index bda8c696..892bc572 100644 --- a/slp_visio/tests/resources/otm/expected_origin_target_trustzone.otm +++ b/slp_visio/tests/resources/otm/expected_origin_target_trustzone.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "11", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -37,6 +38,30 @@ } } ] + }, + { + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "name": "Public Cloud", + "risk": { + "trustRating": 10 + }, + "representations": [ + { + "name": "Public Cloud Representation", + "id": "804b664a-7129-4a9e-a08c-16a99669f605-representation", + "representation": "project-id-diagram", + "size": { + "width": 142, + "height": 142 + }, + "position": { + "x": 945, + "y": 387 + } + } + ], + "attributes": {"default": true} } ], "components": [ @@ -45,7 +70,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "11" }, "representations": [ { @@ -68,7 +93,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/expected_origin_trustzone.otm b/slp_visio/tests/resources/otm/expected_origin_trustzone.otm index 71f59724..45fc14c9 100644 --- a/slp_visio/tests/resources/otm/expected_origin_trustzone.otm +++ b/slp_visio/tests/resources/otm/expected_origin_trustzone.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "11", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -37,6 +38,30 @@ } } ] + }, + { + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "name": "Public Cloud", + "risk": { + "trustRating": 10 + }, + "representations": [ + { + "name": "Public Cloud Representation", + "id": "804b664a-7129-4a9e-a08c-16a99669f605-representation", + "representation": "project-id-diagram", + "size": { + "width": 142, + "height": 142 + }, + "position": { + "x": 945, + "y": 387 + } + } + ], + "attributes": {"default": true} } ], "components": [ @@ -45,7 +70,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "11" }, "representations": [ { @@ -68,7 +93,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/expected_overlapped_boundary_tzs.otm b/slp_visio/tests/resources/otm/expected_overlapped_boundary_tzs.otm index b13b5107..ed664eae 100644 --- a/slp_visio/tests/resources/otm/expected_overlapped_boundary_tzs.otm +++ b/slp_visio/tests/resources/otm/expected_overlapped_boundary_tzs.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "62", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -39,7 +40,8 @@ ] }, { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "64", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -67,7 +69,7 @@ "name": "Custom machine", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "62" }, "representations": [ { @@ -90,7 +92,7 @@ "name": "Private Database", "type": "rds", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "64" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/expected_prune_orphan_connectors.otm b/slp_visio/tests/resources/otm/expected_prune_orphan_connectors.otm index df25fd34..d7a48f39 100644 --- a/slp_visio/tests/resources/otm/expected_prune_orphan_connectors.otm +++ b/slp_visio/tests/resources/otm/expected_prune_orphan_connectors.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -18,6 +18,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_visio/tests/resources/otm/expected_self_pointing_connectors.otm b/slp_visio/tests/resources/otm/expected_self_pointing_connectors.otm index f1c67f75..610cc312 100644 --- a/slp_visio/tests/resources/otm/expected_self_pointing_connectors.otm +++ b/slp_visio/tests/resources/otm/expected_self_pointing_connectors.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -18,6 +18,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/slp_visio/tests/resources/otm/expected_simple_boundary_tzs.otm b/slp_visio/tests/resources/otm/expected_simple_boundary_tzs.otm index 6422e21f..f8adc33e 100644 --- a/slp_visio/tests/resources/otm/expected_simple_boundary_tzs.otm +++ b/slp_visio/tests/resources/otm/expected_simple_boundary_tzs.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "62", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -39,7 +40,8 @@ ] }, { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "64", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -67,7 +69,7 @@ "name": "Custom machine", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "62" }, "representations": [ { @@ -90,7 +92,7 @@ "name": "Private Database", "type": "rds", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "64" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/expected_visio_extraneous_elements.otm b/slp_visio/tests/resources/otm/expected_visio_extraneous_elements.otm index 5d1df298..9a1d1c02 100644 --- a/slp_visio/tests/resources/otm/expected_visio_extraneous_elements.otm +++ b/slp_visio/tests/resources/otm/expected_visio_extraneous_elements.otm @@ -4,7 +4,7 @@ "id": "1", "name": "Amazon EC2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { @@ -27,7 +27,7 @@ "id": "12", "name": "Custom machine", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { @@ -50,7 +50,7 @@ "id": "30", "name": "Private Database", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "48" }, "representations": [ { @@ -73,7 +73,7 @@ "id": "35", "name": "Amazon CloudWatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { @@ -96,7 +96,7 @@ "id": "41", "name": "Custom log system", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { @@ -142,7 +142,7 @@ "source": "12" } ], - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "id": "project-id", "name": "project-name" @@ -160,7 +160,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "47", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "representations": [ { @@ -182,7 +183,8 @@ } }, { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "48", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "representations": [ { diff --git a/slp_visio/tests/resources/otm/expected_visio_nested_tzs.otm b/slp_visio/tests/resources/otm/expected_visio_nested_tzs.otm index 9c0bb00b..dff35bb9 100644 --- a/slp_visio/tests/resources/otm/expected_visio_nested_tzs.otm +++ b/slp_visio/tests/resources/otm/expected_visio_nested_tzs.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,31 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "64", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "name": "Private Secured Cloud", + "risk": { + "trustRating": 10 + }, + "representations": [ + { + "name": "Private Secured Cloud Representation", + "id": "64-representation", + "representation": "project-id-diagram", + "size": { + "width": 142, + "height": 142 + }, + "position": { + "x": 78, + "y": 460 + } + } + ] + }, + { + "id": "65", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -39,13 +63,14 @@ ] }, { - "id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", + "id": "67", + "type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", "name": "Internet", "risk": { "trustRating": 10 }, "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "65" }, "representations": [ { @@ -62,29 +87,8 @@ } } ] - }, - { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", - "name": "Private Secured Cloud", - "risk": { - "trustRating": 10 - }, - "representations": [ - { - "name": "Private Secured Cloud Representation", - "id": "64-representation", - "representation": "project-id-diagram", - "size": { - "width": 142, - "height": 142 - }, - "position": { - "x": 78, - "y": 460 - } - } - ] } + ], "components": [ { @@ -92,7 +96,7 @@ "name": "Custom machine", "type": "ec2", "parent": { - "trustZone": "f0ba7722-39b6-4c81-8290-a30a248bb8d9" + "trustZone": "67" }, "representations": [ { @@ -115,7 +119,7 @@ "name": "Private Database", "type": "rds", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "64" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/expected_visio_nested_tzs_inside_component.otm b/slp_visio/tests/resources/otm/expected_visio_nested_tzs_inside_component.otm index 4218e8a2..5877b18d 100644 --- a/slp_visio/tests/resources/otm/expected_visio_nested_tzs_inside_component.otm +++ b/slp_visio/tests/resources/otm/expected_visio_nested_tzs_inside_component.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "1", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -42,7 +43,8 @@ ] }, { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -73,7 +75,7 @@ "name": "Custom machine", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -96,7 +98,7 @@ "name": "Private Database", "type": "rds", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "1" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/expected_visio_self_pointing_connectors.otm b/slp_visio/tests/resources/otm/expected_visio_self_pointing_connectors.otm index 766eba6a..330fbfcb 100644 --- a/slp_visio/tests/resources/otm/expected_visio_self_pointing_connectors.otm +++ b/slp_visio/tests/resources/otm/expected_visio_self_pointing_connectors.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -48,7 +49,7 @@ "name": "Custom enterprise GW", "type": "empty-component", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -71,7 +72,7 @@ "name": "Custom web server", "type": "empty-component", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/modified-single-connectors.otm b/slp_visio/tests/resources/otm/modified-single-connectors.otm index f692f97f..a722d94a 100644 --- a/slp_visio/tests/resources/otm/modified-single-connectors.otm +++ b/slp_visio/tests/resources/otm/modified-single-connectors.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -48,7 +49,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -71,7 +72,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -94,7 +95,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -117,7 +118,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -140,7 +141,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -163,7 +164,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -186,7 +187,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -209,7 +210,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -232,7 +233,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -255,7 +256,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -278,7 +279,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -301,7 +302,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -324,7 +325,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -347,7 +348,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -370,7 +371,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -393,7 +394,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -416,7 +417,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -439,7 +440,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -462,7 +463,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -485,7 +486,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -508,7 +509,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -531,7 +532,7 @@ "name": "Amazon VPC", "type": "vpc", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/multiple-pages-diagram.otm b/slp_visio/tests/resources/otm/multiple-pages-diagram.otm index 0eb17968..b2445c8a 100644 --- a/slp_visio/tests/resources/otm/multiple-pages-diagram.otm +++ b/slp_visio/tests/resources/otm/multiple-pages-diagram.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "62", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -39,7 +40,8 @@ ] }, { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "64", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -61,7 +63,8 @@ ] }, { - "id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", + "id": "70", + "type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", "name": "Internet", "risk": { "trustRating": 10 @@ -89,7 +92,7 @@ "name": "Custom machine", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "62" }, "representations": [ { @@ -112,7 +115,7 @@ "name": "Private Database", "type": "rds", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "64" }, "representations": [ { @@ -135,7 +138,7 @@ "name": "Internet Machine", "type": "ec2", "parent": { - "trustZone": "f0ba7722-39b6-4c81-8290-a30a248bb8d9" + "trustZone": "70" }, "representations": [ { diff --git a/slp_visio/tests/resources/otm/visio-orphan-dataflows.otm b/slp_visio/tests/resources/otm/visio-orphan-dataflows.otm index b62eb2e5..8675efe5 100644 --- a/slp_visio/tests/resources/otm/visio-orphan-dataflows.otm +++ b/slp_visio/tests/resources/otm/visio-orphan-dataflows.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -48,7 +49,7 @@ "name": "Bucket", "type": "s3", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -71,7 +72,7 @@ "name": "Bucket", "type": "s3", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -94,7 +95,7 @@ "name": "Amazon MQ", "type": "CD-MQ", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -117,7 +118,7 @@ "name": "Amazon MQ", "type": "CD-MQ", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -140,7 +141,7 @@ "name": "Database", "type": "rds", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -163,7 +164,7 @@ "name": "Amazon MQ", "type": "CD-MQ", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { diff --git a/slp_visio/tests/unit/parse/representation/test_representation_calculator.py b/slp_visio/tests/unit/parse/representation/test_representation_calculator.py index b32fd2b7..fa776f1b 100644 --- a/slp_visio/tests/unit/parse/representation/test_representation_calculator.py +++ b/slp_visio/tests/unit/parse/representation/test_representation_calculator.py @@ -1,5 +1,4 @@ -from _pytest.mark import param -from pytest import mark +from pytest import mark, param from shapely.geometry import Polygon, box from otm.otm.entity.representation import RepresentationElement @@ -23,7 +22,7 @@ def create_component( origin: DiagramComponentOrigin = DiagramComponentOrigin.SIMPLE_COMPONENT, parent: DiagramComponent = None, trustzone: bool = False, - representation: Polygon= None, + representation: Polygon = None, ) -> DiagramComponent: return DiagramComponent( id=COMPONENT_ID, @@ -47,7 +46,6 @@ def create_representation(xy: (), wh: ()) -> RepresentationElement: class TestRepresentationCalculator: - LARGER_REPRESENTATION = create_representation((66, 82), (66, 33)) MEDIUM_REPRESENTATION = create_representation((16, 32), (66, 33)) NONE_REPRESENTATION = create_representation((82, 98), (66, 33)) @@ -139,7 +137,6 @@ def test_boundary_trustzone_without_parent(self): trustzone = create_component( origin=DiagramComponentOrigin.BOUNDARY, trustzone=True, - parent=None, representation=LARGER_SHAPE ) @@ -154,7 +151,6 @@ def test_simple_trustzone_without_parent(self): trustzone = create_component( origin=DiagramComponentOrigin.SIMPLE_COMPONENT, trustzone=True, - parent=None, representation=LARGER_SHAPE ) diff --git a/tests/integration/api/controllers/diagram/lucid/test_otm_controller_diagram_lucid.py b/tests/integration/api/controllers/diagram/lucid/test_otm_controller_diagram_lucid.py index 9c14f9da..9c5316ea 100644 --- a/tests/integration/api/controllers/diagram/lucid/test_otm_controller_diagram_lucid.py +++ b/tests/integration/api/controllers/diagram/lucid/test_otm_controller_diagram_lucid.py @@ -8,25 +8,25 @@ from sl_util.sl_util.file_utils import get_byte_data from slp_base.slp_base.errors import DiagramFileNotValidError, MappingFileNotValidError, LoadingMappingFileError, \ OTMResultError, OTMBuildingError, LoadingDiagramFileError -from slp_visio.tests.unit.util.test_uuid import is_valid_uuid +from slp_base.tests.util.otm import validate_and_compare_otm from startleft.startleft.api import fastapi_server from startleft.startleft.api.controllers.diagram import diag_create_otm_controller from tests.resources import test_resource_paths -from tests.resources.test_resource_paths import visio_aws_with_tz_and_vpc, default_visio_mapping, \ - custom_vpc_mapping - -IRIUSRISK_URL = '' +from tests.resources.test_resource_paths import visio_aws_with_tz_and_vpc, default_visio_mapping webapp = fastapi_server.webapp client = TestClient(webapp) +yaml_mime = 'text/yaml' + def get_url(): return diag_create_otm_controller.PREFIX + diag_create_otm_controller.URL octet_stream = 'application/octet-stream' +json_mime = 'application/json' class TestOTMControllerDiagramLucid: @@ -34,7 +34,7 @@ class TestOTMControllerDiagramLucid: @responses.activate def test_create_otm_ok_lucid_aws_with_tz(self): # Given a project_id - project_id: str = 'project_A_id' + project_id: str = 'test_parse_diagram_file_ok' # And the source file diag_file = get_byte_data(test_resource_paths.lucid_aws_with_tz) @@ -43,148 +43,30 @@ def test_create_otm_ok_lucid_aws_with_tz(self): mapping_file = get_byte_data(test_resource_paths.default_lucid_mapping) custom_mapping_file = get_byte_data(test_resource_paths.lucid_aws_with_tz_mapping) + # And the expected otm + expected_otm = test_resource_paths.lucid_aws_with_tz_otm + # When I do post on diagram endpoint files = {'diag_file': diag_file, 'default_mapping_file': mapping_file, 'custom_mapping_file': custom_mapping_file } - body = {'diag_type': 'LUCID', 'id': f'{project_id}', 'name': 'project_A_name'} + body = {'diag_type': 'LUCID', 'id': project_id, 'name': project_id} response = client.post(get_url(), files=files, data=body) # Then the OTM is returned inside the response as JSON assert response.status_code == diag_create_otm_controller.RESPONSE_STATUS_CODE - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime otm = json.loads(response.text) - assert otm['otmVersion'] == '0.1.0' - assert otm['project']['id'] == project_id - assert otm['project']['name'] == 'project_A_name' - - assert len(otm['representations']) == 1 - - assert otm['representations'][0]['name'] == f'{project_id} Diagram Representation' - assert otm['representations'][0]['id'] == f'{project_id}-diagram' - assert otm['representations'][0]['type'] == 'diagram' - assert otm['representations'][0]['size']['width'] == 2378 - assert otm['representations'][0]['size']['height'] == 1558 - - assert len(otm['trustZones']) == 3 - - assert otm['trustZones'][0]['id'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - assert otm['trustZones'][0]['name'] == 'Public Cloud' - assert len(otm['trustZones'][0]['risk']) == 1 - assert otm['trustZones'][0]['risk']['trustRating'] == 10 - assert otm['trustZones'][1]['id'] == '2ab4effa-40b7-4cd2-ba81-8247d29a6f2d' - assert otm['trustZones'][1]['name'] == 'Private Secured Cloud' - assert len(otm['trustZones'][1]['risk']) == 1 - assert otm['trustZones'][1]['risk']['trustRating'] == 10 - assert otm['trustZones'][2]['id'] == 'f0ba7722-39b6-4c81-8290-a30a248bb8d9' - assert otm['trustZones'][2]['name'] == 'Internet' - assert len(otm['trustZones'][2]['risk']) == 1 - assert otm['trustZones'][2]['risk']['trustRating'] == 10 - - assert len(otm['components']) == 9 - - assert otm['components'][0]['id'] == '7' - assert otm['components'][0]['name'] == 'My EC2' - assert otm['components'][0]['type'] == 'ec2' - assert len(otm['components'][0]['parent']) == 1 - assert otm['components'][0]['parent']['trustZone'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - - assert otm['components'][1]['id'] == '10' - assert otm['components'][1]['name'] == 'My CloudWatch' - assert otm['components'][1]['type'] == 'cloudwatch' - assert len(otm['components'][1]['parent']) == 1 - assert otm['components'][1]['parent']['trustZone'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - - assert otm['components'][2]['id'] == '15' - assert otm['components'][2]['name'] == 'My API Gateway' - assert otm['components'][2]['type'] == 'api-gateway' - assert len(otm['components'][2]['parent']) == 1 - assert otm['components'][2]['parent']['trustZone'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - - assert otm['components'][3]['id'] == '24' - assert otm['components'][3]['name'] == 'My CloudTrail' - assert otm['components'][3]['type'] == 'cloudtrail' - assert len(otm['components'][3]['parent']) == 1 - assert otm['components'][3]['parent']['trustZone'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - - assert otm['components'][4]['id'] == '27' - assert otm['components'][4]['name'] == 'My Simple Storage Service (S3)' - assert otm['components'][4]['type'] == 's3' - assert len(otm['components'][4]['parent']) == 1 - assert otm['components'][4]['parent']['trustZone'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - - assert otm['components'][5]['id'] == '36' - assert otm['components'][5]['name'] == 'Web browser' - assert otm['components'][5]['type'] == 'generic-client' - assert len(otm['components'][5]['parent']) == 1 - assert otm['components'][5]['parent']['trustZone'] == 'f0ba7722-39b6-4c81-8290-a30a248bb8d9' - - assert otm['components'][6]['id'] == '42' - assert otm['components'][6]['name'] == 'Android' - assert otm['components'][6]['type'] == 'android-device-client' - assert len(otm['components'][6]['parent']) == 1 - assert otm['components'][6]['parent']['trustZone'] == 'f0ba7722-39b6-4c81-8290-a30a248bb8d9' - - assert otm['components'][7]['id'] == '45' - assert otm['components'][7]['name'] == 'SQL Database' - assert otm['components'][7]['type'] == 'CD-MICROSOFT-AZURE-SQL-DB' - assert len(otm['components'][7]['parent']) == 1 - assert otm['components'][7]['parent']['trustZone'] == '2ab4effa-40b7-4cd2-ba81-8247d29a6f2d' - - assert otm['components'][8]['id'] == '51' - assert otm['components'][8]['name'] == 'My DynamoDB' - assert otm['components'][8]['type'] == 'dynamodb' - assert len(otm['components'][8]['parent']) == 1 - assert otm['components'][8]['parent']['trustZone'] == '2ab4effa-40b7-4cd2-ba81-8247d29a6f2d' - - assert len(otm['dataflows']) == 8 - - assert otm['dataflows'][0]['id'] == '30' - assert otm['dataflows'][0]['name'] == 'EC2 Logs' - assert otm['dataflows'][0]['source'] == '7' - assert otm['dataflows'][0]['destination'] == '10' - - assert otm['dataflows'][1]['id'] == '31' - assert otm['dataflows'][1]['name'] == 'GW/EC2' - assert otm['dataflows'][1]['source'] == '15' - assert otm['dataflows'][1]['destination'] == '7' - - assert otm['dataflows'][2]['id'] == '32' - assert otm['dataflows'][2]['name'] == 'Log trace' - assert otm['dataflows'][2]['source'] == '15' - assert otm['dataflows'][2]['destination'] == '24' - - assert otm['dataflows'][3]['id'] == '33' - assert otm['dataflows'][3]['name'] == 'Customer data' - assert otm['dataflows'][3]['source'] == '15' - assert otm['dataflows'][3]['destination'] == '27' - - assert otm['dataflows'][4]['id'] == '41' - assert len(otm['dataflows'][4]['name']) == 36 - assert otm['dataflows'][4]['source'] == '36' - assert otm['dataflows'][4]['destination'] == '15' - - assert otm['dataflows'][5]['id'] == '44' - assert len(otm['dataflows'][5]['name']) == 36 - assert otm['dataflows'][5]['source'] == '42' - assert otm['dataflows'][5]['destination'] == '15' - - assert otm['dataflows'][6]['id'] == '54' - assert otm['dataflows'][6]['name'] == 'User data' - assert otm['dataflows'][6]['source'] == '15' - assert otm['dataflows'][6]['destination'] == '51' - - assert otm['dataflows'][7]['id'] == '55' - assert otm['dataflows'][7]['name'] == 'App data' - assert otm['dataflows'][7]['source'] == '15' - assert otm['dataflows'][7]['destination'] == '45' + # and the otm is as expected + result, expected = validate_and_compare_otm(otm, expected_otm, None) + assert result == expected @responses.activate def test_create_otm_ok_lucid_aws_with_tz_and_vpc(self): # Given a project_id - project_id: str = 'project_A_id' + project_id: str = 'test_parse_diagram_file_ok' # And the source file diag_file = get_byte_data(test_resource_paths.lucid_aws_with_tz_and_vpc) @@ -193,233 +75,25 @@ def test_create_otm_ok_lucid_aws_with_tz_and_vpc(self): mapping_file = get_byte_data(test_resource_paths.default_lucid_mapping) custom_mapping_file = get_byte_data(test_resource_paths.lucid_aws_with_tz_and_vpc_mapping) + # And the expected otm + expected_otm = test_resource_paths.lucid_aws_with_tz_and_vpc_otm + # When I do post on diagram endpoint files = {'diag_file': diag_file, 'default_mapping_file': mapping_file, 'custom_mapping_file': custom_mapping_file } - body = {'diag_type': 'LUCID', 'id': f'{project_id}', 'name': 'project_A_name'} + body = {'diag_type': 'LUCID', 'id': project_id, 'name': project_id} response = client.post(get_url(), files=files, data=body) # Then the OTM is returned inside the response as JSON assert response.status_code == diag_create_otm_controller.RESPONSE_STATUS_CODE - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime otm = json.loads(response.text) - assert otm['otmVersion'] == '0.1.0' - assert otm['project']['id'] == project_id - assert otm['project']['name'] == 'project_A_name' - - assert len(otm['representations']) == 1 - - assert otm['representations'][0]['name'] == f'{project_id} Diagram Representation' - assert otm['representations'][0]['id'] == f'{project_id}-diagram' - assert otm['representations'][0]['type'] == 'diagram' - assert otm['representations'][0]['size']['width'] == 2378 - assert otm['representations'][0]['size']['height'] == 1558 - - assert len(otm['trustZones']) == 3 - - assert otm['trustZones'][0]['id'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - assert otm['trustZones'][0]['name'] == 'Public Cloud' - assert len(otm['trustZones'][0]['risk']) == 1 - assert otm['trustZones'][0]['risk']['trustRating'] == 10 - assert otm['trustZones'][1]['id'] == '2ab4effa-40b7-4cd2-ba81-8247d29a6f2d' - assert otm['trustZones'][1]['name'] == 'Private Secured Cloud' - assert len(otm['trustZones'][1]['risk']) == 1 - assert otm['trustZones'][1]['risk']['trustRating'] == 10 - assert otm['trustZones'][2]['id'] == 'f0ba7722-39b6-4c81-8290-a30a248bb8d9' - assert otm['trustZones'][2]['name'] == 'Internet' - assert len(otm['trustZones'][2]['risk']) == 1 - assert otm['trustZones'][2]['risk']['trustRating'] == 10 - - assert len(otm['components']) == 10 - - assert otm['components'][0]['id'] == '7' - assert otm['components'][0]['name'] == 'Custom VPC' - assert otm['components'][0]['type'] == 'empty-component' - assert len(otm['components'][0]['parent']) == 1 - assert otm['components'][0]['parent']['trustZone'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - - assert otm['components'][1]['id'] == '9' - assert otm['components'][1]['name'] == 'My EC2' - assert otm['components'][1]['type'] == 'ec2' - assert len(otm['components'][1]['parent']) == 1 - assert otm['components'][1]['parent']['component'] == '7' - - assert otm['components'][2]['id'] == '12' - assert otm['components'][2]['name'] == 'My CloudWatch' - assert otm['components'][2]['type'] == 'cloudwatch' - assert len(otm['components'][2]['parent']) == 1 - assert otm['components'][2]['parent']['trustZone'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - - assert otm['components'][3]['id'] == '17' - assert otm['components'][3]['name'] == 'My API Gateway' - assert otm['components'][3]['type'] == 'api-gateway' - assert len(otm['components'][3]['parent']) == 1 - assert otm['components'][3]['parent']['trustZone'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - - assert otm['components'][4]['id'] == '26' - assert otm['components'][4]['name'] == 'My CloudTrail' - assert otm['components'][4]['type'] == 'cloudtrail' - assert len(otm['components'][4]['parent']) == 1 - assert otm['components'][4]['parent']['trustZone'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - - assert otm['components'][5]['id'] == '29' - assert otm['components'][5]['name'] == 'My Simple Storage Service (S3)' - assert otm['components'][5]['type'] == 's3' - assert len(otm['components'][5]['parent']) == 1 - assert otm['components'][5]['parent']['trustZone'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - - assert otm['components'][6]['id'] == '38' - assert otm['components'][6]['name'] == 'Web browser' - assert otm['components'][6]['type'] == 'generic-client' - assert len(otm['components'][6]['parent']) == 1 - assert otm['components'][6]['parent']['trustZone'] == 'f0ba7722-39b6-4c81-8290-a30a248bb8d9' - - assert otm['components'][7]['id'] == '44' - assert otm['components'][7]['name'] == 'Android' - assert otm['components'][7]['type'] == 'android-device-client' - assert len(otm['components'][7]['parent']) == 1 - assert otm['components'][7]['parent']['trustZone'] == 'f0ba7722-39b6-4c81-8290-a30a248bb8d9' - - assert otm['components'][8]['id'] == '47' - assert otm['components'][8]['name'] == 'SQL Database' - assert otm['components'][8]['type'] == 'CD-MICROSOFT-AZURE-SQL-DB' - assert len(otm['components'][8]['parent']) == 1 - assert otm['components'][8]['parent']['trustZone'] == '2ab4effa-40b7-4cd2-ba81-8247d29a6f2d' - - assert otm['components'][9]['id'] == '53' - assert otm['components'][9]['name'] == 'My DynamoDB' - assert otm['components'][9]['type'] == 'dynamodb' - assert len(otm['components'][9]['parent']) == 1 - assert otm['components'][9]['parent']['trustZone'] == '2ab4effa-40b7-4cd2-ba81-8247d29a6f2d' - - assert len(otm['dataflows']) == 8 - - assert otm['dataflows'][0]['id'] == '32' - assert otm['dataflows'][0]['name'] == 'EC2 Logs' - assert otm['dataflows'][0]['source'] == '9' - assert otm['dataflows'][0]['destination'] == '12' - - assert otm['dataflows'][1]['id'] == '33' - assert otm['dataflows'][1]['name'] == 'GW/EC2' - assert otm['dataflows'][1]['source'] == '17' - assert otm['dataflows'][1]['destination'] == '9' - - assert otm['dataflows'][2]['id'] == '34' - assert otm['dataflows'][2]['name'] == 'Log trace' - assert otm['dataflows'][2]['source'] == '17' - assert otm['dataflows'][2]['destination'] == '26' - - assert otm['dataflows'][3]['id'] == '35' - assert otm['dataflows'][3]['name'] == 'Customer data' - assert otm['dataflows'][3]['source'] == '17' - assert otm['dataflows'][3]['destination'] == '29' - - assert otm['dataflows'][4]['id'] == '43' - assert is_valid_uuid((otm['dataflows'][4]['name'])) - assert otm['dataflows'][4]['source'] == '38' - assert otm['dataflows'][4]['destination'] == '17' - - assert otm['dataflows'][5]['id'] == '46' - assert is_valid_uuid(otm['dataflows'][5]['name']) - assert otm['dataflows'][5]['source'] == '44' - assert otm['dataflows'][5]['destination'] == '17' - - assert otm['dataflows'][6]['id'] == '56' - assert otm['dataflows'][6]['name'] == 'User data' - assert otm['dataflows'][6]['source'] == '17' - assert otm['dataflows'][6]['destination'] == '53' - - assert otm['dataflows'][7]['id'] == '57' - assert otm['dataflows'][7]['name'] == 'App data' - assert otm['dataflows'][7]['source'] == '17' - assert otm['dataflows'][7]['destination'] == '47' - - @responses.activate - def test_create_otm_ok_both_mapping_files(self): - # Given a project_id - project_id: str = 'project_A_id' - - # When I do post on diagram endpoint - files = {'diag_file': open(visio_aws_with_tz_and_vpc, 'rb'), - 'default_mapping_file': open(default_visio_mapping, 'rb'), - 'custom_mapping_file': open(custom_vpc_mapping, 'rb')} - body = {'diag_type': 'VISIO', 'id': f'{project_id}', 'name': 'project_A_name'} - response = client.post(get_url(), files=files, data=body) - - # Then the OTM is returned inside the response as JSON - assert response.status_code == diag_create_otm_controller.RESPONSE_STATUS_CODE - assert response.headers.get('content-type') == 'application/json' - otm = json.loads(response.text) - - assert otm['otmVersion'] == '0.1.0' - assert otm['project']['id'] == project_id - assert otm['project']['name'] == 'project_A_name' - assert len(otm['representations']) == 1 - assert otm['representations'][0]['name'] == f'{project_id} Diagram Representation' - assert otm['representations'][0]['id'] == f'{project_id}-diagram' - assert otm['representations'][0]['type'] == 'diagram' - assert otm['representations'][0]['size']['width'] == 1967 - assert otm['representations'][0]['size']['height'] == 1356 - assert len(otm['trustZones']) == 2 - assert otm['trustZones'][0]['id'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - assert otm['trustZones'][0]['name'] == 'Public Cloud' - assert len(otm['trustZones'][0]['risk']) == 1 - assert otm['trustZones'][0]['risk']['trustRating'] == 10 - assert otm['trustZones'][1]['id'] == '2ab4effa-40b7-4cd2-ba81-8247d29a6f2d' - assert otm['trustZones'][1]['name'] == 'Private Secured Cloud' - assert len(otm['trustZones'][1]['risk']) == 1 - assert otm['trustZones'][1]['risk']['trustRating'] == 10 - assert len(otm['components']) == 6 - assert otm['components'][0]['id'] == '49' - assert otm['components'][0]['name'] == 'Custom VPC' - assert otm['components'][0]['type'] == 'empty-component' - assert len(otm['components'][0]['parent']) == 1 - assert otm['components'][0]['parent']['trustZone'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - assert otm['components'][1]['id'] == '1' - assert otm['components'][1]['name'] == 'Amazon EC2' - assert otm['components'][1]['type'] == 'ec2' - assert len(otm['components'][1]['parent']) == 1 - assert otm['components'][1]['parent']['component'] == '49' - assert otm['components'][2]['id'] == '12' - assert otm['components'][2]['name'] == 'Custom machine' - assert otm['components'][2]['type'] == 'ec2' - assert len(otm['components'][2]['parent']) == 1 - assert otm['components'][2]['parent']['component'] == '49' - assert otm['components'][3]['id'] == '30' - assert otm['components'][3]['name'] == 'Private Database' - assert otm['components'][3]['type'] == 'rds' - assert len(otm['components'][3]['parent']) == 1 - assert otm['components'][3]['parent']['trustZone'] == '2ab4effa-40b7-4cd2-ba81-8247d29a6f2d' - assert otm['components'][4]['id'] == '35' - assert otm['components'][4]['name'] == 'Amazon CloudWatch' - assert otm['components'][4]['type'] == 'cloudwatch' - assert len(otm['components'][4]['parent']) == 1 - assert otm['components'][4]['parent']['trustZone'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - assert otm['components'][5]['id'] == '41' - assert otm['components'][5]['name'] == 'Custom log system' - assert otm['components'][5]['type'] == 'cloudwatch' - assert len(otm['components'][5]['parent']) == 1 - assert otm['components'][5]['parent']['trustZone'] == 'b61d6911-338d-46a8-9f39-8dcd24abfe91' - assert len(otm['dataflows']) == 4 - assert otm['dataflows'][0]['id'] == '17' - assert len(otm['dataflows'][0]['name']) == 36 - assert otm['dataflows'][0]['source'] == '1' - assert otm['dataflows'][0]['destination'] == '12' - assert otm['dataflows'][1]['id'] == '34' - assert len(otm['dataflows'][1]['name']) == 36 - assert otm['dataflows'][1]['source'] == '12' - assert otm['dataflows'][1]['destination'] == '30' - assert otm['dataflows'][2]['id'] == '40' - assert len(otm['dataflows'][2]['name']) == 36 - assert otm['dataflows'][2]['source'] == '1' - assert otm['dataflows'][2]['destination'] == '35' - assert otm['dataflows'][3]['id'] == '46' - assert len(otm['dataflows'][3]['name']) == 36 - assert otm['dataflows'][3]['source'] == '12' - assert otm['dataflows'][3]['destination'] == '41' + # and the otm is as expected + result, expected = validate_and_compare_otm(otm, expected_otm, None) + assert result == expected @responses.activate @patch('slp_visio.slp_visio.validate.visio_validator.VisioValidator.validate') @@ -429,7 +103,7 @@ def test_response_on_validating_diagram_error(self, mock_load_source_data): # And the request files diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) - mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), 'text/yaml') + mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), yaml_mime) # And the mocked method throwing a DiagramFileNotValidError error = DiagramFileNotValidError('Invalid size', 'mocked error detail', 'mocked error msg 1') @@ -442,7 +116,7 @@ def test_response_on_validating_diagram_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'DiagramFileNotValidError' @@ -458,8 +132,8 @@ def test_response_on_loading_diagram_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), 'application/octet-stream') - mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), 'text/yaml') + diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) + mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingDiagramFileError error = LoadingDiagramFileError('mocked error title', 'mocked error detail', 'mocked error msg 1') @@ -472,7 +146,7 @@ def test_response_on_loading_diagram_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'LoadingDiagramFileError' @@ -488,8 +162,8 @@ def test_response_on_validating_mapping_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), 'application/octet-stream') - mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), 'text/yaml') + diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) + mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingDiagramFileError error = MappingFileNotValidError('Mapping file does not comply with the schema', 'Schema error', @@ -503,7 +177,7 @@ def test_response_on_validating_mapping_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'MappingFileNotValidError' @@ -519,8 +193,8 @@ def test_response_on_loading_mapping_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), 'application/octet-stream') - mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), 'text/yaml') + diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) + mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingDiagramFileError error = LoadingMappingFileError('Error loading the mapping file. The mapping file ins not valid.', @@ -534,7 +208,7 @@ def test_response_on_loading_mapping_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'LoadingMappingFileError' @@ -550,8 +224,8 @@ def test_response_on_otm_result_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), 'application/octet-stream') - mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), 'text/yaml') + diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) + mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingDiagramFileError error = OTMResultError('OTM file does not comply with the schema', 'Schema error', 'mocked error msg') @@ -564,7 +238,7 @@ def test_response_on_otm_result_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'OTMResultError' @@ -580,8 +254,8 @@ def test_response_on_otm_building_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), 'application/octet-stream') - mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), 'text/yaml') + diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) + mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingDiagramFileError error = OTMBuildingError('OTM building error', 'Schema error', 'mocked error msg') @@ -594,7 +268,7 @@ def test_response_on_otm_building_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'OTMBuildingError' @@ -616,8 +290,8 @@ def test_response_on_invalid_diagram_file(self, diagram_source, detail): # And the request files diagram_source = bytes(diagram_source) if isinstance(diagram_source, bytearray) else diagram_source - diagram_file = (visio_aws_with_tz_and_vpc, diagram_source, 'application/octet-stream') - mapping_file = ('default_mapping_file', open(default_visio_mapping, 'rb'), 'text/yaml') + diagram_file = (visio_aws_with_tz_and_vpc, diagram_source, octet_stream) + mapping_file = ('default_mapping_file', open(default_visio_mapping, 'rb'), yaml_mime) # When I do post on diagram endpoint files = {'diag_file': diagram_file, 'default_mapping_file': mapping_file} @@ -626,7 +300,7 @@ def test_response_on_invalid_diagram_file(self, diagram_source, detail): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'DiagramFileNotValidError' @@ -636,7 +310,7 @@ def test_response_on_invalid_diagram_file(self, diagram_source, detail): assert body_response['errors'][0]['errorMessage'] == detail @mark.parametrize('mapping_source,msg', [ - (f'small', 'Mapping file does not comply with the schema'), + ('small', 'Mapping file does not comply with the schema'), (b'', 'Mapping files are not valid. Invalid size'), (bytearray(4), 'Mapping files are not valid. Invalid size'), (bytearray(1024 * 1024 * 5 + 1), 'Mapping files are not valid. Invalid size') @@ -648,8 +322,8 @@ def test_response_on_invalid_mapping_file(self, mapping_source, msg): # And the request files mapping_source = bytes(mapping_source) if isinstance(mapping_source, bytearray) else mapping_source - diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), 'application/octet-stream') - mapping_file = ('default_mapping_file', mapping_source, 'text/yaml') + diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) + mapping_file = ('default_mapping_file', mapping_source, yaml_mime) # When I do post on diagram endpoint files = {'diag_file': diagram_file, 'default_mapping_file': mapping_file} @@ -658,7 +332,7 @@ def test_response_on_invalid_mapping_file(self, mapping_source, msg): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'MappingFileNotValidError' diff --git a/tests/integration/api/controllers/diagram/visio/test_otm_controller_diagram_visio.py b/tests/integration/api/controllers/diagram/visio/test_otm_controller_diagram_visio.py index b79095b5..4bc5a2fe 100644 --- a/tests/integration/api/controllers/diagram/visio/test_otm_controller_diagram_visio.py +++ b/tests/integration/api/controllers/diagram/visio/test_otm_controller_diagram_visio.py @@ -5,17 +5,16 @@ from fastapi.testclient import TestClient from pytest import mark +from sl_util.sl_util.file_utils import get_byte_data from slp_base.slp_base.errors import DiagramFileNotValidError, MappingFileNotValidError, LoadingMappingFileError, \ OTMResultError, OTMBuildingError, LoadingDiagramFileError -from slp_base.tests.util.otm import validate_and_compare_otm, validate_and_compare +from slp_base.tests.util.otm import validate_and_compare_otm from startleft.startleft.api import fastapi_server from startleft.startleft.api.controllers.diagram import diag_create_otm_controller from tests.resources import test_resource_paths from tests.resources.test_resource_paths import visio_aws_with_tz_and_vpc, default_visio_mapping, \ default_visio_mapping_legacy, custom_vpc_mapping, custom_vpc_mapping_legacy, \ - visio_create_otm_ok_only_default_mapping, visio_create_otm_ok_both_mapping_files - -IRIUSRISK_URL = '' + visio_create_otm_ok_only_default_mapping webapp = fastapi_server.webapp @@ -29,6 +28,8 @@ def get_url(): octet_stream = 'application/octet-stream' +json_mime = 'application/json' +yaml_mime = 'text/yaml' class TestOTMControllerDiagramVisio: @@ -39,45 +40,65 @@ def test_create_otm_ok_only_default_mapping(self, mapping): # Given a project_id project_id: str = 'project_A_id' + # And the source file + diag_file = get_byte_data(test_resource_paths.visio_aws_with_tz_and_vpc) + + # And the mapping file + mapping_file = get_byte_data(mapping) + + # And the expected otm + expected_otm = visio_create_otm_ok_only_default_mapping + # When I do post on diagram endpoint - files = {'diag_file': open(test_resource_paths.visio_aws_with_tz_and_vpc, 'rb'), - 'default_mapping_file': open(mapping, 'rb')} - body = {'diag_type': 'VISIO', 'id': f'{project_id}', 'name': 'project_A_name'} + files = {'diag_file': diag_file, + 'default_mapping_file': mapping_file} + body = {'diag_type': 'VISIO', 'id': project_id, 'name': 'project_A_name'} response = client.post(get_url(), files=files, data=body) # Then the OTM is returned inside the response as JSON assert response.status_code == diag_create_otm_controller.RESPONSE_STATUS_CODE - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime otm = json.loads(response.text) - result, expected = validate_and_compare_otm(otm, visio_create_otm_ok_only_default_mapping, VALIDATION_EXCLUDED_REGEX) + result, expected = validate_and_compare_otm(otm, expected_otm, VALIDATION_EXCLUDED_REGEX) assert result == expected - @mark.parametrize('default_mapping,custom_mapping', [ - (default_visio_mapping, custom_vpc_mapping), - (default_visio_mapping_legacy, custom_vpc_mapping_legacy), - (default_visio_mapping, custom_vpc_mapping_legacy), - (default_visio_mapping_legacy, custom_vpc_mapping), - ]) - @responses.activate - def test_create_otm_ok_both_mapping_files(self, default_mapping, custom_mapping): - # Given a project_id - project_id: str = 'project_A_id' - # When I do post on diagram endpoint - files = {'diag_file': open(visio_aws_with_tz_and_vpc, 'rb'), - 'default_mapping_file': open(default_mapping, 'rb'), - 'custom_mapping_file': open(custom_mapping, 'rb')} - body = {'diag_type': 'VISIO', 'id': f'{project_id}', 'name': 'project_A_name'} - response = client.post(get_url(), files=files, data=body) +@mark.parametrize('default_mapping,custom_mapping', [ + (default_visio_mapping, custom_vpc_mapping), + (default_visio_mapping_legacy, custom_vpc_mapping_legacy), + (default_visio_mapping, custom_vpc_mapping_legacy), + (default_visio_mapping_legacy, custom_vpc_mapping), +]) +@responses.activate +def test_create_otm_ok_both_mapping_files(self, default_mapping, custom_mapping): + # Given a project_id + project_id: str = 'test_parse_diagram_file_ok' - # Then the OTM is returned inside the response as JSON - assert response.status_code == diag_create_otm_controller.RESPONSE_STATUS_CODE - assert response.headers.get('content-type') == 'application/json' - otm = json.loads(response.text) + # And the source file + diag_file = get_byte_data(visio_aws_with_tz_and_vpc) - result, expected = validate_and_compare(otm, visio_create_otm_ok_both_mapping_files, VALIDATION_EXCLUDED_REGEX) - assert result == expected + # And the mapping files + mapping_file = get_byte_data(default_mapping) + custom_mapping_file = get_byte_data(custom_mapping) + + # And the expected otm + expected_otm = test_resource_paths.visio_aws_with_tz_and_vpc_otm_expected + + # When I do post on diagram endpoint + files = {'diag_file': diag_file, 'default_mapping_file': mapping_file, + 'custom_mapping_file': custom_mapping_file} + body = {'diag_type': 'VISIO', 'id': project_id, 'name': project_id} + response = client.post(get_url(), files=files, data=body) + + # Then the OTM is returned inside the response as JSON + assert response.status_code == diag_create_otm_controller.RESPONSE_STATUS_CODE + assert response.headers.get('content-type') == json_mime + otm = json.loads(response.text) + + # and the otm is as expected + result, expected = validate_and_compare_otm(otm, expected_otm, None) + assert result == expected @responses.activate @patch('slp_visio.slp_visio.validate.visio_validator.VisioValidator.validate') @@ -87,7 +108,7 @@ def test_response_on_validating_diagram_error(self, mock_load_source_data): # And the request files diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) - mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), 'text/yaml') + mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), yaml_mime) # And the mocked method throwing a DiagramFileNotValidError error = DiagramFileNotValidError('Invalid size', 'mocked error detail', 'mocked error msg 1') @@ -100,7 +121,7 @@ def test_response_on_validating_diagram_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'DiagramFileNotValidError' @@ -116,8 +137,8 @@ def test_response_on_loading_diagram_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), 'application/octet-stream') - mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), 'text/yaml') + diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) + mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingDiagramFileError error = LoadingDiagramFileError('mocked error title', 'mocked error detail', 'mocked error msg 1') @@ -130,7 +151,7 @@ def test_response_on_loading_diagram_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'LoadingDiagramFileError' @@ -146,8 +167,8 @@ def test_response_on_validating_mapping_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), 'application/octet-stream') - mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), 'text/yaml') + diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) + mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingDiagramFileError error = MappingFileNotValidError('Mapping file does not comply with the schema', 'Schema error', @@ -161,7 +182,7 @@ def test_response_on_validating_mapping_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'MappingFileNotValidError' @@ -177,8 +198,8 @@ def test_response_on_loading_mapping_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), 'application/octet-stream') - mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), 'text/yaml') + diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) + mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingDiagramFileError error = LoadingMappingFileError('Error loading the mapping file. The mapping file ins not valid.', @@ -192,7 +213,7 @@ def test_response_on_loading_mapping_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'LoadingMappingFileError' @@ -208,8 +229,8 @@ def test_response_on_otm_result_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), 'application/octet-stream') - mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), 'text/yaml') + diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) + mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingDiagramFileError error = OTMResultError('OTM file does not comply with the schema', 'Schema error', 'mocked error msg') @@ -222,7 +243,7 @@ def test_response_on_otm_result_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'OTMResultError' @@ -238,8 +259,8 @@ def test_response_on_otm_building_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), 'application/octet-stream') - mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), 'text/yaml') + diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) + mapping_file = (default_visio_mapping, open(default_visio_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingDiagramFileError error = OTMBuildingError('OTM building error', 'Schema error', 'mocked error msg') @@ -252,7 +273,7 @@ def test_response_on_otm_building_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'OTMBuildingError' @@ -274,8 +295,8 @@ def test_response_on_invalid_diagram_file(self, diagram_source, detail): # And the request files diagram_source = bytes(diagram_source) if isinstance(diagram_source, bytearray) else diagram_source - diagram_file = (visio_aws_with_tz_and_vpc, diagram_source, 'application/octet-stream') - mapping_file = ('default_mapping_file', open(default_visio_mapping, 'rb'), 'text/yaml') + diagram_file = (visio_aws_with_tz_and_vpc, diagram_source, octet_stream) + mapping_file = ('default_mapping_file', open(default_visio_mapping, 'rb'), yaml_mime) # When I do post on diagram endpoint files = {'diag_file': diagram_file, 'default_mapping_file': mapping_file} @@ -284,7 +305,7 @@ def test_response_on_invalid_diagram_file(self, diagram_source, detail): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'DiagramFileNotValidError' @@ -294,7 +315,7 @@ def test_response_on_invalid_diagram_file(self, diagram_source, detail): assert body_response['errors'][0]['errorMessage'] == detail @mark.parametrize('mapping_source,msg', [ - (f'small', 'Mapping file does not comply with the schema'), + ('small', 'Mapping file does not comply with the schema'), (b'', 'Mapping files are not valid. Invalid size'), (bytearray(4), 'Mapping files are not valid. Invalid size'), (bytearray(1024 * 1024 * 5 + 1), 'Mapping files are not valid. Invalid size') @@ -305,9 +326,9 @@ def test_response_on_invalid_mapping_file(self, mapping_source, msg): project_id: str = 'project_A_id' # And the request files - diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), 'application/octet-stream') + diagram_file = (visio_aws_with_tz_and_vpc, open(visio_aws_with_tz_and_vpc, 'rb'), octet_stream) mapping_source = bytes(mapping_source) if isinstance(mapping_source, bytearray) else mapping_source - mapping_file = ('default_mapping_file', mapping_source, 'text/yaml') + mapping_file = ('default_mapping_file', mapping_source, yaml_mime) # When I do post on diagram endpoint files = {'diag_file': diagram_file, 'default_mapping_file': mapping_file} @@ -316,7 +337,7 @@ def test_response_on_invalid_mapping_file(self, mapping_source, msg): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'MappingFileNotValidError' diff --git a/tests/integration/api/controllers/iac/cloudformation/test_otm_controller_iac_cloudformation.py b/tests/integration/api/controllers/iac/cloudformation/test_otm_controller_iac_cloudformation.py index 4da1a5b1..8765cc48 100644 --- a/tests/integration/api/controllers/iac/cloudformation/test_otm_controller_iac_cloudformation.py +++ b/tests/integration/api/controllers/iac/cloudformation/test_otm_controller_iac_cloudformation.py @@ -20,24 +20,27 @@ webapp = fastapi_server.webapp client = TestClient(webapp) +json_mime = 'application/json' + def get_url(): return iac_create_otm_controller.PREFIX + iac_create_otm_controller.URL +yaml_mime = 'text/yaml' + + class TestOTMControllerIaCCloudformation: cft_map = default_cloudformation_mapping wrong_id = cloudformation_malformed_mapping_wrong_id - app_json = 'application/json' - text_yaml = 'text/yaml' - uc_a = (None, 'proj A', example_json, app_json, cft_map, 'RequestValidationError') - uc_b = ('proj_B', None, example_json, app_json, cft_map, 'RequestValidationError') + uc_a = (None, 'proj A', example_json, json_mime, cft_map, 'RequestValidationError') + uc_b = ('proj_B', None, example_json, json_mime, cft_map, 'RequestValidationError') uc_c = ('proj_C', 'proj C', None, None, cft_map, 'RequestValidationError') - uc_d = ('proj_D', 'proj D', example_json, app_json, None, 'RequestValidationError') - uc_e = ('proj_E', 'proj E', example_json, app_json, wrong_id, 'MappingFileNotValidError') + uc_d = ('proj_D', 'proj D', example_json, json_mime, None, 'RequestValidationError') + uc_e = ('proj_E', 'proj E', example_json, json_mime, wrong_id, 'MappingFileNotValidError') uc_f = ('proj_F', 'proj F', None, None, None, 'RequestValidationError') uc_h = ('proj_H', 'proj H', invalid_yaml, '', cft_map, 'IacFileNotValidError') - uc_i = ('proj_I', 'proj I', invalid_yaml, text_yaml, cft_map, 'OTMBuildingError') + uc_i = ('proj_I', 'proj I', invalid_yaml, yaml_mime, cft_map, 'OTMBuildingError') uc_j = ('proj_J', 'proj J', invalid_yaml, None, cft_map, 'OTMBuildingError') uc_k = ('proj_K', 'proj K', cloudformation_gz, None, cft_map, 'IacFileNotValidError') uc_l = ('proj_L', 'proj L', visio_aws_shapes, None, cft_map, 'IacFileNotValidError') @@ -48,8 +51,8 @@ def test_create_otm_ok(self): project_id: str = 'project_A_id' # And the request files - iac_file = (example_json, open(example_json, 'rb'), 'application/json') - mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), 'text/yaml') + iac_file = (example_json, open(example_json, 'rb'), json_mime) + mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), yaml_mime) # When I do post on cloudformation endpoint files = {'iac_file': iac_file, 'mapping_file': mapping_file} @@ -58,12 +61,17 @@ def test_create_otm_ok(self): # Then the OTM is returned inside the response as JSON assert response.status_code == iac_create_otm_controller.RESPONSE_STATUS_CODE - assert response.headers.get('content-type') == 'application/json' - assert '"otmVersion": "0.1.0"' in response.text - assert '"project": ' in response.text - assert '"name": "project_A_name"' in response.text - assert '"trustZones": ' in response.text - assert '"components": ' in response.text + assert response.headers.get('content-type') == json_mime + + # And the otm is as expected + otm = json.loads(response.text) + assert otm['otmVersion'] == '0.2.0' + assert otm['project']['id'] == 'project_A_id' + assert otm['project']['name'] == 'project_A_name' + assert otm['project']['name'] == 'project_A_name' + assert len(otm['trustZones']) == 1 + assert len(otm['components']) == 5 + assert len(otm['dataflows']) == 0 @mark.parametrize('project_id,project_name,cft_filename,cft_mimetype,mapping_filename,error_type', [uc_a, uc_b, uc_c, uc_d, uc_e, uc_f, uc_h, uc_i, uc_j, uc_k]) @@ -77,14 +85,14 @@ def test_create_project_validation_error(self, project_id: str, project_name: st if cft_filename: files['iac_file'] = (cft_filename, open(cft_filename, 'rb'), cft_mimetype) if mapping_filename: - files['mapping_file'] = (mapping_filename, open(mapping_filename, 'rb'), 'text/yaml') + files['mapping_file'] = (mapping_filename, open(mapping_filename, 'rb'), yaml_mime) # When I do post on cloudformation endpoint response = client.post(get_url(), files=files, data=body) # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers['content-type'] == 'application/json' + assert response.headers['content-type'] == json_mime res_body = json.loads(response.content.decode('utf-8')) assert res_body['status'] == '400' assert res_body['error_type'] == error_type @@ -96,8 +104,8 @@ def test_response_on_validating_iac_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - iac_file = (example_json, open(example_json, 'rb'), 'application/json') - mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), 'text/yaml') + iac_file = (example_json, open(example_json, 'rb'), json_mime) + mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingIacFileError error = IacFileNotValidError('Invalid size', 'mocked error detail', 'mocked error msg 1') @@ -110,7 +118,7 @@ def test_response_on_validating_iac_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'IacFileNotValidError' @@ -126,8 +134,8 @@ def test_response_on_loading_iac_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - iac_file = (example_json, open(example_json, 'rb'), 'application/json') - mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), 'text/yaml') + iac_file = (example_json, open(example_json, 'rb'), json_mime) + mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingIacFileError error = LoadingIacFileError('mocked error title', 'mocked error detail', 'mocked error msg 1') @@ -140,7 +148,7 @@ def test_response_on_loading_iac_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'LoadingIacFileError' @@ -156,8 +164,8 @@ def test_response_on_validating_mapping_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - iac_file = (example_json, open(example_json, 'rb'), 'application/json') - mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), 'text/yaml') + iac_file = (example_json, open(example_json, 'rb'), json_mime) + mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingIacFileError error = MappingFileNotValidError('Mapping file does not comply with the schema', 'Schema error', @@ -171,7 +179,7 @@ def test_response_on_validating_mapping_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'MappingFileNotValidError' @@ -187,8 +195,8 @@ def test_response_on_loading_mapping_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - iac_file = (example_json, open(example_json, 'rb'), 'application/json') - mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), 'text/yaml') + iac_file = (example_json, open(example_json, 'rb'), json_mime) + mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingIacFileError error = LoadingMappingFileError('Error loading the mapping file. The mapping file ins not valid.', @@ -202,7 +210,7 @@ def test_response_on_loading_mapping_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'LoadingMappingFileError' @@ -218,8 +226,8 @@ def test_response_on_otm_result_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - iac_file = (example_json, open(example_json, 'rb'), 'application/json') - mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), 'text/yaml') + iac_file = (example_json, open(example_json, 'rb'), json_mime) + mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingIacFileError error = OTMResultError('OTM file does not comply with the schema', 'Schema error', 'mocked error msg') @@ -232,7 +240,7 @@ def test_response_on_otm_result_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'OTMResultError' @@ -248,8 +256,8 @@ def test_response_on_otm_building_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - iac_file = (example_json, open(example_json, 'rb'), 'application/json') - mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), 'text/yaml') + iac_file = (example_json, open(example_json, 'rb'), json_mime) + mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), yaml_mime) # And the mocked method throwing a LoadingIacFileError error = OTMBuildingError('OTM building error', 'Schema error', 'mocked error msg') @@ -262,7 +270,7 @@ def test_response_on_otm_building_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'OTMBuildingError' @@ -283,8 +291,8 @@ def test_response_on_invalid_iac_file(self, iac_source, detail): # And the request files iac_source = bytes(iac_source) if isinstance(iac_source, bytearray) else iac_source - iac_file = (example_json, iac_source, 'application/json') - mapping_file = ('mapping_file', open(default_cloudformation_mapping, 'rb'), 'text/yaml') + iac_file = (example_json, iac_source, json_mime) + mapping_file = ('mapping_file', open(default_cloudformation_mapping, 'rb'), yaml_mime) # When I do post on cloudformation endpoint files = {'iac_file': iac_file, 'mapping_file': mapping_file} @@ -293,7 +301,7 @@ def test_response_on_invalid_iac_file(self, iac_source, detail): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'IacFileNotValidError' @@ -303,7 +311,7 @@ def test_response_on_invalid_iac_file(self, iac_source, detail): assert body_response['errors'][0]['errorMessage'] == detail @mark.parametrize('mapping_source,msg', [ - (f'small', 'Mapping file does not comply with the schema'), + ('small', 'Mapping file does not comply with the schema'), (b'', 'Mapping files are not valid. Invalid size'), (bytearray(4), 'Mapping files are not valid. Invalid size'), (bytearray(1024 * 1024 * 5 + 1), 'Mapping files are not valid. Invalid size') @@ -314,9 +322,9 @@ def test_response_on_invalid_mapping_file(self, mapping_source, msg): project_id: str = 'project_A_id' # And the request files - iac_file = (example_json, example_json, 'application/json') + iac_file = (example_json, example_json, json_mime) mapping_source = bytes(mapping_source) if isinstance(mapping_source, bytearray) else mapping_source - mapping_file = ('mapping_file', mapping_source, 'text/yaml') + mapping_file = ('mapping_file', mapping_source, yaml_mime) # When I do post on cloudformation endpoint files = {'iac_file': iac_file, 'mapping_file': mapping_file} @@ -325,7 +333,7 @@ def test_response_on_invalid_mapping_file(self, mapping_source, msg): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'MappingFileNotValidError' @@ -339,23 +347,24 @@ def test_mapping_file_cloudformation_all_functions(self): project_id: str = 'project_A_id' # And the request files, containing a mapping file with all cloudformation functions - iac_file = (cloudformation_all_functions, open(cloudformation_all_functions, 'rb'), 'application/json') + iac_file = (cloudformation_all_functions, open(cloudformation_all_functions, 'rb'), json_mime) mapping_file = ( - cloudformation_mapping_all_functions, open(cloudformation_mapping_all_functions, 'rb'), 'text/yaml') + cloudformation_mapping_all_functions, open(cloudformation_mapping_all_functions, 'rb'), yaml_mime) # When I do post on cloudformation endpoint files = {'iac_file': iac_file, 'mapping_file': mapping_file} body = {'iac_type': TESTING_IAC_TYPE, 'id': f'{project_id}', 'name': 'project_A_name'} response = client.post(get_url(), files=files, data=body) - # Then the OTM is returned without errors inside the response as JSON - assert response.status_code == iac_create_otm_controller.RESPONSE_STATUS_CODE - assert response.headers.get('content-type') == 'application/json' - assert '"otmVersion": "0.1.0"' in response.text - assert '"project": ' in response.text - assert '"name": "project_A_name"' in response.text - assert '"trustZones": ' in response.text - assert '"components": ' in response.text + # And the otm is as expected + otm = json.loads(response.text) + assert otm['otmVersion'] == '0.2.0' + assert otm['project']['id'] == 'project_A_id' + assert otm['project']['name'] == 'project_A_name' + assert otm['project']['name'] == 'project_A_name' + assert len(otm['trustZones']) == 1 + assert len(otm['components']) == 5 + assert len(otm['dataflows']) == 0 # And all the expected components are mapped assert len(json.loads(response.text)["components"]) == 5 @@ -368,11 +377,11 @@ def test_create_otm_multiple_files_ok(self): # And the request files, two definition files, and one mapping file iac_file_networks = ( cloudformation_multiple_files_networks, open(cloudformation_multiple_files_networks, 'rb'), - 'application/json') + json_mime) iac_file_resources = ( cloudformation_multiple_files_resources, open(cloudformation_multiple_files_resources, 'rb'), - 'application/json') - mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), 'text/yaml') + json_mime) + mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), yaml_mime) # When I do post on cloudformation endpoint files = [('iac_file', iac_file_networks), ('iac_file', iac_file_resources), ('mapping_file', mapping_file)] @@ -381,15 +390,17 @@ def test_create_otm_multiple_files_ok(self): # Then the OTM is returned inside the response as JSON assert response.status_code == iac_create_otm_controller.RESPONSE_STATUS_CODE - assert response.headers.get('content-type') == 'application/json' - assert '"otmVersion": "0.1.0"' in response.text - assert '"project": ' in response.text - assert '"name": "project_A_name"' in response.text - assert '"trustZones": ' in response.text - assert '"components": ' in response.text + assert response.headers.get('content-type') == json_mime - # And all the expected components are mapped (5 from networks, 17 from resources) - assert len(json.loads(response.text)["components"]) == 22 + # And the otm is as expected + otm = json.loads(response.text) + assert otm['otmVersion'] == '0.2.0' + assert otm['project']['id'] == 'project_A_id' + assert otm['project']['name'] == 'project_A_name' + assert otm['project']['name'] == 'project_A_name' + assert len(otm['trustZones']) == 2 + assert len(otm['components']) == 22 + assert len(otm['dataflows']) == 22 @responses.activate def test_create_otm_multiple_files_on_validating_iac_error(self): @@ -399,9 +410,9 @@ def test_create_otm_multiple_files_on_validating_iac_error(self): # And the request files, two definition files, and one mapping file iac_file_valid = ( cloudformation_multiple_files_networks, open(cloudformation_multiple_files_networks, 'rb'), - 'application/json') + json_mime) iac_file_invalid = '' - mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), 'text/yaml') + mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), yaml_mime) # When I do post on cloudformation endpoint files = [('iac_file', iac_file_valid), ('iac_file', iac_file_invalid), ('mapping_file', mapping_file)] @@ -410,7 +421,7 @@ def test_create_otm_multiple_files_on_validating_iac_error(self): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers['content-type'] == 'application/json' + assert response.headers['content-type'] == json_mime res_body = json.loads(response.content.decode('utf-8')) assert res_body['status'] == '400' assert res_body['error_type'] == 'IacFileNotValidError' @@ -423,8 +434,8 @@ def test_yaml_ref_function_is_parsed(self, filename): project_name: str = 'project_A_name' # And the request files - iac_file = (filename, open(filename, 'rb'), 'text/yaml') - mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), 'text/yaml') + iac_file = (filename, open(filename, 'rb'), yaml_mime) + mapping_file = (default_cloudformation_mapping, open(default_cloudformation_mapping, 'rb'), yaml_mime) # When I do post on cloudformation endpoint files = {'iac_file': iac_file, 'mapping_file': mapping_file} diff --git a/tests/integration/api/controllers/iac/terraform/test_otm_controller_iac_terraform.py b/tests/integration/api/controllers/iac/terraform/test_otm_controller_iac_terraform.py index c6948ac3..27b7734d 100644 --- a/tests/integration/api/controllers/iac/terraform/test_otm_controller_iac_terraform.py +++ b/tests/integration/api/controllers/iac/terraform/test_otm_controller_iac_terraform.py @@ -21,6 +21,9 @@ webapp = fastapi_server.webapp client = TestClient(webapp) +json_mime = 'application/json' +yaml_mime = 'text/yaml' + def get_url(): return iac_create_otm_controller.PREFIX + iac_create_otm_controller.URL @@ -30,16 +33,14 @@ class TestOTMControllerIaCTerraform: tf_file = terraform_aws_simple_components tf_map = terraform_iriusrisk_tf_aws_mapping wrong_id = terraform_malformed_mapping_wrong_id - app_json = 'application/json' - text_yaml = 'text/yaml' - uc_a = (None, 'proj A', tf_file, app_json, tf_map, 'RequestValidationError') - uc_b = ('proj_B', None, tf_file, app_json, tf_map, 'RequestValidationError') + uc_a = (None, 'proj A', tf_file, json_mime, tf_map, 'RequestValidationError') + uc_b = ('proj_B', None, tf_file, json_mime, tf_map, 'RequestValidationError') uc_c = ('proj_C', 'proj C', None, None, tf_map, 'RequestValidationError') - uc_d = ('proj_D', 'proj D', tf_file, app_json, None, 'RequestValidationError') - uc_e = ('proj_E', 'proj E', tf_file, app_json, wrong_id, 'MappingFileNotValidError') + uc_d = ('proj_D', 'proj D', tf_file, json_mime, None, 'RequestValidationError') + uc_e = ('proj_E', 'proj E', tf_file, json_mime, wrong_id, 'MappingFileNotValidError') uc_f = ('proj_F', 'proj F', None, None, None, 'RequestValidationError') uc_h = ('proj_H', 'proj H', invalid_tf, '', tf_map, 'IacFileNotValidError') - uc_i = ('proj_I', 'proj I', invalid_tf, text_yaml, tf_map, 'IacFileNotValidError') + uc_i = ('proj_I', 'proj I', invalid_tf, yaml_mime, tf_map, 'IacFileNotValidError') uc_j = ('proj_J', 'proj J', invalid_tf, None, tf_map, 'LoadingIacFileError') uc_k = ('proj_K', 'proj K', terraform_gz, None, tf_map, 'IacFileNotValidError') uc_l = ('proj_L', 'proj L', visio_aws_shapes, None, tf_map, 'IacFileNotValidError') @@ -55,8 +56,8 @@ def test_create_otm_ok_all_line_breaks(self, filename: str, break_line: str): project_id: str = 'project_A_id' # And the request files - iac_file = (filename, open(filename, 'rb'), 'application/json') - mapping_file = (terraform_iriusrisk_tf_aws_mapping, open(terraform_iriusrisk_tf_aws_mapping, 'rb'), 'text/yaml') + iac_file = (filename, open(filename, 'rb'), json_mime) + mapping_file = (terraform_iriusrisk_tf_aws_mapping, open(terraform_iriusrisk_tf_aws_mapping, 'rb'), yaml_mime) # And the iac_data with custom line breaks iac_data = file_utils.get_byte_data(filename).decode().replace('\n', break_line) @@ -71,12 +72,17 @@ def test_create_otm_ok_all_line_breaks(self, filename: str, break_line: str): # And the OTM is returned inside the response as JSON assert response.status_code == iac_create_otm_controller.RESPONSE_STATUS_CODE - assert response.headers.get('content-type') == 'application/json' - assert '"otmVersion": "0.1.0"' in response.text - assert '"project": ' in response.text - assert '"name": "project_A_name"' in response.text - assert '"trustZones": ' in response.text - assert '"components": ' in response.text + assert response.headers.get('content-type') == json_mime + + # And the otm is as expected + otm = json.loads(response.text) + assert otm['otmVersion'] == '0.2.0' + assert otm['project']['id'] == 'project_A_id' + assert otm['project']['name'] == 'project_A_name' + assert otm['project']['name'] == 'project_A_name' + assert len(otm['trustZones']) == 1 + assert len(otm['components']) == 20 + assert len(otm['dataflows']) == 0 @mark.parametrize('project_id,project_name,cft_filename,cft_mimetype,mapping_filename,error_type', [uc_a, uc_b, uc_c, uc_d, uc_e, uc_f, uc_h, uc_i, uc_j, uc_k]) @@ -90,14 +96,14 @@ def test_create_project_validation_error(self, project_id: str, project_name: st if cft_filename: files['iac_file'] = (cft_filename, open(cft_filename, 'rb'), cft_mimetype) if mapping_filename: - files['mapping_file'] = (mapping_filename, open(mapping_filename, 'rb'), 'text/yaml') + files['mapping_file'] = (mapping_filename, open(mapping_filename, 'rb'), yaml_mime) # When I do post on TERRAFORM endpoint response = client.post(get_url(), files=files, data=body) # Then assert response.status_code == 400 - assert response.headers['content-type'] == 'application/json' + assert response.headers['content-type'] == json_mime res_body = json.loads(response.content.decode('utf-8')) assert res_body['status'] == '400' assert res_body['error_type'] == error_type @@ -109,8 +115,8 @@ def test_response_on_validating_iac_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - iac_file = (self.tf_file, open(self.tf_file, 'rb'), 'application/json') - mapping_file = (self.tf_map, open(self.tf_map, 'rb'), 'text/yaml') + iac_file = (self.tf_file, open(self.tf_file, 'rb'), json_mime) + mapping_file = (self.tf_map, open(self.tf_map, 'rb'), yaml_mime) # And the mocked method throwing a LoadingIacFileError error = IacFileNotValidError('Invalid size', 'mocked error detail', 'mocked error msg 1') @@ -123,7 +129,7 @@ def test_response_on_validating_iac_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'IacFileNotValidError' @@ -139,8 +145,8 @@ def test_response_on_loading_iac_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - iac_file = (self.tf_file, open(self.tf_file, 'rb'), 'application/json') - mapping_file = (self.tf_map, open(self.tf_map, 'rb'), 'text/yaml') + iac_file = (self.tf_file, open(self.tf_file, 'rb'), json_mime) + mapping_file = (self.tf_map, open(self.tf_map, 'rb'), yaml_mime) # And the mocked method throwing a LoadingIacFileError error = LoadingIacFileError('mocked error title', 'mocked error detail', 'mocked error msg 1') @@ -153,7 +159,7 @@ def test_response_on_loading_iac_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'LoadingIacFileError' @@ -169,8 +175,8 @@ def test_response_on_validating_mapping_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - iac_file = (self.tf_file, open(self.tf_file, 'rb'), 'application/json') - mapping_file = (self.tf_map, open(self.tf_map, 'rb'), 'text/yaml') + iac_file = (self.tf_file, open(self.tf_file, 'rb'), json_mime) + mapping_file = (self.tf_map, open(self.tf_map, 'rb'), yaml_mime) # And the mocked method throwing a LoadingIacFileError error = MappingFileNotValidError('Mapping file does not comply with the schema', 'Schema error', @@ -184,7 +190,7 @@ def test_response_on_validating_mapping_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'MappingFileNotValidError' @@ -200,8 +206,8 @@ def test_response_on_loading_mapping_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - iac_file = (self.tf_file, open(self.tf_file, 'rb'), 'application/json') - mapping_file = (self.tf_map, open(self.tf_map, 'rb'), 'text/yaml') + iac_file = (self.tf_file, open(self.tf_file, 'rb'), json_mime) + mapping_file = (self.tf_map, open(self.tf_map, 'rb'), yaml_mime) # And the mocked method throwing a LoadingIacFileError error = LoadingMappingFileError('Error loading the mapping file. The mapping file ins not valid.', @@ -215,7 +221,7 @@ def test_response_on_loading_mapping_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'LoadingMappingFileError' @@ -231,8 +237,8 @@ def test_response_on_otm_result_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - iac_file = (self.tf_file, open(self.tf_file, 'rb'), 'application/json') - mapping_file = (self.tf_map, open(self.tf_map, 'rb'), 'text/yaml') + iac_file = (self.tf_file, open(self.tf_file, 'rb'), json_mime) + mapping_file = (self.tf_map, open(self.tf_map, 'rb'), yaml_mime) # And the mocked method throwing a LoadingIacFileError error = OTMResultError('OTM file does not comply with the schema', 'Schema error', 'mocked error msg') @@ -245,7 +251,7 @@ def test_response_on_otm_result_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'OTMResultError' @@ -261,8 +267,8 @@ def test_response_on_otm_building_error(self, mock_load_source_data): project_id: str = 'project_A_id' # And the request files - iac_file = (self.tf_file, open(self.tf_file, 'rb'), 'application/json') - mapping_file = (self.tf_map, open(self.tf_map, 'rb'), 'text/yaml') + iac_file = (self.tf_file, open(self.tf_file, 'rb'), json_mime) + mapping_file = (self.tf_map, open(self.tf_map, 'rb'), yaml_mime) # And the mocked method throwing a LoadingIacFileError error = OTMBuildingError('OTM building error', 'Schema error', 'mocked error msg') @@ -275,7 +281,7 @@ def test_response_on_otm_building_error(self, mock_load_source_data): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'OTMBuildingError' @@ -295,8 +301,8 @@ def test_response_on_invalid_iac_file(self, iac_source, detail): # And the request files iac_source = bytes(iac_source) if isinstance(iac_source, bytearray) else iac_source - iac_file = (self.tf_file, iac_source, 'application/json') - mapping_file = ('mapping_file', open(self.tf_map, 'rb'), 'text/yaml') + iac_file = (self.tf_file, iac_source, json_mime) + mapping_file = ('mapping_file', open(self.tf_map, 'rb'), yaml_mime) # When I do post on terraform endpoint files = {'iac_file': iac_file, 'mapping_file': mapping_file} @@ -305,7 +311,7 @@ def test_response_on_invalid_iac_file(self, iac_source, detail): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'IacFileNotValidError' @@ -315,7 +321,7 @@ def test_response_on_invalid_iac_file(self, iac_source, detail): assert body_response['errors'][0]['errorMessage'] == detail @mark.parametrize('mapping_source,msg', [ - (f'small', 'Mapping file does not comply with the schema'), + ('small', 'Mapping file does not comply with the schema'), (b'', 'Mapping files are not valid. Invalid size'), (bytearray(4), 'Mapping files are not valid. Invalid size'), (bytearray(1024 * 1024 * 5 + 1), 'Mapping files are not valid. Invalid size') @@ -326,9 +332,9 @@ def test_response_on_invalid_mapping_file(self, mapping_source, msg): project_id: str = 'project_A_id' # And the request files - iac_file = (self.tf_file, open(self.tf_file, 'rb'), 'application/json') + iac_file = (self.tf_file, open(self.tf_file, 'rb'), json_mime) mapping_source = bytes(mapping_source) if isinstance(mapping_source, bytearray) else mapping_source - mapping_file = ('mapping_file', mapping_source, 'text/yaml') + mapping_file = ('mapping_file', mapping_source, yaml_mime) # When I do post on terraform endpoint files = {'iac_file': iac_file, 'mapping_file': mapping_file} @@ -337,7 +343,7 @@ def test_response_on_invalid_mapping_file(self, mapping_source, msg): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers.get('content-type') == 'application/json' + assert response.headers.get('content-type') == json_mime body_response = json.loads(response.text) assert body_response['status'] == '400' assert body_response['error_type'] == 'MappingFileNotValidError' @@ -351,9 +357,9 @@ def test_mapping_file_terraform_specific_functions(self): project_id: str = 'project_A_id' # And the request files, containing a mapping file with all terraform specific functions - iac_file = (terraform_specific_functions, open(terraform_specific_functions, 'rb'), 'application/json') + iac_file = (terraform_specific_functions, open(terraform_specific_functions, 'rb'), json_mime) mapping_file = ( - terraform_mapping_specific_functions, open(terraform_mapping_specific_functions, 'rb'), 'text/yaml') + terraform_mapping_specific_functions, open(terraform_mapping_specific_functions, 'rb'), yaml_mime) # When I do post on terraform endpoint files = {'iac_file': iac_file, 'mapping_file': mapping_file} @@ -362,15 +368,17 @@ def test_mapping_file_terraform_specific_functions(self): # Then the OTM is returned without errors inside the response as JSON assert response.status_code == iac_create_otm_controller.RESPONSE_STATUS_CODE - assert response.headers.get('content-type') == 'application/json' - assert '"otmVersion": "0.1.0"' in response.text - assert '"project": ' in response.text - assert '"name": "project_A_name"' in response.text - assert '"trustZones": ' in response.text - assert '"components": ' in response.text - - # And all the expected components are mapped - assert len(json.loads(response.text)["components"]) == 3 + assert response.headers.get('content-type') == json_mime + + # And the otm is as expected + otm = json.loads(response.text) + assert otm['otmVersion'] == '0.2.0' + assert otm['project']['id'] == 'project_A_id' + assert otm['project']['name'] == 'project_A_name' + assert otm['project']['name'] == 'project_A_name' + assert len(otm['trustZones']) == 1 + assert len(otm['components']) == 3 + assert len(otm['dataflows']) == 0 @responses.activate def test_create_otm_multiple_files_ok(self): @@ -380,11 +388,11 @@ def test_create_otm_multiple_files_ok(self): # And the request files, two definition files, and one mapping file iac_file_one = ( terraform_multiple_files_one, open(terraform_multiple_files_one, 'rb'), - 'application/json') + json_mime) iac_file_two = ( terraform_multiple_files_two, open(terraform_multiple_files_two, 'rb'), - 'application/json') - mapping_file = (terraform_iriusrisk_tf_aws_mapping, open(terraform_iriusrisk_tf_aws_mapping, 'rb'), 'text/yaml') + json_mime) + mapping_file = (terraform_iriusrisk_tf_aws_mapping, open(terraform_iriusrisk_tf_aws_mapping, 'rb'), yaml_mime) # When I do post on terraform endpoint files = [('iac_file', iac_file_one), ('iac_file', iac_file_two), ('mapping_file', mapping_file)] @@ -393,12 +401,17 @@ def test_create_otm_multiple_files_ok(self): # Then the OTM is returned inside the response as JSON assert response.status_code == iac_create_otm_controller.RESPONSE_STATUS_CODE - assert response.headers.get('content-type') == 'application/json' - assert '"otmVersion": "0.1.0"' in response.text - assert '"project": ' in response.text - assert '"name": "project_A_name"' in response.text - assert '"trustZones": ' in response.text - assert '"components": ' in response.text + assert response.headers.get('content-type') == json_mime + + # And the otm is as expected + otm = json.loads(response.text) + assert otm['otmVersion'] == '0.2.0' + assert otm['project']['id'] == 'project_A_id' + assert otm['project']['name'] == 'project_A_name' + assert otm['project']['name'] == 'project_A_name' + assert len(otm['trustZones']) == 1 + assert len(otm['components']) == 12 + assert len(otm['dataflows']) == 5 # And all the expected components are mapped (3 from first, 28 from second) assert len(json.loads(response.text)["components"]) == 12 @@ -411,9 +424,9 @@ def test_create_otm_multiple_files_on_validating_iac_error(self): # And the request files, two definition files, and one mapping file iac_file_valid = ( terraform_multiple_files_one, open(terraform_multiple_files_one, 'rb'), - 'application/json') + json_mime) iac_file_invalid = '' - mapping_file = (terraform_iriusrisk_tf_aws_mapping, open(terraform_iriusrisk_tf_aws_mapping, 'rb'), 'text/yaml') + mapping_file = (terraform_iriusrisk_tf_aws_mapping, open(terraform_iriusrisk_tf_aws_mapping, 'rb'), yaml_mime) files = [('iac_file', iac_file_valid), ('iac_file', iac_file_invalid), ('mapping_file', mapping_file)] body = {'iac_type': TESTING_IAC_TYPE, 'id': f'{project_id}', 'name': 'project_A_name'} @@ -421,7 +434,7 @@ def test_create_otm_multiple_files_on_validating_iac_error(self): # Then the error is returned inside the response as JSON assert response.status_code == 400 - assert response.headers['content-type'] == 'application/json' + assert response.headers['content-type'] == json_mime res_body = json.loads(response.content.decode('utf-8')) assert res_body['status'] == '400' assert res_body['error_type'] == 'IacFileNotValidError' diff --git a/tests/resources/cloudformation/cloudformation_for_mappings_tests.otm b/tests/resources/cloudformation/cloudformation_for_mappings_tests.otm index 92f97018..4f5ea62f 100644 --- a/tests/resources/cloudformation/cloudformation_for_mappings_tests.otm +++ b/tests/resources/cloudformation/cloudformation_for_mappings_tests.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/tests/resources/lucid/lucid-aws-with-tz-and-vpc.otm b/tests/resources/lucid/lucid-aws-with-tz-and-vpc.otm index 17be6f3d..26c9f4bf 100644 --- a/tests/resources/lucid/lucid-aws-with-tz-and-vpc.otm +++ b/tests/resources/lucid/lucid-aws-with-tz-and-vpc.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "test_parse_diagram_file_ok", "id": "test_parse_diagram_file_ok" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "1", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -39,7 +40,8 @@ ] }, { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "5", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -61,7 +63,8 @@ ] }, { - "id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", + "id": "36", + "type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", "name": "Internet", "risk": { "trustRating": 10 @@ -89,7 +92,7 @@ "name": "Custom VPC", "type": "empty-component", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -135,7 +138,7 @@ "name": "My CloudWatch", "type": "cloudwatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -158,7 +161,7 @@ "name": "My API Gateway", "type": "api-gateway", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -181,7 +184,7 @@ "name": "My CloudTrail", "type": "cloudtrail", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -204,7 +207,7 @@ "name": "My Simple Storage Service (S3)", "type": "s3", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -227,7 +230,7 @@ "name": "Web browser", "type": "generic-client", "parent": { - "trustZone": "f0ba7722-39b6-4c81-8290-a30a248bb8d9" + "trustZone": "36" }, "representations": [ { @@ -250,7 +253,7 @@ "name": "Android", "type": "android-device-client", "parent": { - "trustZone": "f0ba7722-39b6-4c81-8290-a30a248bb8d9" + "trustZone": "36" }, "representations": [ { @@ -273,7 +276,7 @@ "name": "SQL Database", "type": "CD-MICROSOFT-AZURE-SQL-DB", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "5" }, "representations": [ { @@ -296,7 +299,7 @@ "name": "My DynamoDB", "type": "dynamodb", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "5" }, "representations": [ { @@ -342,13 +345,13 @@ }, { "id": "43", - "name": "2114ddb1-f677-4275-a9a2-0b2ac8e11073", + "name": "b8161949-a8ba-4a30-b409-9547dfb51740", "source": "38", "destination": "17" }, { "id": "46", - "name": "f58ee066-de2c-4464-9ceb-117b5dfa2703", + "name": "6ceb010f-8390-4dc5-943b-62d268c34e78", "source": "44", "destination": "17" }, diff --git a/tests/resources/lucid/lucid-aws-with-tz-default.otm b/tests/resources/lucid/lucid-aws-with-tz-default.otm index 97e959e6..cb0cf751 100644 --- a/tests/resources/lucid/lucid-aws-with-tz-default.otm +++ b/tests/resources/lucid/lucid-aws-with-tz-default.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "test_parse_diagram_file_ok", "id": "test_parse_diagram_file_ok" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "1", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -39,7 +40,8 @@ ] }, { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "5", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -59,6 +61,30 @@ } } ] + }, + { + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "name": "Public Cloud", + "risk": { + "trustRating": 10 + }, + "representations": [ + { + "name": "Public Cloud Representation", + "id": "804b664a-7129-4a9e-a08c-16a99669f605-representation", + "representation": "test_parse_diagram_file_ok-diagram", + "size": { + "width": 142, + "height": 140 + }, + "position": { + "x": 394, + "y": 626 + } + } + ], + "attributes": {"default": true} } ], "components": [ @@ -67,7 +93,7 @@ "name": "My EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -90,7 +116,7 @@ "name": "My CloudWatch", "type": "cloudwatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -113,7 +139,7 @@ "name": "My API Gateway", "type": "api-gateway", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -136,7 +162,7 @@ "name": "My CloudTrail", "type": "cloudtrail", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -159,7 +185,7 @@ "name": "My Simple Storage Service (S3)", "type": "s3", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -182,7 +208,7 @@ "name": "Web browser", "type": "generic-client", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -205,7 +231,7 @@ "name": "SQL Database", "type": "CD-MICROSOFT-AZURE-SQL-DB", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "5" }, "representations": [ { @@ -228,7 +254,7 @@ "name": "My DynamoDB", "type": "other-database", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "5" }, "representations": [ { diff --git a/tests/resources/lucid/lucid-aws-with-tz.otm b/tests/resources/lucid/lucid-aws-with-tz.otm index c8af2cdd..76c4c1b4 100644 --- a/tests/resources/lucid/lucid-aws-with-tz.otm +++ b/tests/resources/lucid/lucid-aws-with-tz.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "test_parse_diagram_file_ok", "id": "test_parse_diagram_file_ok" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "1", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -39,7 +40,8 @@ ] }, { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "5", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -61,7 +63,8 @@ ] }, { - "id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", + "id": "34", + "type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9", "name": "Internet", "risk": { "trustRating": 10 @@ -89,7 +92,7 @@ "name": "My EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -112,7 +115,7 @@ "name": "My CloudWatch", "type": "cloudwatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -135,7 +138,7 @@ "name": "My API Gateway", "type": "api-gateway", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -158,7 +161,7 @@ "name": "My CloudTrail", "type": "cloudtrail", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -181,7 +184,7 @@ "name": "My Simple Storage Service (S3)", "type": "s3", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "1" }, "representations": [ { @@ -204,7 +207,7 @@ "name": "Web browser", "type": "generic-client", "parent": { - "trustZone": "f0ba7722-39b6-4c81-8290-a30a248bb8d9" + "trustZone": "34" }, "representations": [ { @@ -227,7 +230,7 @@ "name": "Android", "type": "android-device-client", "parent": { - "trustZone": "f0ba7722-39b6-4c81-8290-a30a248bb8d9" + "trustZone": "34" }, "representations": [ { @@ -250,7 +253,7 @@ "name": "SQL Database", "type": "CD-MICROSOFT-AZURE-SQL-DB", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "5" }, "representations": [ { @@ -273,7 +276,7 @@ "name": "My DynamoDB", "type": "dynamodb", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "5" }, "representations": [ { @@ -319,13 +322,13 @@ }, { "id": "41", - "name": "b0059921-bdba-4a1d-bdd5-f672636e9af3", + "name": "ee05d7f5-451f-4b00-9dd9-971033a576c0", "source": "36", "destination": "15" }, { "id": "44", - "name": "637b85b3-1a0f-4648-a519-ada47d7192ef", + "name": "3491f9b5-dccc-42f3-a364-44a675d6a83e", "source": "42", "destination": "15" }, diff --git a/tests/resources/otm/otm_empty_file_cloudformation_example.otm b/tests/resources/otm/otm_empty_file_cloudformation_example.otm index 7290f6b5..9c99330d 100644 --- a/tests/resources/otm/otm_empty_file_cloudformation_example.otm +++ b/tests/resources/otm/otm_empty_file_cloudformation_example.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/tests/resources/otm/otm_empty_file_terraform_example.otm b/tests/resources/otm/otm_empty_file_terraform_example.otm index 95cd746b..d150cc15 100644 --- a/tests/resources/otm/otm_empty_file_terraform_example.otm +++ b/tests/resources/otm/otm_empty_file_terraform_example.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -14,6 +14,7 @@ "trustZones": [ { "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/tests/resources/terraform/aws_simple_components.otm b/tests/resources/terraform/aws_simple_components.otm index e0e0ff3a..e1ee1227 100644 --- a/tests/resources/terraform/aws_simple_components.otm +++ b/tests/resources/terraform/aws_simple_components.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "test_parse_terraform_file_ok", "id": "test_parse_terraform_file_ok" @@ -11,6 +11,7 @@ }], "trustZones": [{ "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 diff --git a/tests/resources/test_resource_paths.py b/tests/resources/test_resource_paths.py index 15d8db68..b979ab07 100644 --- a/tests/resources/test_resource_paths.py +++ b/tests/resources/test_resource_paths.py @@ -3,123 +3,122 @@ path = os.path.dirname(__file__) # GENERIC -example_json = path + '/example.json' -example_yaml = path + '/example.yaml' -invalid_yaml = path + '/invalid-yaml.yaml' -invalid_tf = path + '/invalid-tf.tf' -example_gzip = path + '/example.gz' +example_json = f'{path}/example.json' +example_yaml = f'{path}/example.yaml' +invalid_yaml = f'{path}/invalid-yaml.yaml' +invalid_tf = f'{path}/invalid-tf.tf' +example_gzip = f'{path}/example.gz' empty_mapping_file = path + "/empty_mapping_file.yaml" # OTM -otm_file_example = path + '/otm/otm_file_example.otm' -otm_yaml_file_example = path + '/otm/otm_file_example_yaml.otm' -otm_empty_file_terraform_example = path + '/otm/otm_empty_file_terraform_example.otm' -otm_empty_file_cloudformation_example = path + '/otm/otm_empty_file_cloudformation_example.otm' +otm_file_example = f'{path}/otm/otm_file_example.otm' +otm_yaml_file_example = f'{path}/otm/otm_file_example_yaml.otm' +otm_empty_file_terraform_example = f'{path}/otm/otm_empty_file_terraform_example.otm' +otm_empty_file_cloudformation_example = f'{path}/otm/otm_empty_file_cloudformation_example.otm' # CLOUDFORMATION -cloudformation_for_mappings_tests_json = path + '/cloudformation/cloudformation_for_mappings_tests.json' -cloudformation_for_security_group_tests_json = path + '/cloudformation/cloudformation_for_security_group_tests.json' -cloudformation_for_security_group_tests_2_json = path + '/cloudformation/cloudformation_for_security_group_tests_2.json' -cloudformation_for_security_groups_mapping = path + '/cloudformation/cloudformation_for_security_group_tests_mapping_definitions.yaml' -cloudformation_gz = path + '/cloudformation/cloudformation.gz' -cloudformation_invalid_size = path + '/cloudformation/cloudformation-invalid-size.json' -cloudformation_malformed_mapping_wrong_id = path + '/cloudformation/cloudformation_malformed_mapping_wrong_id.yaml' -cloudformation_component_without_parent = path + '/cloudformation/cloudformation_component_without_parent.json' -cloudformation_skipped_component_without_parent = path + '/cloudformation/cloudformation_component_without_parent_skipped.json' -cloudformation_unknown_resource = path + '/cloudformation/cloudformation_unknown_resource.json' -cloudformation_all_functions = path + '/cloudformation/cloudformation_all_functions.json' -cloudformation_multiple_files_networks = path + '/cloudformation/cloudformation_multiple_files_networks.json' -cloudformation_multiple_files_resources = path + '/cloudformation/cloudformation_multiple_files_resources.json' -cloudformation_ref_full_syntax = path + '/cloudformation/cloudformation_ref_full_syntax.yaml' -cloudformation_ref_short_syntax = path + '/cloudformation/cloudformation_ref_short_syntax.yaml' +cloudformation_for_mappings_tests_json = f'{path}/cloudformation/cloudformation_for_mappings_tests.json' +cloudformation_for_security_group_tests_json = f'{path}/cloudformation/cloudformation_for_security_group_tests.json' +cloudformation_for_security_group_tests_2_json = f'{path}/cloudformation/cloudformation_for_security_group_tests_2.json' +cloudformation_for_security_groups_mapping = f'{path}/cloudformation/cloudformation_for_security_group_tests_mapping_definitions.yaml' +cloudformation_gz = f'{path}/cloudformation/cloudformation.gz' +cloudformation_invalid_size = f'{path}/cloudformation/cloudformation-invalid-size.json' +cloudformation_malformed_mapping_wrong_id = f'{path}/cloudformation/cloudformation_malformed_mapping_wrong_id.yaml' +cloudformation_component_without_parent = f'{path}/cloudformation/cloudformation_component_without_parent.json' +cloudformation_skipped_component_without_parent = f'{path}/cloudformation/cloudformation_component_without_parent_skipped.json' +cloudformation_unknown_resource = f'{path}/cloudformation/cloudformation_unknown_resource.json' +cloudformation_all_functions = f'{path}/cloudformation/cloudformation_all_functions.json' +cloudformation_multiple_files_networks = f'{path}/cloudformation/cloudformation_multiple_files_networks.json' +cloudformation_multiple_files_resources = f'{path}/cloudformation/cloudformation_multiple_files_resources.json' +cloudformation_ref_full_syntax = f'{path}/cloudformation/cloudformation_ref_full_syntax.yaml' +cloudformation_ref_short_syntax = f'{path}/cloudformation/cloudformation_ref_short_syntax.yaml' # mapping -default_cloudformation_mapping = path + '/cloudformation/cloudformation_mapping.yaml' -cloudformation_mapping_component_without_parent = path + '/cloudformation/cloudformation_mapping_component_without_parent.yaml' -cloudformation_mapping_all_functions = path + '/cloudformation/cloudformation_mapping_all_functions.yaml' +default_cloudformation_mapping = f'{path}/cloudformation/cloudformation_mapping.yaml' +cloudformation_mapping_component_without_parent = f'{path}/cloudformation/cloudformation_mapping_component_without_parent.yaml' +cloudformation_mapping_all_functions = f'{path}/cloudformation/cloudformation_mapping_all_functions.yaml' # expected otm results -cloudformation_for_mappings_tests_json_otm_expected = path + '/cloudformation/cloudformation_for_mappings_tests.otm' +cloudformation_for_mappings_tests_json_otm_expected = f'{path}/cloudformation/cloudformation_for_mappings_tests.otm' # TERRAFORM -terraform_for_mappings_tests_json = path + '/terraform/terraform_for_mappings_tests.tf' -terraform_aws_simple_components = path + '/terraform/aws_simple_components.tf' -terraform_aws_multiple_components = path + '/terraform/aws_multiple_components.tf' -terraform_aws_singleton_components = path + '/terraform/aws_singleton_components.tf' -terraform_aws_altsource_components = path + '/terraform/aws_altsource_components.tf' -terraform_aws_security_groups_components = path + '/terraform/aws_security_groups_components.tf' -terraform_aws_dataflows = path + '/terraform/aws_dataflows.tf' -terraform_aws_parent_children_components = path + '/terraform/aws_parent_children_components.tf' -terraform_aws_singleton_components_unix_line_breaks = path + '/terraform/aws_singleton_components_unix_line_breaks.tf' -terraform_component_without_parent = path + '/terraform/aws_component_without_parent.tf' -terraform_skipped_component_without_parent = path + '/terraform/aws_component_without_parent_skipped.tf' -terraform_unknown_resource = path + '/terraform/terraform_unknown_resource.tf' -terraform_unknown_module = path + '/terraform/terraform_unknown_module.tf' -terraform_no_resources = path + '/terraform/no_resources.tf' -terraform_gz = path + '/terraform/terraform.gz' -terraform_specific_functions = path + '/terraform/terraform_specific_functions.tf' -terraform_modules = path + '/terraform/terraform_modules_sample.tf' -terraform_extra_modules_sample = path + '/terraform/terraform_extra_modules_sample.tf' -terraform_multiple_files_one = path + '/terraform/aws_simple_components.tf' -terraform_multiple_files_two = path + '/terraform/aws_dataflows.tf' +terraform_for_mappings_tests_json = f'{path}/terraform/terraform_for_mappings_tests.tf' +terraform_aws_simple_components = f'{path}/terraform/aws_simple_components.tf' +terraform_aws_multiple_components = f'{path}/terraform/aws_multiple_components.tf' +terraform_aws_singleton_components = f'{path}/terraform/aws_singleton_components.tf' +terraform_aws_altsource_components = f'{path}/terraform/aws_altsource_components.tf' +terraform_aws_security_groups_components = f'{path}/terraform/aws_security_groups_components.tf' +terraform_aws_dataflows = f'{path}/terraform/aws_dataflows.tf' +terraform_aws_parent_children_components = f'{path}/terraform/aws_parent_children_components.tf' +terraform_aws_singleton_components_unix_line_breaks = f'{path}/terraform/aws_singleton_components_unix_line_breaks.tf' +terraform_component_without_parent = f'{path}/terraform/aws_component_without_parent.tf' +terraform_skipped_component_without_parent = f'{path}/terraform/aws_component_without_parent_skipped.tf' +terraform_unknown_resource = f'{path}/terraform/terraform_unknown_resource.tf' +terraform_unknown_module = f'{path}/terraform/terraform_unknown_module.tf' +terraform_no_resources = f'{path}/terraform/no_resources.tf' +terraform_gz = f'{path}/terraform/terraform.gz' +terraform_specific_functions = f'{path}/terraform/terraform_specific_functions.tf' +terraform_modules = f'{path}/terraform/terraform_modules_sample.tf' +terraform_extra_modules_sample = f'{path}/terraform/terraform_extra_modules_sample.tf' +terraform_multiple_files_one = f'{path}/terraform/aws_simple_components.tf' +terraform_multiple_files_two = f'{path}/terraform/aws_dataflows.tf' # mapping -terraform_iriusrisk_tf_aws_mapping = path + '/terraform/iriusrisk-tf-aws-mapping.yaml' -terraform_mapping_aws_component_without_parent = path + '/terraform/terraform_mapping_component_without_parent.yaml' -terraform_malformed_mapping_wrong_id = path + '/terraform/terraform-malformed-mapping-wrong-id.yaml' -terraform_mapping_specific_functions = path + '/terraform/terraform_mapping_specific_functions.yaml' -terraform_mapping_modules = path + '/terraform/terraform_mapping_modules.yaml' -terraform_mapping_extra_modules = path + '/terraform/terraform_mapping_extra_modules.yaml' +terraform_iriusrisk_tf_aws_mapping = f'{path}/terraform/iriusrisk-tf-aws-mapping.yaml' +terraform_mapping_aws_component_without_parent = f'{path}/terraform/terraform_mapping_component_without_parent.yaml' +terraform_malformed_mapping_wrong_id = f'{path}/terraform/terraform-malformed-mapping-wrong-id.yaml' +terraform_mapping_specific_functions = f'{path}/terraform/terraform_mapping_specific_functions.yaml' +terraform_mapping_modules = f'{path}/terraform/terraform_mapping_modules.yaml' +terraform_mapping_extra_modules = f'{path}/terraform/terraform_mapping_extra_modules.yaml' # expected otm results -terraform_aws_simple_components_otm_expected = path + '/terraform/aws_simple_components.otm' +terraform_aws_simple_components_otm_expected = f'{path}/terraform/aws_simple_components.otm' # VISIO -visio_aws_with_tz_and_vpc = path + '/visio/aws-with-tz-and-vpc.vsdx' -visio_aws_shapes = path + '/visio/aws-shapes.vsdx' -visio_aws_stencils = path + '/visio/aws-stencils.vsdx' -visio_generic_shapes = path + '/visio/generic-shapes.vsdx' -visio_self_pointing_connectors = path + '/visio/self-pointing-connectors.vsdx' -visio_extraneous_elements = path + '/visio/extraneous-elements.vsdx' -visio_boundaries = path + '/visio/boundaries.vsdx' -visio_simple_boundary_tzs = path + '/visio/simple-boundary-tzs.vsdx' -visio_boundary_tz_and_default_tz = path + '/visio/boundary-tz-and-default-tz.vsdx' -visio_overlapped_boundary_tzs = path + '/visio/overlapped-boundary-tzs.vsdx' -visio_multiple_pages_diagram = path + '/visio/multiple-pages-diagram.vsdx' -visio_boundary_and_component_tzs = path + '/visio/boundary-and-component-tzs.vsdx' -visio_nested_tzs = path + '/visio/nested-tzs.vsdx' -visio_simple_components = path + '/visio/simple-components.vsdx' -visio_orphan_dataflows = path + '/visio/visio-orphan-dataflows.vsdx' -visio_invalid_file_size = path + '/visio/invalid-file-size.vsdx' -visio_invalid_file_type = path + '/visio/invalid-file-type.pdf' -visio_modified_single_connectors = path + '/visio/modified-single-connectors.vsdx' -visio_bidirectional_connectors = path + '/visio/bidirectional-connectors.vsdx' +visio_aws_with_tz_and_vpc = f'{path}/visio/aws-with-tz-and-vpc.vsdx' +visio_aws_shapes = f'{path}/visio/aws-shapes.vsdx' +visio_aws_stencils = f'{path}/visio/aws-stencils.vsdx' +visio_generic_shapes = f'{path}/visio/generic-shapes.vsdx' +visio_self_pointing_connectors = f'{path}/visio/self-pointing-connectors.vsdx' +visio_extraneous_elements = f'{path}/visio/extraneous-elements.vsdx' +visio_boundaries = f'{path}/visio/boundaries.vsdx' +visio_simple_boundary_tzs = f'{path}/visio/simple-boundary-tzs.vsdx' +visio_boundary_tz_and_default_tz = f'{path}/visio/boundary-tz-and-default-tz.vsdx' +visio_overlapped_boundary_tzs = f'{path}/visio/overlapped-boundary-tzs.vsdx' +visio_multiple_pages_diagram = f'{path}/visio/multiple-pages-diagram.vsdx' +visio_boundary_and_component_tzs = f'{path}/visio/boundary-and-component-tzs.vsdx' +visio_nested_tzs = f'{path}/visio/nested-tzs.vsdx' +visio_simple_components = f'{path}/visio/simple-components.vsdx' +visio_orphan_dataflows = f'{path}/visio/visio-orphan-dataflows.vsdx' +visio_invalid_file_size = f'{path}/visio/invalid-file-size.vsdx' +visio_invalid_file_type = f'{path}/visio/invalid-file-type.pdf' +visio_modified_single_connectors = f'{path}/visio/modified-single-connectors.vsdx' +visio_bidirectional_connectors = f'{path}/visio/bidirectional-connectors.vsdx' # mapping -default_visio_mapping = path + '/visio/aws-visio-mapping.yaml' -custom_vpc_mapping = path + '/visio/custom-vpc-mapping.yaml' +default_visio_mapping = f'{path}/visio/aws-visio-mapping.yaml' +custom_vpc_mapping = f'{path}/visio/custom-vpc-mapping.yaml' # legacy mapping -default_visio_mapping_legacy = path + '/visio/legacy/aws-visio-mapping.yaml' -custom_vpc_mapping_legacy = path + '/visio/legacy/custom-vpc-mapping.yaml' +default_visio_mapping_legacy = f'{path}/visio/legacy/aws-visio-mapping.yaml' +custom_vpc_mapping_legacy = f'{path}/visio/legacy/custom-vpc-mapping.yaml' # expected otm results -visio_aws_shapes_otm_expected = path + '/visio/aws-shapes.otm' -visio_aws_with_tz_and_vpc_otm_expected = path + '/visio/aws-with-tz-and-vpc.otm' -visio_orphan_dataflows_otm_expected = path + '/visio/visio-orphan-dataflows.otm' -visio_create_otm_ok_only_default_mapping = path + '/visio/visio_create_otm_ok_only_default_mapping.otm' -visio_create_otm_ok_both_mapping_files = path + '/visio/visio_create_otm_ok_both_mapping_files.otm' +visio_aws_shapes_otm_expected = f'{path}/visio/aws-shapes.otm' +visio_aws_with_tz_and_vpc_otm_expected = f'{path}/visio/aws-with-tz-and-vpc.otm' +visio_orphan_dataflows_otm_expected = f'{path}/visio/visio-orphan-dataflows.otm' +visio_create_otm_ok_only_default_mapping = f'{path}/visio/visio_create_otm_ok_only_default_mapping.otm' MTMT_multiple_trustzones_same_type_ID = f'{path}/otm/MTMT_multiple_trustzones_same_type_ID.otm' MTMT_multiple_trustzones_same_type_TYPE = f'{path}/otm/MTMT_multiple_trustzones_same_type_TYPE.otm' # LUCID -lucid_aws_with_tz = path + '/lucid/lucid-aws-with-tz.vsdx' -lucid_aws_with_tz_and_vpc = path + '/lucid/lucid-aws-with-tz-and-vpc.vsdx' +lucid_aws_with_tz = f'{path}/lucid/lucid-aws-with-tz.vsdx' +lucid_aws_with_tz_and_vpc = f'{path}/lucid/lucid-aws-with-tz-and-vpc.vsdx' # mapping -default_lucid_mapping = path + '/lucid/default-lucid-mapping.yaml' -lucid_aws_with_tz_mapping = path + '/lucid/lucid-aws-with-tz.yaml' -lucid_aws_with_tz_and_vpc_mapping = path + '/lucid/lucid-aws-with-tz-and-vpc.yaml' +default_lucid_mapping = f'{path}/lucid/default-lucid-mapping.yaml' +lucid_aws_with_tz_mapping = f'{path}/lucid/lucid-aws-with-tz.yaml' +lucid_aws_with_tz_and_vpc_mapping = f'{path}/lucid/lucid-aws-with-tz-and-vpc.yaml' # expected otm results -lucid_aws_with_tz_default_otm = path + '/lucid/lucid-aws-with-tz-default.otm' -lucid_aws_with_tz_otm = path + '/lucid/lucid-aws-with-tz.otm' -lucid_aws_with_tz_and_vpc_otm = path + '/lucid/lucid-aws-with-tz-and-vpc.otm' +lucid_aws_with_tz_default_otm = f'{path}/lucid/lucid-aws-with-tz-default.otm' +lucid_aws_with_tz_otm = f'{path}/lucid/lucid-aws-with-tz.otm' +lucid_aws_with_tz_and_vpc_otm = f'{path}/lucid/lucid-aws-with-tz-and-vpc.otm' # MTMT -mtmt_mapping_file_valid = path + '/mtmt/mapping_example.yaml' -mtmt_mapping_file_invalid = path + '/mtmt/mapping_example_invalid.yaml' \ No newline at end of file +mtmt_mapping_file_valid = f'{path}/mtmt/mapping_example.yaml' +mtmt_mapping_file_invalid = f'{path}/mtmt/mapping_example_invalid.yaml' diff --git a/tests/resources/visio/aws-shapes.otm b/tests/resources/visio/aws-shapes.otm index cbf69a3e..9ef91ebc 100644 --- a/tests/resources/visio/aws-shapes.otm +++ b/tests/resources/visio/aws-shapes.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "test_parse_diagram_file_ok", "id": "test_parse_diagram_file_ok" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -48,7 +49,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -71,7 +72,7 @@ "name": "Custom machine", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -94,7 +95,7 @@ "name": "Private Database", "type": "rds", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -117,7 +118,7 @@ "name": "Amazon CloudWatch", "type": "cloudwatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -140,7 +141,7 @@ "name": "Custom log system", "type": "cloudwatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { diff --git a/tests/resources/visio/aws-with-tz-and-vpc.otm b/tests/resources/visio/aws-with-tz-and-vpc.otm index a1d97a87..57d8fd1d 100644 --- a/tests/resources/visio/aws-with-tz-and-vpc.otm +++ b/tests/resources/visio/aws-with-tz-and-vpc.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "test_parse_diagram_file_ok", "id": "test_parse_diagram_file_ok" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "47", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -39,7 +40,8 @@ ] }, { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "48", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -67,7 +69,7 @@ "name": "Custom VPC", "type": "empty-component", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { @@ -136,7 +138,7 @@ "name": "Private Database", "type": "rds", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "48" }, "representations": [ { @@ -159,7 +161,7 @@ "name": "Amazon CloudWatch", "type": "cloudwatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { @@ -182,7 +184,7 @@ "name": "Custom log system", "type": "cloudwatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { diff --git a/tests/resources/visio/visio-orphan-dataflows.otm b/tests/resources/visio/visio-orphan-dataflows.otm index d00dc129..5f4bd39e 100644 --- a/tests/resources/visio/visio-orphan-dataflows.otm +++ b/tests/resources/visio/visio-orphan-dataflows.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project-name", "id": "project-id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "804b664a-7129-4a9e-a08c-16a99669f605", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -48,7 +49,7 @@ "name": "Bucket", "type": "s3", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -71,7 +72,7 @@ "name": "Bucket", "type": "s3", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -94,7 +95,7 @@ "name": "Amazon MQ", "type": "CD-MQ", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -117,7 +118,7 @@ "name": "Amazon MQ", "type": "CD-MQ", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -140,7 +141,7 @@ "name": "Database", "type": "rds", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { @@ -163,7 +164,7 @@ "name": "Amazon MQ", "type": "CD-MQ", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "804b664a-7129-4a9e-a08c-16a99669f605" }, "representations": [ { diff --git a/tests/resources/visio/visio_create_otm_ok_both_mapping_files.otm b/tests/resources/visio/visio_create_otm_ok_both_mapping_files.otm deleted file mode 100644 index f1263038..00000000 --- a/tests/resources/visio/visio_create_otm_ok_both_mapping_files.otm +++ /dev/null @@ -1,230 +0,0 @@ -{ - "otmVersion": "0.1.0", - "project": { - "name": "project_A_name", - "id": "project_A_id" - }, - "representations": [ - { - "name": "project_A_id Diagram Representation", - "id": "project_A_id-diagram", - "type": "diagram", - "size": { - "width": 1967, - "height": 1356 - } - } - ], - "trustZones": [ - { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", - "name": "Public Cloud", - "risk": { - "trustRating": 10 - }, - "representations": [ - { - "name": "Public Cloud Representation", - "id": "47-representation", - "representation": "project_A_id-diagram", - "size": { - "width": 590, - "height": 700 - }, - "position": { - "x": 328, - "y": 328 - } - } - ] - }, - { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", - "name": "Private Secured Cloud", - "risk": { - "trustRating": 10 - }, - "representations": [ - { - "name": "Private Secured Cloud Representation", - "id": "48-representation", - "representation": "project_A_id-diagram", - "size": { - "width": 523, - "height": 472 - }, - "position": { - "x": 1116, - "y": 421 - } - } - ] - } - ], - "components": [ - { - "id": "49", - "name": "Custom VPC", - "type": "empty-component", - "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" - }, - "representations": [ - { - "name": "Custom VPC Representation", - "id": "49-representation", - "representation": "project_A_id-diagram", - "size": { - "width": 295, - "height": 406 - }, - "position": { - "x": 57, - "y": 29 - } - } - ] - }, - { - "id": "1", - "name": "Amazon EC2", - "type": "ec2", - "parent": { - "component": "49" - }, - "representations": [ - { - "name": "Amazon EC2 Representation", - "id": "1-representation", - "representation": "project_A_id-diagram", - "size": { - "width": 82, - "height": 82 - }, - "position": { - "x": 82, - "y": 24 - } - } - ] - }, - { - "id": "12", - "name": "Custom machine", - "type": "ec2", - "parent": { - "component": "49" - }, - "representations": [ - { - "name": "Custom machine Representation", - "id": "12-representation", - "representation": "project_A_id-diagram", - "size": { - "width": 82, - "height": 82 - }, - "position": { - "x": 82, - "y": 230 - } - } - ] - }, - { - "id": "30", - "name": "Private Database", - "type": "rds", - "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" - }, - "representations": [ - { - "name": "Private Database Representation", - "id": "30-representation", - "representation": "project_A_id-diagram", - "size": { - "width": 82, - "height": 82 - }, - "position": { - "x": 219, - "y": 166 - } - } - ] - }, - { - "id": "35", - "name": "Amazon CloudWatch", - "type": "cloudwatch", - "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" - }, - "representations": [ - { - "name": "Amazon CloudWatch Representation", - "id": "35-representation", - "representation": "project_A_id-diagram", - "size": { - "width": 82, - "height": 82 - }, - "position": { - "x": 477, - "y": 53 - } - } - ] - }, - { - "id": "41", - "name": "Custom log system", - "type": "cloudwatch", - "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" - }, - "representations": [ - { - "name": "Custom log system Representation", - "id": "41-representation", - "representation": "project_A_id-diagram", - "size": { - "width": 82, - "height": 82 - }, - "position": { - "x": 139, - "y": 516 - } - } - ] - } - ], - "dataflows": [ - { - "destination": "12", - "id": "17", - "name": "21830dc6-840d-4254-bb35-f4b2c68561e5", - "source": "1" - }, - { - "destination": "30", - "id": "34", - "name": "89ab351c-6ae7-4afb-ad90-0eb045fd801a", - "source": "12" - }, - { - "destination": "35", - "id": "40", - "name": "7aecb32c-e39f-4dc2-ad6e-7f5793161a6d", - "source": "1" - }, - { - "destination": "41", - "id": "46", - "name": "6ceb010f-8390-4dc5-943b-62d268c34e78", - "source": "12" - } - ] -} \ No newline at end of file diff --git a/tests/resources/visio/visio_create_otm_ok_only_default_mapping.otm b/tests/resources/visio/visio_create_otm_ok_only_default_mapping.otm index 2d92e5ee..ab18cb1f 100644 --- a/tests/resources/visio/visio_create_otm_ok_only_default_mapping.otm +++ b/tests/resources/visio/visio_create_otm_ok_only_default_mapping.otm @@ -1,5 +1,5 @@ { - "otmVersion": "0.1.0", + "otmVersion": "0.2.0", "project": { "name": "project_A_name", "id": "project_A_id" @@ -17,7 +17,8 @@ ], "trustZones": [ { - "id": "b61d6911-338d-46a8-9f39-8dcd24abfe91", + "id": "47", + "type": "b61d6911-338d-46a8-9f39-8dcd24abfe91", "name": "Public Cloud", "risk": { "trustRating": 10 @@ -39,7 +40,8 @@ ] }, { - "id": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", + "id": "48", + "type": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d", "name": "Private Secured Cloud", "risk": { "trustRating": 10 @@ -67,7 +69,7 @@ "name": "Amazon EC2", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { @@ -90,7 +92,7 @@ "name": "Custom machine", "type": "ec2", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { @@ -113,7 +115,7 @@ "name": "Private Database", "type": "rds", "parent": { - "trustZone": "2ab4effa-40b7-4cd2-ba81-8247d29a6f2d" + "trustZone": "48" }, "representations": [ { @@ -136,7 +138,7 @@ "name": "Amazon CloudWatch", "type": "cloudwatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { @@ -159,7 +161,7 @@ "name": "Custom log system", "type": "cloudwatch", "parent": { - "trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91" + "trustZone": "47" }, "representations": [ { diff --git a/tests/unit/test_otm_unifier.py b/tests/unit/test_otm_unifier.py deleted file mode 100644 index 711310e6..00000000 --- a/tests/unit/test_otm_unifier.py +++ /dev/null @@ -1,48 +0,0 @@ -import json - -from otm.otm.entity.component import Component -from otm.otm.entity.representation import RepresentationType -from otm.otm.entity.trustzone import Trustzone -from otm.otm.otm_builder import OTMBuilder -from otm.otm.provider import Provider -from sl_util.sl_util.file_utils import get_byte_data -from slp_base.slp_base.otm_trustzone_unifier import OTMTrustZoneUnifier -from tests.resources.test_resource_paths import MTMT_multiple_trustzones_same_type_ID - - -class DummyType(str, Provider): - DUMMY = ("DUMMY", "Dummy", RepresentationType.DIAGRAM) - - -class TestOTMUnifier: - - def test_multiple_trustzones_same_type(self): - # GIVEN an otm with multiple trust zones with the same type - trustzones: [Trustzone] = [ - Trustzone(trustzone_id='60e82972', type='6376d53e', name='Internet'), - Trustzone(trustzone_id='250a69a4', type='6376d53e', name='Public'), - Trustzone(trustzone_id='d6987386', type='6376d53e', name='Intranet'), - Trustzone(trustzone_id='e85a8516', type='6376d53e', name='Private'), - Trustzone(trustzone_id='75163eca', type='b61d6911', name='Public Cloud Zone'), - ] - components: [Component] = [ - Component('de588d55', 'Public Web App', '', '250a69a4', 'trustZone'), - Component('6460a14f', 'Browser', '', '60e82972', 'trustZone'), - Component('348d1acd', 'Web API', '', 'd6987386', 'trustZone'), - Component('9c7e2caa', 'Intranet Web App', '', 'd6987386', 'trustZone'), - Component('104c3e42', 'PostgreSQL', '', 'e85a8516', 'trustZone'), - Component('a2986e26', 'DynamoDB', '', '75163eca', 'trustZone'), - - ] - origin = OTMBuilder('test1', 'Test 1', DummyType.DUMMY).add_trustzones(trustzones).add_components(components) \ - .build() - - # AND the expected otm without tz type field - expected = json.loads(get_byte_data(MTMT_multiple_trustzones_same_type_ID)) - - # WHEN we unify the trust zones - OTMTrustZoneUnifier(origin).unify() - - # THEN we check the expected result - assert origin.json() == expected - From 69ad8183ca5370deffcab2a54d200b1d42562d93 Mon Sep 17 00:00:00 2001 From: Santi Manero Date: Wed, 13 Sep 2023 10:47:22 +0200 Subject: [PATCH 2/4] [OPT-684] Fixed indentation issue --- .../test_otm_controller_diagram_visio.py | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/tests/integration/api/controllers/diagram/visio/test_otm_controller_diagram_visio.py b/tests/integration/api/controllers/diagram/visio/test_otm_controller_diagram_visio.py index 4bc5a2fe..215f9174 100644 --- a/tests/integration/api/controllers/diagram/visio/test_otm_controller_diagram_visio.py +++ b/tests/integration/api/controllers/diagram/visio/test_otm_controller_diagram_visio.py @@ -64,41 +64,41 @@ def test_create_otm_ok_only_default_mapping(self, mapping): assert result == expected -@mark.parametrize('default_mapping,custom_mapping', [ - (default_visio_mapping, custom_vpc_mapping), - (default_visio_mapping_legacy, custom_vpc_mapping_legacy), - (default_visio_mapping, custom_vpc_mapping_legacy), - (default_visio_mapping_legacy, custom_vpc_mapping), -]) -@responses.activate -def test_create_otm_ok_both_mapping_files(self, default_mapping, custom_mapping): - # Given a project_id - project_id: str = 'test_parse_diagram_file_ok' - - # And the source file - diag_file = get_byte_data(visio_aws_with_tz_and_vpc) - - # And the mapping files - mapping_file = get_byte_data(default_mapping) - custom_mapping_file = get_byte_data(custom_mapping) - - # And the expected otm - expected_otm = test_resource_paths.visio_aws_with_tz_and_vpc_otm_expected - - # When I do post on diagram endpoint - files = {'diag_file': diag_file, 'default_mapping_file': mapping_file, - 'custom_mapping_file': custom_mapping_file} - body = {'diag_type': 'VISIO', 'id': project_id, 'name': project_id} - response = client.post(get_url(), files=files, data=body) - - # Then the OTM is returned inside the response as JSON - assert response.status_code == diag_create_otm_controller.RESPONSE_STATUS_CODE - assert response.headers.get('content-type') == json_mime - otm = json.loads(response.text) - - # and the otm is as expected - result, expected = validate_and_compare_otm(otm, expected_otm, None) - assert result == expected + @mark.parametrize('default_mapping,custom_mapping', [ + (default_visio_mapping, custom_vpc_mapping), + (default_visio_mapping_legacy, custom_vpc_mapping_legacy), + (default_visio_mapping, custom_vpc_mapping_legacy), + (default_visio_mapping_legacy, custom_vpc_mapping), + ]) + @responses.activate + def test_create_otm_ok_both_mapping_files(self, default_mapping, custom_mapping): + # Given a project_id + project_id: str = 'test_parse_diagram_file_ok' + + # And the source file + diag_file = get_byte_data(visio_aws_with_tz_and_vpc) + + # And the mapping files + mapping_file = get_byte_data(default_mapping) + custom_mapping_file = get_byte_data(custom_mapping) + + # And the expected otm + expected_otm = test_resource_paths.visio_aws_with_tz_and_vpc_otm_expected + + # When I do post on diagram endpoint + files = {'diag_file': diag_file, 'default_mapping_file': mapping_file, + 'custom_mapping_file': custom_mapping_file} + body = {'diag_type': 'VISIO', 'id': project_id, 'name': project_id} + response = client.post(get_url(), files=files, data=body) + + # Then the OTM is returned inside the response as JSON + assert response.status_code == diag_create_otm_controller.RESPONSE_STATUS_CODE + assert response.headers.get('content-type') == json_mime + otm = json.loads(response.text) + + # and the otm is as expected + result, expected = validate_and_compare_otm(otm, expected_otm, None) + assert result == expected @responses.activate @patch('slp_visio.slp_visio.validate.visio_validator.VisioValidator.validate') From 5a60f195b830705953abbf3cab53c18a2aa388a3 Mon Sep 17 00:00:00 2001 From: Daniel Font Date: Wed, 20 Sep 2023 09:40:27 +0200 Subject: [PATCH 3/4] [OPT-684] Fix tests after wrong merge. --- .../test_otm_controller_iac_cloudformation.py | 22 +++++++++---------- .../test_otm_controller_iac_terraform.py | 22 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/integration/api/controllers/iac/cloudformation/test_otm_controller_iac_cloudformation.py b/tests/integration/api/controllers/iac/cloudformation/test_otm_controller_iac_cloudformation.py index d348390e..16b5fccb 100644 --- a/tests/integration/api/controllers/iac/cloudformation/test_otm_controller_iac_cloudformation.py +++ b/tests/integration/api/controllers/iac/cloudformation/test_otm_controller_iac_cloudformation.py @@ -33,17 +33,17 @@ def get_url(): class TestOTMControllerIaCCloudformation: cft_map = default_cloudformation_mapping wrong_id = cloudformation_malformed_mapping_wrong_id - uc_a = (None, 'proj A', example_json, json_mime, cft_map, 'RequestValidationError') - uc_b = ('proj_B', None, example_json, json_mime, cft_map, 'RequestValidationError') - uc_c = ('proj_C', 'proj C', None, None, cft_map, 'RequestValidationError') - uc_d = ('proj_D', 'proj D', example_json, json_mime, None, 'RequestValidationError') - uc_e = ('proj_E', 'proj E', example_json, json_mime, wrong_id, 'MappingFileNotValidError') - uc_f = ('proj_F', 'proj F', None, None, None, 'RequestValidationError') - uc_h = ('proj_H', 'proj H', invalid_yaml, '', cft_map, 'IacFileNotValidError') - uc_i = ('proj_I', 'proj I', invalid_yaml, yaml_mime, cft_map, 'OTMBuildingError') - uc_j = ('proj_J', 'proj J', invalid_yaml, None, cft_map, 'OTMBuildingError') - uc_k = ('proj_K', 'proj K', cloudformation_gz, None, cft_map, 'IacFileNotValidError') - uc_l = ('proj_L', 'proj L', visio_aws_shapes, None, cft_map, 'IacFileNotValidError') + uc_a = (None, 'proj A', example_json, json_mime, cft_map, None, 'RequestValidationError') + uc_b = ('proj_B', None, example_json, json_mime, cft_map, None, 'RequestValidationError') + uc_c = ('proj_C', 'proj C', None, None, cft_map, None, 'RequestValidationError') + uc_d = ('proj_D', 'proj D', example_json, json_mime, None, None, 'MappingFileNotValidError') + uc_e = ('proj_E', 'proj E', example_json, json_mime, wrong_id, None, 'MappingFileNotValidError') + uc_f = ('proj_F', 'proj F', None, None, None, None, 'RequestValidationError') + uc_h = ('proj_H', 'proj H', invalid_yaml, '', cft_map, None, 'IacFileNotValidError') + uc_i = ('proj_I', 'proj I', invalid_yaml, yaml_mime, cft_map, None, 'OTMBuildingError') + uc_j = ('proj_J', 'proj J', invalid_yaml, None, cft_map, None, 'OTMBuildingError') + uc_k = ('proj_K', 'proj K', cloudformation_gz, None, cft_map, None, 'IacFileNotValidError') + uc_l = ('proj_L', 'proj L', example_json, json_mime, cft_map, cft_map, 'MappingFileNotValidError') @responses.activate def test_create_otm_ok(self): diff --git a/tests/integration/api/controllers/iac/terraform/test_otm_controller_iac_terraform.py b/tests/integration/api/controllers/iac/terraform/test_otm_controller_iac_terraform.py index 7451c290..bd6610d1 100644 --- a/tests/integration/api/controllers/iac/terraform/test_otm_controller_iac_terraform.py +++ b/tests/integration/api/controllers/iac/terraform/test_otm_controller_iac_terraform.py @@ -33,17 +33,17 @@ class TestOTMControllerIaCTerraform: tf_file = terraform_aws_simple_components tf_map = terraform_iriusrisk_tf_aws_mapping wrong_id = terraform_malformed_mapping_wrong_id - uc_a = (None, 'proj A', tf_file, json_mime, tf_map, 'RequestValidationError') - uc_b = ('proj_B', None, tf_file, json_mime, tf_map, 'RequestValidationError') - uc_c = ('proj_C', 'proj C', None, None, tf_map, 'RequestValidationError') - uc_d = ('proj_D', 'proj D', tf_file, json_mime, None, 'RequestValidationError') - uc_e = ('proj_E', 'proj E', tf_file, json_mime, wrong_id, 'MappingFileNotValidError') - uc_f = ('proj_F', 'proj F', None, None, None, 'RequestValidationError') - uc_h = ('proj_H', 'proj H', invalid_tf, '', tf_map, 'IacFileNotValidError') - uc_i = ('proj_I', 'proj I', invalid_tf, yaml_mime, tf_map, 'IacFileNotValidError') - uc_j = ('proj_J', 'proj J', invalid_tf, None, tf_map, 'LoadingIacFileError') - uc_k = ('proj_K', 'proj K', terraform_gz, None, tf_map, 'IacFileNotValidError') - uc_l = ('proj_L', 'proj L', visio_aws_shapes, None, tf_map, 'IacFileNotValidError') + uc_a = (None, 'proj A', tf_file, json_mime, tf_map, None, 'RequestValidationError') + uc_b = ('proj_B', None, tf_file, json_mime, tf_map, None, 'RequestValidationError') + uc_c = ('proj_C', 'proj C', None, None, tf_map, None, 'RequestValidationError') + uc_d = ('proj_D', 'proj D', tf_file, json_mime, None, None, 'MappingFileNotValidError') + uc_e = ('proj_E', 'proj E', tf_file, json_mime, wrong_id, None, 'MappingFileNotValidError') + uc_f = ('proj_F', 'proj F', None, None, None, None, 'RequestValidationError') + uc_h = ('proj_H', 'proj H', invalid_tf, '', tf_map, None, 'IacFileNotValidError') + uc_i = ('proj_I', 'proj I', invalid_tf, yaml_mime, tf_map, None, 'IacFileNotValidError') + uc_j = ('proj_J', 'proj J', invalid_tf, None, tf_map, None, 'LoadingIacFileError') + uc_k = ('proj_K', 'proj K', terraform_gz, None, tf_map, None, 'IacFileNotValidError') + uc_l = ('proj_L', 'proj L', tf_file, json_mime, tf_map, tf_map, 'MappingFileNotValidError') @responses.activate @pytest.mark.parametrize('filename,break_line', [ From b62c10b1e3ac9dbaf4d4efe75f0d612a8fc9c352 Mon Sep 17 00:00:00 2001 From: Santi Manero Date: Thu, 28 Sep 2023 11:49:17 +0200 Subject: [PATCH 4/4] [OPT-684] Fixed attack surface trust zone creation issue on tfplan --- .../transformers/attack_surface_calculator.py | 4 +- .../test_attack_surface_calculator.py | 91 ++++++++++++++++++- 2 files changed, 92 insertions(+), 3 deletions(-) diff --git a/slp_tfplan/slp_tfplan/transformers/attack_surface_calculator.py b/slp_tfplan/slp_tfplan/transformers/attack_surface_calculator.py index 3e9ad8a7..8f178af2 100644 --- a/slp_tfplan/slp_tfplan/transformers/attack_surface_calculator.py +++ b/slp_tfplan/slp_tfplan/transformers/attack_surface_calculator.py @@ -35,7 +35,7 @@ def _create_client(client_id: str, variables: Dict, security_group_cidr: Securit component_id=client_id, name=_generate_client_name(security_group_cidr, variables, attack_surface_configuration.client), component_type=attack_surface_configuration.client, - parent=attack_surface_configuration.trustzone.type, + parent=attack_surface_configuration.trustzone.id, parent_type=ParentType.TRUST_ZONE, tags=[] ) @@ -191,6 +191,6 @@ def __is_same_dataflow_to_parent(self, return parent_name == child_name and relations == same_or_ancestor_relationships def add_attack_surface_trustzone(self): - if self.otm.exists_component_with_parent(self.attack_surface_configuration.trustzone.type) and \ + if self.otm.exists_component_with_parent(self.attack_surface_configuration.trustzone.id) and \ not self.otm.exists_trustzone_with_type(self.attack_surface_configuration.trustzone.type): self.otm.trustzones.append(trustzone_to_otm(self.attack_surface_configuration.trustzone)) diff --git a/slp_tfplan/tests/unit/transformers/test_attack_surface_calculator.py b/slp_tfplan/tests/unit/transformers/test_attack_surface_calculator.py index 166de119..a41b1adc 100644 --- a/slp_tfplan/tests/unit/transformers/test_attack_surface_calculator.py +++ b/slp_tfplan/tests/unit/transformers/test_attack_surface_calculator.py @@ -2,7 +2,9 @@ from unittest.mock import MagicMock, Mock import pytest +from pytest import param +from otm.otm.entity.trustzone import Trustzone from slp_tfplan.slp_tfplan.matcher import ComponentsAndSGsMatcher from slp_tfplan.slp_tfplan.objects.tfplan_objects import SecurityGroupCIDR, TFPlanComponent from slp_tfplan.slp_tfplan.relationship.component_relationship_calculator import ComponentRelationshipCalculator, \ @@ -202,7 +204,7 @@ def test_ingress_dataflows(self, # THE second component is the 'client' in the Internet trustzone assert otm.components[1].id == expected_id assert otm.components[1].type == 'client' - assert otm.components[1].parent == 'Internet' + assert otm.components[1].parent == 'internet-trustzone-id' # THE otm has 2 trustzones assert len(otm.trustzones) == 2 @@ -344,6 +346,10 @@ def test_security_group_cidr_multiple_ips(self, assert otm.components[1].id == expected_client_id assert otm.components[1].name == expected_client_name + # AND the parents are the expected + assert otm.components[1].parent == 'internet-trustzone-id' + assert otm.components[0].parent == 'default-trustzone-id' + # AND the otm has 2 trustzones assert len(otm.trustzones) == 2 @@ -455,3 +461,86 @@ def test_remove_parent_dataflows(self, # AND it generates 1 dataflow assert len(otm.dataflows) == 1 + + @pytest.mark.parametrize('parent_id', [ + param('internet-trustzone-id', id='component_with_parent_and_no_previous_tz_internet') + ]) + def test_add_attack_surface_trustzone_when_needed(self, parent_id): + # GIVEN an extra component with custom parent id + generic_client = build_mocked_component({ + 'component_name': 'component_k', + 'tf_type': 'generic-client', + 'parent_id': parent_id + }) + # AND the otm with 3 components + otm = build_mocked_otm([_component_a, _component_b, generic_client]) + + # AND the attack surface calculator + calculator = AttackSurfaceCalculator( + otm, + MagicMock(), + attack_surface_configuration) + # WHEN we add the attack surface trust zone + calculator.add_attack_surface_trustzone() + # THEN the trust zones are the expected + assert len(otm.trustzones) == 2 + assert otm.trustzones[0].id == 'default-trustzone-id' + assert otm.trustzones[0].name == 'default-trustzone-name' + assert otm.trustzones[0].type == 'default-trustzone-type' + assert otm.trustzones[1].id == 'internet-trustzone-id' + assert otm.trustzones[1].name == 'Internet Trustzone' + assert otm.trustzones[1].type == 'Internet' + # AND the components are the expected + assert len(otm.components) == 3 + assert otm.components[0].id == 'aws_type.component_a' + assert otm.components[0].parent == 'default-trustzone-id' + assert otm.components[1].id == 'aws_type.component_b' + assert otm.components[1].parent == 'default-trustzone-id' + assert otm.components[2].id == 'generic-client.component_k' + assert otm.components[2].parent == 'internet-trustzone-id' + + @pytest.mark.parametrize('parent_id,extra_trustzone', [ + param('internet-trustzone-id', internet_trustzone, id='component_with_parent_but_previous_tz'), + param('default-trustzone-id', internet_trustzone, id='no_component_with_parent_and_previous_tz'), + param('default-trustzone-id', None, id='no_component_with_parent_and_no_previous_tz_1tz'), + param('default-trustzone-id', Trustzone('99', 'dummy', type='00000'), + id='no_component_with_parent_and_no_previous_tz_2tz'), + ]) + def test_add_attack_surface_trustzone_when_not_needed(self, parent_id, extra_trustzone: Trustzone): + # GIVEN a generic client with internet tz as parent + generic_client = build_mocked_component({ + 'component_name': 'component_k', + 'tf_type': 'generic-client', + 'parent_id': parent_id + }) + # AND the otm with 3 components + otm = build_mocked_otm([_component_a, _component_b, generic_client]) + + # AND an extra trust zone + if extra_trustzone: + otm.trustzones.append(extra_trustzone) + + # AND the attack surface calculator + calculator = AttackSurfaceCalculator( + otm, + MagicMock(), + attack_surface_configuration) + # WHEN we add the attack surface trust zone + calculator.add_attack_surface_trustzone() + # THEN the trust zones are the expected + assert len(otm.trustzones) == 2 if extra_trustzone else 1 + assert otm.trustzones[0].id == 'default-trustzone-id' + assert otm.trustzones[0].name == 'default-trustzone-name' + assert otm.trustzones[0].type == 'default-trustzone-type' + if extra_trustzone: + assert otm.trustzones[1].id == extra_trustzone.id + assert otm.trustzones[1].name == extra_trustzone.name + assert otm.trustzones[1].type == extra_trustzone.type + # AND the components are the expected + assert len(otm.components) == 3 + assert otm.components[0].id == 'aws_type.component_a' + assert otm.components[0].parent == 'default-trustzone-id' + assert otm.components[1].id == 'aws_type.component_b' + assert otm.components[1].parent == 'default-trustzone-id' + assert otm.components[2].id == 'generic-client.component_k' + assert otm.components[2].parent == parent_id