From 976b77c17e16f9e953ef16cc9e757a541294fae8 Mon Sep 17 00:00:00 2001 From: Stefan Kehayov Date: Wed, 7 Feb 2024 17:20:51 +0200 Subject: [PATCH] reformat code files with IDE reformat and added TestAbacusValidator to test the abacus validation --- .../schemas/abacus_mapping_schema.json | 61 +- slp_abacus/slp_abacus/abacus_processor.py | 4 +- slp_abacus/slp_abacus/load/abacus_loader.py | 1 - .../load/abacus_mapping_file_loader.py | 1 - slp_abacus/slp_abacus/parse/abacus_parser.py | 6 +- .../default_trustzone_transformer.py | 5 +- .../parent_calculator_transformer.py | 1 - .../validate/abacus_mapping_file_validator.py | 3 - .../slp_abacus/validate/abacus_validator.py | 33 +- .../tests/resources/abacus/abacus_merged.json | 524 +++++++++--------- .../abacus/component-by-project.json | 226 ++++---- .../resources/abacus/elements-by-project.json | 227 ++++---- .../abacus/locations-by-component.json | 83 ++- .../platform-services-by-component.json | 44 +- .../iriusrisk-abacus-mapping.yaml | 4 +- slp_abacus/tests/util/builders.py | 3 +- slp_abacus/tests/validate/__init__.py | 0 .../tests/validate/test_abacus_validator.py | 77 +++ 18 files changed, 702 insertions(+), 601 deletions(-) rename slp_abacus/tests/resources/{abacus => mapping}/iriusrisk-abacus-mapping.yaml (86%) create mode 100644 slp_abacus/tests/validate/__init__.py create mode 100644 slp_abacus/tests/validate/test_abacus_validator.py diff --git a/slp_abacus/resources/schemas/abacus_mapping_schema.json b/slp_abacus/resources/schemas/abacus_mapping_schema.json index da424597..d4d90ff2 100644 --- a/slp_abacus/resources/schemas/abacus_mapping_schema.json +++ b/slp_abacus/resources/schemas/abacus_mapping_schema.json @@ -2,16 +2,25 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Mapping File", "type": "object", - "required": ["trustzones", "components"], + "required": [ + "trustzones", + "components" + ], "properties": { "trustzones": { "type": "array", "items": { "type": "object", - "required": ["label"], + "required": [ + "label" + ], "properties": { - "label": {"$ref": "#/definitions/LabelUnion"}, - "type": {"$ref": "#/definitions/query"} + "label": { + "$ref": "#/definitions/LabelUnion" + }, + "type": { + "$ref": "#/definitions/query" + } } } }, @@ -19,10 +28,16 @@ "type": "array", "items": { "type": "object", - "required": ["label"], + "required": [ + "label" + ], "properties": { - "label": {"$ref": "#/definitions/LabelUnion"}, - "type": {"$ref": "#/definitions/query"} + "label": { + "$ref": "#/definitions/LabelUnion" + }, + "type": { + "$ref": "#/definitions/query" + } } } } @@ -35,35 +50,35 @@ } ] }, - "LabelUnion":{ - "anyOf":[ + "LabelUnion": { + "anyOf": [ { - "type":"array", - "items":{ - "type":"string" + "type": "array", + "items": { + "type": "string" } }, { - "$ref":"#/definitions/RegExClass" + "$ref": "#/definitions/RegExClass" }, { - "type":"string" + "type": "string" } ], - "title":"LabelUnion" + "title": "LabelUnion" }, - "RegExClass":{ - "type":"object", - "additionalProperties":false, - "properties":{ - "$regex":{ - "type":"string" + "RegExClass": { + "type": "object", + "additionalProperties": false, + "properties": { + "$regex": { + "type": "string" } }, - "required":[ + "required": [ "$regex" ], - "title":"RegExClass" + "title": "RegExClass" } } } \ No newline at end of file diff --git a/slp_abacus/slp_abacus/abacus_processor.py b/slp_abacus/slp_abacus/abacus_processor.py index 71355748..424e4764 100644 --- a/slp_abacus/slp_abacus/abacus_processor.py +++ b/slp_abacus/slp_abacus/abacus_processor.py @@ -1,6 +1,6 @@ from starlette.datastructures import UploadFile -from sl_util.sl_util.file_utils import get_byte_data, get_byte_data_from_upload_file, read_byte_data +from sl_util.sl_util.file_utils import get_byte_data, get_byte_data_from_upload_file from slp_abacus.slp_abacus.load.abacus_loader import AbacusLoader from slp_abacus.slp_abacus.load.abacus_mapping_file_loader import AbacusMappingFileLoader from slp_abacus.slp_abacus.parse.abacus_parser import AbacusParser @@ -14,7 +14,7 @@ class AbacusProcessor(OTMProcessor): Abacus implementation of OTMProcessor """ - def __init__(self, project_id: str, project_name: str, source, mappings: [bytes], diag_type=None): + def __init__(self, project_id: str, project_name: str, source, mappings: [bytes], diag_type=None): self.project_id = project_id self.project_name = project_name self.source: bytes = \ diff --git a/slp_abacus/slp_abacus/load/abacus_loader.py b/slp_abacus/slp_abacus/load/abacus_loader.py index 80f18523..aadde70d 100644 --- a/slp_abacus/slp_abacus/load/abacus_loader.py +++ b/slp_abacus/slp_abacus/load/abacus_loader.py @@ -1,6 +1,5 @@ import json import logging -import yaml from sl_util.sl_util.file_utils import read_byte_data from slp_abacus.slp_abacus.objects.diagram_objects import Diagram, DiagramComponent, DiagramRepresentation diff --git a/slp_abacus/slp_abacus/load/abacus_mapping_file_loader.py b/slp_abacus/slp_abacus/load/abacus_mapping_file_loader.py index 0ddf90f4..84dae66b 100644 --- a/slp_abacus/slp_abacus/load/abacus_mapping_file_loader.py +++ b/slp_abacus/slp_abacus/load/abacus_mapping_file_loader.py @@ -12,7 +12,6 @@ def __init__(self, trustzones: List[Dict], components: List[Dict]): self.components: List[Dict] = components - class AbacusMappingFileLoader(MappingFileLoader): def __init__(self, mapping_data_list: List[bytes]): diff --git a/slp_abacus/slp_abacus/parse/abacus_parser.py b/slp_abacus/slp_abacus/parse/abacus_parser.py index 6632e311..8c176434 100644 --- a/slp_abacus/slp_abacus/parse/abacus_parser.py +++ b/slp_abacus/slp_abacus/parse/abacus_parser.py @@ -2,13 +2,13 @@ from otm.otm.entity.otm import OTM from otm.otm.otm_builder import OTMBuilder -from slp_base import OTMBuildingError -from slp_base.slp_base.provider_parser import ProviderParser -from slp_base.slp_base.provider_type import DiagramType from slp_abacus.slp_abacus.load.abacus_mapping_file_loader import AbacusMapping from slp_abacus.slp_abacus.objects.diagram_objects import Diagram from slp_abacus.slp_abacus.parse.diagram_mapper import DiagramMapper from slp_abacus.slp_abacus.parse.transformers.default_trustzone_transformer import DefaultTrustZoneTransformer +from slp_base import OTMBuildingError +from slp_base.slp_base.provider_parser import ProviderParser +from slp_base.slp_base.provider_type import DiagramType logger = logging.getLogger(__name__) diff --git a/slp_abacus/slp_abacus/parse/transformers/default_trustzone_transformer.py b/slp_abacus/slp_abacus/parse/transformers/default_trustzone_transformer.py index c56c469f..4902ae52 100644 --- a/slp_abacus/slp_abacus/parse/transformers/default_trustzone_transformer.py +++ b/slp_abacus/slp_abacus/parse/transformers/default_trustzone_transformer.py @@ -4,9 +4,9 @@ from otm.otm.trustzone_representation_calculator import \ TrustZoneRepresentationCalculator from sl_util.sl_util.iterations_utils import append_if_not_exists -from slp_base import OTMBuildingError from slp_abacus.slp_abacus.objects.diagram_objects import Diagram, DiagramTrustZone, DiagramComponent from slp_abacus.slp_abacus.parse.transformers.transformer import Transformer +from slp_base import OTMBuildingError def _find_orphan_components(components: List[DiagramComponent]) -> List[DiagramComponent]: @@ -25,7 +25,8 @@ def transform(self): return if not self.default_trustzone: - raise OTMBuildingError(title='Invalid configuration', message='A default trust zone is required with orphan components') + raise OTMBuildingError(title='Invalid configuration', + message='A default trust zone is required with orphan components') self.__use_default_trustzone_as_global_parent() diff --git a/slp_abacus/slp_abacus/parse/transformers/parent_calculator_transformer.py b/slp_abacus/slp_abacus/parse/transformers/parent_calculator_transformer.py index df59ceee..0b01ec6e 100644 --- a/slp_abacus/slp_abacus/parse/transformers/parent_calculator_transformer.py +++ b/slp_abacus/slp_abacus/parse/transformers/parent_calculator_transformer.py @@ -2,7 +2,6 @@ from otm.otm.entity.parent_type import ParentType from slp_abacus.slp_abacus.objects.diagram_objects import DiagramComponent, DiagramTrustZone -from slp_abacus.slp_abacus.parse.transformers.transformer import Transformer PARENT_TYPES = { DiagramComponent: ParentType.COMPONENT, diff --git a/slp_abacus/slp_abacus/validate/abacus_mapping_file_validator.py b/slp_abacus/slp_abacus/validate/abacus_mapping_file_validator.py index 6f77eedf..9b01776d 100644 --- a/slp_abacus/slp_abacus/validate/abacus_mapping_file_validator.py +++ b/slp_abacus/slp_abacus/validate/abacus_mapping_file_validator.py @@ -12,6 +12,3 @@ class AbacusMappingFileValidator(MultipleMappingFileValidator): def __init__(self, mappings_data: [bytes]): super(AbacusMappingFileValidator, self).__init__( Schema.from_package('slp_abacus', self.schema_filename), mappings_data) - - # def validate(self): - # logger.debug('Validating mapping files') diff --git a/slp_abacus/slp_abacus/validate/abacus_validator.py b/slp_abacus/slp_abacus/validate/abacus_validator.py index 9c637bf8..a4d13599 100644 --- a/slp_abacus/slp_abacus/validate/abacus_validator.py +++ b/slp_abacus/slp_abacus/validate/abacus_validator.py @@ -1,21 +1,36 @@ import logging import os -import xmlschema - from sl_util.sl_util.file_utils import get_file_type_by_content from slp_base import ProviderValidator, DiagramFileNotValidError, DiagramType -from slp_base.slp_base.provider_validator import generate_size_error, generate_content_type_error, generate_schema_error +from slp_base.slp_base.provider_validator import generate_size_error, generate_content_type_error logger = logging.getLogger(__name__) -path = os.path.dirname(__file__) -class AbacusValidator(ProviderValidator): +MAX_SIZE = 10 * 1024 * 1024 +MIN_SIZE = 10 - def __init__(self): - super(AbacusValidator, self).__init__() +path = os.path.dirname(__file__) - # def validate(self): - # logger.info('Validating Abacus file') +class AbacusValidator(ProviderValidator): + def __init__(self, data): + super(AbacusValidator, self).__init__() + self.data = data + self.provider = DiagramType.ABACUS + + def validate(self): + logger.info('Validating Abacus file') + self.__validate_size() + self.__validate_content_type() + + def __validate_size(self): + size = len(self.data) + if size > MAX_SIZE or size < MIN_SIZE: + raise generate_size_error(self.provider, 'diag_file', DiagramFileNotValidError) + + def __validate_content_type(self): + mime = get_file_type_by_content(self.data) + if mime not in self.provider.valid_mime: + raise generate_content_type_error(self.provider, 'diag_file', DiagramFileNotValidError) diff --git a/slp_abacus/tests/resources/abacus/abacus_merged.json b/slp_abacus/tests/resources/abacus/abacus_merged.json index 484e2be9..3f3502f7 100644 --- a/slp_abacus/tests/resources/abacus/abacus_merged.json +++ b/slp_abacus/tests/resources/abacus/abacus_merged.json @@ -1,264 +1,264 @@ { - "EEID": 258635, - "Description": "This is a project used for Irius Risk and Abacus integration purposes", - "Name": "POC00012023", - "BaselineElementEEID": 258635, - "Created": "2023-04-25T19:09:26Z", - "CreatedBy": "username", - "Modified": "2023-05-03T12:39:25Z", - "ModifiedBy": "username", - "ComponentTypeEEID": 153, - "ComponentTypeName": "Project", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": 59571, - "OutConnections": [ - { - "EEID": 258636, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258636, - "Created": "2023-04-25T19:10:03Z", - "CreatedBy": "username", - "Modified": "2023-04-25T19:10:03Z", - "ModifiedBy": "username", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258631, - "SinkComponentName": "SST PoC Webpage" - }, - { - "EEID": 258642, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258642, - "Created": "2023-04-25T19:19:05Z", - "CreatedBy": "username", - "Modified": "2023-04-25T19:19:05Z", - "ModifiedBy": "username", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258639, - "SinkComponentName": "SST PoC Integrator" - }, - { - "EEID": 258646, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258646, - "Created": "2023-04-25T19:20:28Z", - "CreatedBy": "username", - "Modified": "2023-04-25T19:20:28Z", - "ModifiedBy": "username", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258643, - "SinkComponentName": "SST PoC Backend" - }, - { - "EEID": 258650, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258650, - "Created": "2023-04-25T19:22:10Z", - "CreatedBy": "username", - "Modified": "2023-04-25T19:22:10Z", - "ModifiedBy": "username", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258647, - "SinkComponentName": "SST PoC Database" - }, - { - "EEID": 258665, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258665, - "Created": "2023-04-25T19:48:54Z", - "CreatedBy": "username", - "Modified": "2023-04-25T19:48:54Z", - "ModifiedBy": "username", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258662, - "SinkComponentName": "SST PoC Static Content" - }, - { - "EEID": 258636, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258636, - "Created": "2023-04-25T19:10:03Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T19:10:03Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258631, - "SinkComponentName": "SST PoC Webpage" - }, - { - "EEID": 258642, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258642, - "Created": "2023-04-25T19:19:05Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T19:19:05Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258639, - "SinkComponentName": "SST PoC Integrator" - }, - { - "EEID": 258646, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258646, - "Created": "2023-04-25T19:20:28Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T19:20:28Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258643, - "SinkComponentName": "SST PoC Backend" - }, - { - "EEID": 258650, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258650, - "Created": "2023-04-25T19:22:10Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T19:22:10Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258647, - "SinkComponentName": "SST PoC Database" - }, - { - "EEID": 258665, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258665, - "Created": "2023-04-25T19:48:54Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T19:48:54Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258662, - "SinkComponentName": "SST PoC Static Content" - }, - { - "EEID": 259247, - "Description": "", - "Name": "Hosts", - "BaselineElementEEID": 259247, - "Created": "2023-04-25T21:00:34Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T21:00:34Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 13890, - "ConnectionTypeName": "Hosts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": 259251, - "SourceComponentEEID": 259244, - "SourceComponentName": "Azure - IFA - Zona 1 (PoC Irius Risk)", - "SinkComponentEEID": 258631, - "SinkComponentName": "SST PoC Webpage" - }, - { - "EEID": 259258, - "Description": "", - "Name": "Hosts", - "BaselineElementEEID": 259258, - "Created": "2023-04-25T21:01:08Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T21:01:08Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 13890, - "ConnectionTypeName": "Hosts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": 259262, - "SourceComponentEEID": 259255, - "SourceComponentName": "Azure - IFA - Zona 2 (PoC Irius Risk)", - "SinkComponentEEID": 258631, - "SinkComponentName": "SST PoC Webpage" - }, - { - "EEID": 258632, - "Description": "", - "Name": "Requires", - "BaselineElementEEID": 258632, - "Created": "2023-04-25T19:07:36Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T19:07:36Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 141, - "ConnectionTypeName": "Requires", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258631, - "SourceComponentName": "SST PoC Webpage", - "SinkComponentEEID": 51534, - "SinkComponentName": "Angular v12.0.0" - } - ] + "EEID": 258635, + "Description": "This is a project used for Irius Risk and Abacus integration purposes", + "Name": "POC00012023", + "BaselineElementEEID": 258635, + "Created": "2023-04-25T19:09:26Z", + "CreatedBy": "username", + "Modified": "2023-05-03T12:39:25Z", + "ModifiedBy": "username", + "ComponentTypeEEID": 153, + "ComponentTypeName": "Project", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": 59571, + "OutConnections": [ + { + "EEID": 258636, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258636, + "Created": "2023-04-25T19:10:03Z", + "CreatedBy": "username", + "Modified": "2023-04-25T19:10:03Z", + "ModifiedBy": "username", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258631, + "SinkComponentName": "SST PoC Webpage" + }, + { + "EEID": 258642, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258642, + "Created": "2023-04-25T19:19:05Z", + "CreatedBy": "username", + "Modified": "2023-04-25T19:19:05Z", + "ModifiedBy": "username", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258639, + "SinkComponentName": "SST PoC Integrator" + }, + { + "EEID": 258646, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258646, + "Created": "2023-04-25T19:20:28Z", + "CreatedBy": "username", + "Modified": "2023-04-25T19:20:28Z", + "ModifiedBy": "username", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258643, + "SinkComponentName": "SST PoC Backend" + }, + { + "EEID": 258650, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258650, + "Created": "2023-04-25T19:22:10Z", + "CreatedBy": "username", + "Modified": "2023-04-25T19:22:10Z", + "ModifiedBy": "username", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258647, + "SinkComponentName": "SST PoC Database" + }, + { + "EEID": 258665, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258665, + "Created": "2023-04-25T19:48:54Z", + "CreatedBy": "username", + "Modified": "2023-04-25T19:48:54Z", + "ModifiedBy": "username", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258662, + "SinkComponentName": "SST PoC Static Content" + }, + { + "EEID": 258636, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258636, + "Created": "2023-04-25T19:10:03Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T19:10:03Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258631, + "SinkComponentName": "SST PoC Webpage" + }, + { + "EEID": 258642, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258642, + "Created": "2023-04-25T19:19:05Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T19:19:05Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258639, + "SinkComponentName": "SST PoC Integrator" + }, + { + "EEID": 258646, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258646, + "Created": "2023-04-25T19:20:28Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T19:20:28Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258643, + "SinkComponentName": "SST PoC Backend" + }, + { + "EEID": 258650, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258650, + "Created": "2023-04-25T19:22:10Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T19:22:10Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258647, + "SinkComponentName": "SST PoC Database" + }, + { + "EEID": 258665, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258665, + "Created": "2023-04-25T19:48:54Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T19:48:54Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258662, + "SinkComponentName": "SST PoC Static Content" + }, + { + "EEID": 259247, + "Description": "", + "Name": "Hosts", + "BaselineElementEEID": 259247, + "Created": "2023-04-25T21:00:34Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T21:00:34Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 13890, + "ConnectionTypeName": "Hosts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": 259251, + "SourceComponentEEID": 259244, + "SourceComponentName": "Azure - IFA - Zona 1 (PoC Irius Risk)", + "SinkComponentEEID": 258631, + "SinkComponentName": "SST PoC Webpage" + }, + { + "EEID": 259258, + "Description": "", + "Name": "Hosts", + "BaselineElementEEID": 259258, + "Created": "2023-04-25T21:01:08Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T21:01:08Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 13890, + "ConnectionTypeName": "Hosts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": 259262, + "SourceComponentEEID": 259255, + "SourceComponentName": "Azure - IFA - Zona 2 (PoC Irius Risk)", + "SinkComponentEEID": 258631, + "SinkComponentName": "SST PoC Webpage" + }, + { + "EEID": 258632, + "Description": "", + "Name": "Requires", + "BaselineElementEEID": 258632, + "Created": "2023-04-25T19:07:36Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T19:07:36Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 141, + "ConnectionTypeName": "Requires", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258631, + "SourceComponentName": "SST PoC Webpage", + "SinkComponentEEID": 51534, + "SinkComponentName": "Angular v12.0.0" + } + ] } \ No newline at end of file diff --git a/slp_abacus/tests/resources/abacus/component-by-project.json b/slp_abacus/tests/resources/abacus/component-by-project.json index 3762af67..230d57af 100644 --- a/slp_abacus/tests/resources/abacus/component-by-project.json +++ b/slp_abacus/tests/resources/abacus/component-by-project.json @@ -1,117 +1,117 @@ { - "@odata.context": "https://CLIENTURL.avolutionsoftware.com/api/$metadata#Components", - "value": [ + "@odata.context": "https://CLIENTURL.avolutionsoftware.com/api/$metadata#Components", + "value": [ + { + "EEID": 258635, + "Description": "This is a project used for Irius Risk and Abacus integration purposes", + "Name": "POC00012023", + "BaselineElementEEID": 258635, + "Created": "2023-04-25T19:09:26Z", + "CreatedBy": "username", + "Modified": "2023-05-03T12:39:25Z", + "ModifiedBy": "username", + "ComponentTypeEEID": 153, + "ComponentTypeName": "Project", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": 59571, + "OutConnections": [ { - "EEID": 258635, - "Description": "This is a project used for Irius Risk and Abacus integration purposes", - "Name": "POC00012023", - "BaselineElementEEID": 258635, - "Created": "2023-04-25T19:09:26Z", - "CreatedBy": "username", - "Modified": "2023-05-03T12:39:25Z", - "ModifiedBy": "username", - "ComponentTypeEEID": 153, - "ComponentTypeName": "Project", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": 59571, - "OutConnections": [ - { - "EEID": 258636, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258636, - "Created": "2023-04-25T19:10:03Z", - "CreatedBy": "username", - "Modified": "2023-04-25T19:10:03Z", - "ModifiedBy": "username", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258631, - "SinkComponentName": "SST PoC Webpage" - }, - { - "EEID": 258642, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258642, - "Created": "2023-04-25T19:19:05Z", - "CreatedBy": "username", - "Modified": "2023-04-25T19:19:05Z", - "ModifiedBy": "username", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258639, - "SinkComponentName": "SST PoC Integrator" - }, - { - "EEID": 258646, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258646, - "Created": "2023-04-25T19:20:28Z", - "CreatedBy": "username", - "Modified": "2023-04-25T19:20:28Z", - "ModifiedBy": "username", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258643, - "SinkComponentName": "SST PoC Backend" - }, - { - "EEID": 258650, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258650, - "Created": "2023-04-25T19:22:10Z", - "CreatedBy": "username", - "Modified": "2023-04-25T19:22:10Z", - "ModifiedBy": "username", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258647, - "SinkComponentName": "SST PoC Database" - }, - { - "EEID": 258665, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258665, - "Created": "2023-04-25T19:48:54Z", - "CreatedBy": "username", - "Modified": "2023-04-25T19:48:54Z", - "ModifiedBy": "username", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258662, - "SinkComponentName": "SST PoC Static Content" - } - ] + "EEID": 258636, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258636, + "Created": "2023-04-25T19:10:03Z", + "CreatedBy": "username", + "Modified": "2023-04-25T19:10:03Z", + "ModifiedBy": "username", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258631, + "SinkComponentName": "SST PoC Webpage" + }, + { + "EEID": 258642, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258642, + "Created": "2023-04-25T19:19:05Z", + "CreatedBy": "username", + "Modified": "2023-04-25T19:19:05Z", + "ModifiedBy": "username", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258639, + "SinkComponentName": "SST PoC Integrator" + }, + { + "EEID": 258646, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258646, + "Created": "2023-04-25T19:20:28Z", + "CreatedBy": "username", + "Modified": "2023-04-25T19:20:28Z", + "ModifiedBy": "username", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258643, + "SinkComponentName": "SST PoC Backend" + }, + { + "EEID": 258650, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258650, + "Created": "2023-04-25T19:22:10Z", + "CreatedBy": "username", + "Modified": "2023-04-25T19:22:10Z", + "ModifiedBy": "username", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258647, + "SinkComponentName": "SST PoC Database" + }, + { + "EEID": 258665, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258665, + "Created": "2023-04-25T19:48:54Z", + "CreatedBy": "username", + "Modified": "2023-04-25T19:48:54Z", + "ModifiedBy": "username", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258662, + "SinkComponentName": "SST PoC Static Content" } - ] + ] + } + ] } \ No newline at end of file diff --git a/slp_abacus/tests/resources/abacus/elements-by-project.json b/slp_abacus/tests/resources/abacus/elements-by-project.json index fe46f441..66016575 100644 --- a/slp_abacus/tests/resources/abacus/elements-by-project.json +++ b/slp_abacus/tests/resources/abacus/elements-by-project.json @@ -1,122 +1,121 @@ - // https://santander.avolutionsoftware.com/api/Components?$filter=ArchitectureName eq 'F1RST' and ComponentTypeName eq 'Project' and Name eq 'POC00012023'&$expand=OutConnections($filter=SinkComponent/ComponentTypeName eq 'Digital Touchpoint' OR SinkComponent/ComponentTypeName eq 'Technical Component' OR SinkComponent/ComponentTypeName eq 'Repository'OR SinkComponent/ComponentTypeName eq 'Load Balancer') // get in f1rst architecture, for the project POC00012023 filtered by types 'Technical Component', 'Touchpoints' and 'Repositories' { - "@odata.context": "https://santander.avolutionsoftware.com/api/$metadata#Components", - "value": [ + "@odata.context": "https://santander.avolutionsoftware.com/api/$metadata#Components", + "value": [ + { + "EEID": 258635, + "Description": "This is a project used for Irius Risk and Abacus integration purposes", + "Name": "POC00012023", + "BaselineElementEEID": 258635, + "Created": "2023-04-25T19:09:26Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-05-03T12:39:25Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ComponentTypeEEID": 153, + "ComponentTypeName": "Project", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": 59571, + "OutConnections": [ + { + "EEID": 258636, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258636, + "Created": "2023-04-25T19:10:03Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T19:10:03Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258631, + "SinkComponentName": "SST PoC Webpage" + }, + { + "EEID": 258642, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258642, + "Created": "2023-04-25T19:19:05Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T19:19:05Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258639, + "SinkComponentName": "SST PoC Integrator" + }, + { + "EEID": 258646, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258646, + "Created": "2023-04-25T19:20:28Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T19:20:28Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258643, + "SinkComponentName": "SST PoC Backend" + }, + { + "EEID": 258650, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258650, + "Created": "2023-04-25T19:22:10Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T19:22:10Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258647, + "SinkComponentName": "SST PoC Database" + }, { - "EEID": 258635, - "Description": "This is a project used for Irius Risk and Abacus integration purposes", - "Name": "POC00012023", - "BaselineElementEEID": 258635, - "Created": "2023-04-25T19:09:26Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-05-03T12:39:25Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ComponentTypeEEID": 153, - "ComponentTypeName": "Project", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": 59571, - "OutConnections": [ - { - "EEID": 258636, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258636, - "Created": "2023-04-25T19:10:03Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T19:10:03Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258631, - "SinkComponentName": "SST PoC Webpage" - }, - { - "EEID": 258642, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258642, - "Created": "2023-04-25T19:19:05Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T19:19:05Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258639, - "SinkComponentName": "SST PoC Integrator" - }, - { - "EEID": 258646, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258646, - "Created": "2023-04-25T19:20:28Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T19:20:28Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258643, - "SinkComponentName": "SST PoC Backend" - }, - { - "EEID": 258650, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258650, - "Created": "2023-04-25T19:22:10Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T19:22:10Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258647, - "SinkComponentName": "SST PoC Database" - }, - { - "EEID": 258665, - "Description": "", - "Name": "Impacts", - "BaselineElementEEID": 258665, - "Created": "2023-04-25T19:48:54Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T19:48:54Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 173, - "ConnectionTypeName": "Impacts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258635, - "SourceComponentName": "POC00012023", - "SinkComponentEEID": 258662, - "SinkComponentName": "SST PoC Static Content" - } - ] + "EEID": 258665, + "Description": "", + "Name": "Impacts", + "BaselineElementEEID": 258665, + "Created": "2023-04-25T19:48:54Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T19:48:54Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 173, + "ConnectionTypeName": "Impacts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258635, + "SourceComponentName": "POC00012023", + "SinkComponentEEID": 258662, + "SinkComponentName": "SST PoC Static Content" } - ] + ] + } + ] } \ No newline at end of file diff --git a/slp_abacus/tests/resources/abacus/locations-by-component.json b/slp_abacus/tests/resources/abacus/locations-by-component.json index 5d08fa26..1ebf3fc9 100644 --- a/slp_abacus/tests/resources/abacus/locations-by-component.json +++ b/slp_abacus/tests/resources/abacus/locations-by-component.json @@ -1,48 +1,47 @@ - // https://santander.avolutionsoftware.com/api/Components(258631)/InConnections?$filter=ConnectionTypeEEID eq 13890 // getting locations filtered by a specfic component using the connection 'hosts' which has ID 13890 for the component "SST PoC Webpage" which has the ID 257831 { - "@odata.context": "https://santander.avolutionsoftware.com/api/$metadata#Connections", - "value": [ - { - "EEID": 259247, - "Description": "", - "Name": "Hosts", - "BaselineElementEEID": 259247, - "Created": "2023-04-25T21:00:34Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T21:00:34Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 13890, - "ConnectionTypeName": "Hosts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": 259251, - "SourceComponentEEID": 259244, - "SourceComponentName": "Azure - IFA - Zona 1 (PoC Irius Risk)", - "SinkComponentEEID": 258631, - "SinkComponentName": "SST PoC Webpage" - }, - { - "EEID": 259258, - "Description": "", - "Name": "Hosts", - "BaselineElementEEID": 259258, - "Created": "2023-04-25T21:01:08Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T21:01:08Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 13890, - "ConnectionTypeName": "Hosts", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": 259262, - "SourceComponentEEID": 259255, - "SourceComponentName": "Azure - IFA - Zona 2 (PoC Irius Risk)", - "SinkComponentEEID": 258631, - "SinkComponentName": "SST PoC Webpage" - } - ] + "@odata.context": "https://santander.avolutionsoftware.com/api/$metadata#Connections", + "value": [ + { + "EEID": 259247, + "Description": "", + "Name": "Hosts", + "BaselineElementEEID": 259247, + "Created": "2023-04-25T21:00:34Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T21:00:34Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 13890, + "ConnectionTypeName": "Hosts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": 259251, + "SourceComponentEEID": 259244, + "SourceComponentName": "Azure - IFA - Zona 1 (PoC Irius Risk)", + "SinkComponentEEID": 258631, + "SinkComponentName": "SST PoC Webpage" + }, + { + "EEID": 259258, + "Description": "", + "Name": "Hosts", + "BaselineElementEEID": 259258, + "Created": "2023-04-25T21:01:08Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T21:01:08Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 13890, + "ConnectionTypeName": "Hosts", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": 259262, + "SourceComponentEEID": 259255, + "SourceComponentName": "Azure - IFA - Zona 2 (PoC Irius Risk)", + "SinkComponentEEID": 258631, + "SinkComponentName": "SST PoC Webpage" + } + ] } \ No newline at end of file diff --git a/slp_abacus/tests/resources/abacus/platform-services-by-component.json b/slp_abacus/tests/resources/abacus/platform-services-by-component.json index bbd53157..5ea5d65e 100644 --- a/slp_abacus/tests/resources/abacus/platform-services-by-component.json +++ b/slp_abacus/tests/resources/abacus/platform-services-by-component.json @@ -3,26 +3,26 @@ // Out connections of type 'requires' which has the ID 141 for the component "SST PoC Webpage" which has the ID 258631 { - "@odata.context": "https://santander.avolutionsoftware.com/api/$metadata#Connections", - "value": [ - { - "EEID": 258632, - "Description": "", - "Name": "Requires", - "BaselineElementEEID": 258632, - "Created": "2023-04-25T19:07:36Z", - "CreatedBy": "Gabriel.Rensi.Silva", - "Modified": "2023-04-25T19:07:36Z", - "ModifiedBy": "Gabriel.Rensi.Silva", - "ConnectionTypeEEID": 141, - "ConnectionTypeName": "Requires", - "ArchitectureEEID": 5, - "ArchitectureName": "F1RST", - "ParentEEID": -1, - "SourceComponentEEID": 258631, - "SourceComponentName": "SST PoC Webpage", - "SinkComponentEEID": 51534, - "SinkComponentName": "Angular v12.0.0" - } - ] + "@odata.context": "https://santander.avolutionsoftware.com/api/$metadata#Connections", + "value": [ + { + "EEID": 258632, + "Description": "", + "Name": "Requires", + "BaselineElementEEID": 258632, + "Created": "2023-04-25T19:07:36Z", + "CreatedBy": "Gabriel.Rensi.Silva", + "Modified": "2023-04-25T19:07:36Z", + "ModifiedBy": "Gabriel.Rensi.Silva", + "ConnectionTypeEEID": 141, + "ConnectionTypeName": "Requires", + "ArchitectureEEID": 5, + "ArchitectureName": "F1RST", + "ParentEEID": -1, + "SourceComponentEEID": 258631, + "SourceComponentName": "SST PoC Webpage", + "SinkComponentEEID": 51534, + "SinkComponentName": "Angular v12.0.0" + } + ] } \ No newline at end of file diff --git a/slp_abacus/tests/resources/abacus/iriusrisk-abacus-mapping.yaml b/slp_abacus/tests/resources/mapping/iriusrisk-abacus-mapping.yaml similarity index 86% rename from slp_abacus/tests/resources/abacus/iriusrisk-abacus-mapping.yaml rename to slp_abacus/tests/resources/mapping/iriusrisk-abacus-mapping.yaml index 2d96f108..16304594 100644 --- a/slp_abacus/tests/resources/abacus/iriusrisk-abacus-mapping.yaml +++ b/slp_abacus/tests/resources/mapping/iriusrisk-abacus-mapping.yaml @@ -1,6 +1,6 @@ trustzones: - - label: Public Cloud - type: b61d6911-338d-46a8-9f39-8dcd24abfe91 + - label: Public Cloud + type: b61d6911-338d-46a8-9f39-8dcd24abfe91 default: true components: diff --git a/slp_abacus/tests/util/builders.py b/slp_abacus/tests/util/builders.py index 7b0be3d7..dea2881f 100644 --- a/slp_abacus/tests/util/builders.py +++ b/slp_abacus/tests/util/builders.py @@ -17,7 +17,8 @@ def build_trustzone(trustzone_id: str = 'tz-id', type: str = 'tz-type', name: st return DiagramTrustZone(id=trustzone_id, name=name or f'{trustzone_id} name', type=type, default=default) -def build_component(component_id: str = 'c-id', parent_id: str = None, name: str = None, shape_type: str = None) -> DiagramComponent: +def build_component(component_id: str = 'c-id', parent_id: str = None, name: str = None, + shape_type: str = None) -> DiagramComponent: component = DiagramComponent(id=component_id, name=name or component_id) component.otm.parent = parent_id component.shape_type = shape_type diff --git a/slp_abacus/tests/validate/__init__.py b/slp_abacus/tests/validate/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/slp_abacus/tests/validate/test_abacus_validator.py b/slp_abacus/tests/validate/test_abacus_validator.py new file mode 100644 index 00000000..a353c734 --- /dev/null +++ b/slp_abacus/tests/validate/test_abacus_validator.py @@ -0,0 +1,77 @@ +from unittest.mock import patch, MagicMock + +import pytest + +from sl_util.sl_util import secure_regex as re +from sl_util.sl_util.file_utils import get_byte_data +from slp_abacus.slp_abacus.validate.abacus_validator import AbacusValidator +from slp_abacus.tests.resources.test_resource_paths import wrong_root_abacus, wrong_mxcell_abacus, wrong_mxfile_abacus, \ + wrong_mxgraphmodel_abacus, not_xml, abacus_merged +from slp_base import DiagramFileNotValidError, CommonError + +filename_pattern = re.compile('^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}\\.[abacus|xml]') + + +def create_mock_file(size: int) -> bytes: + return bytes('A' * size, 'utf-8') + + +class TestAbacusValidator: + + @pytest.mark.parametrize('size_value', [ + pytest.param(9, id="less than expected min"), + pytest.param((10 * 1024 * 1024) + 1, id="more than expected max") + ]) + def test_invalid_sizes(self, size_value: int): + # GIVEN the validator with an invalid size + validator = AbacusValidator(create_mock_file(size_value)) + + # WHEN we validate + with pytest.raises(DiagramFileNotValidError) as error_info: + validator.validate() + + # THEN the error raised is as expected + assert error_info.typename == 'DiagramFileNotValidError' + assert error_info.value.message == 'Provided diag_file is not valid. Invalid size' + + @patch('slp_abacus.slp_abacus.validate.abacus_validator.get_file_type_by_content') + @pytest.mark.parametrize('mime', [ + 'application/zip', 'application/pdf', 'text/html' + ]) + def test_invalid_mimetype(self, mock_content_type, mime): + # GIVEN the validator with a valid size + file = MagicMock() + file.__len__.return_value = 10 + + # AND different types + mock_content_type.return_value = mime + + # AND the validator + validator = AbacusValidator(file) + + # WHEN we validate + with pytest.raises(DiagramFileNotValidError) as error_info: + validator.validate() + + # THEN the error raised is as expected + assert error_info.typename == 'DiagramFileNotValidError' + assert error_info.value.message == 'Invalid content type for diag_file' + + @pytest.mark.parametrize('mime, size, filepath', [ + pytest.param('application/octet-stream', 10, abacus_merged, id='encoded-tiny-binary'), + pytest.param('application/json', 10 * 1024 * 1024, abacus_merged, id='xml-big-xml'), + pytest.param('text/plain', 10 * 1024 * 1024, abacus_merged, id='encoded-big-text') + ]) + def test_valid_file(self, mime: str, size: int, filepath: str): + # GIVEN the valid file + file = get_byte_data(filepath) + + # AND the validator + validator = AbacusValidator(file) + + # WHEN we validate + # THEN no CommonError is raised + try: + validator.validate() + except CommonError: + assert False