From 095d99a01ffe602072258719d3516d86f82b97d7 Mon Sep 17 00:00:00 2001 From: Hakan Dilek Date: Wed, 16 Oct 2024 23:18:10 +0200 Subject: [PATCH] feat: add test fixtures related to bom.definitions for #697 Signed-off-by: Hakan Dilek --- tests/_data/models.py | 59 +++++++++++++++++++ ...nitions_and_detailed_standards-1.0.xml.bin | 4 ++ ...nitions_and_detailed_standards-1.1.xml.bin | 4 ++ ...itions_and_detailed_standards-1.2.json.bin | 10 ++++ ...nitions_and_detailed_standards-1.2.xml.bin | 6 ++ ...itions_and_detailed_standards-1.3.json.bin | 10 ++++ ...nitions_and_detailed_standards-1.3.xml.bin | 6 ++ ...itions_and_detailed_standards-1.4.json.bin | 10 ++++ ...nitions_and_detailed_standards-1.4.xml.bin | 6 ++ ...itions_and_detailed_standards-1.5.json.bin | 20 +++++++ ...nitions_and_detailed_standards-1.5.xml.bin | 10 ++++ ...bom_with_definitions_standards-1.0.xml.bin | 4 ++ ...bom_with_definitions_standards-1.1.xml.bin | 4 ++ ...om_with_definitions_standards-1.2.json.bin | 10 ++++ ...bom_with_definitions_standards-1.2.xml.bin | 6 ++ ...om_with_definitions_standards-1.3.json.bin | 10 ++++ ...bom_with_definitions_standards-1.3.xml.bin | 6 ++ ...om_with_definitions_standards-1.4.json.bin | 10 ++++ ...bom_with_definitions_standards-1.4.xml.bin | 6 ++ ...om_with_definitions_standards-1.5.json.bin | 20 +++++++ ...bom_with_definitions_standards-1.5.xml.bin | 10 ++++ ...om_with_definitions_standards-1.6.json.bin | 36 +++++++++++ ...bom_with_definitions_standards-1.6.xml.bin | 25 ++++++++ 23 files changed, 292 insertions(+) create mode 100644 tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.0.xml.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.1.xml.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.2.json.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.2.xml.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.3.json.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.3.xml.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.4.json.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.4.xml.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.5.json.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.5.xml.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_standards-1.0.xml.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_standards-1.1.xml.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_standards-1.2.json.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_standards-1.2.xml.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_standards-1.3.json.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_standards-1.3.xml.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_standards-1.4.json.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_standards-1.4.xml.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_standards-1.5.json.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_standards-1.5.xml.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_standards-1.6.json.bin create mode 100644 tests/_data/snapshots/get_bom_with_definitions_standards-1.6.xml.bin diff --git a/tests/_data/models.py b/tests/_data/models.py index 72504e83..ccbe0692 100644 --- a/tests/_data/models.py +++ b/tests/_data/models.py @@ -78,6 +78,7 @@ RelatedCryptoMaterialState, RelatedCryptoMaterialType, ) +from cyclonedx.model.definition import CreId, DefinitionRepository, Level, Requirement, Standard from cyclonedx.model.dependency import Dependency from cyclonedx.model.impact_analysis import ( ImpactAnalysisAffectedStatus, @@ -1273,6 +1274,62 @@ def get_bom_for_issue_630_empty_property() -> Bom: }) +def get_bom_with_definitions_standards() -> Bom: + """ + Returns a BOM with definitions and standards only. + """ + return _make_bom( + definitions=DefinitionRepository(standards=[ + Standard(name='Some Standard', version='1.2.3', description='Some description', + owner='Some Owner', external_references=[get_external_reference_2()] + ) + ]) + ) + + +def get_bom_with_definitions_and_detailed_standards() -> Bom: + """ + Returns a BOM with definitions and multiple detailed standards including requirements and levels. + """ + return _make_bom( + definitions=DefinitionRepository( + standards=[ + Standard(name='Some Standard', version='1.2.3', description='Some description', + owner='Some Owner', external_references=[get_external_reference_1()], + requirements=[ + Requirement(identifier='REQ-1', title='Requirement 1', text='some requirement text', + bom_ref='req-1', descriptions=['Requirement 1 described here', 'and here'], + open_cre=[CreId('CRE:1-2')], properties=[Property(name='key1', value='val1')] + ), + Requirement(identifier='REQ-2', title='Requirement 2', text='some requirement text', + bom_ref='req-2', descriptions=['Requirement 2 described here'], + open_cre=[CreId('CRE:1-2'), CreId('CRE:3-4')], + properties=[Property(name='key2', value='val2')] + ), + ], + levels=[ + Level(identifier='LVL-1', title='Level 1', description='Level 1 description', + bom_ref='lvl-1', requirements=['req-1', 'req-2']), + Level(identifier='LVL-2', title='Level 2', description='Level 2 description', + bom_ref='lvl-2', requirements=['req-2']) + ]), + Standard(name='Another Standard', version='1.0.0', description='Another description', + owner='Another Owner', external_references=[get_external_reference_2()], + requirements=[ + Requirement(identifier='REQ-3', title='Requirement 3', text='some requirement text', + bom_ref='req-3', descriptions=['Requirement 3 described here', 'and here'], + open_cre=[CreId('CRE:5-6'), CreId('CRE:7-8')], + properties=[Property(name='key3', value='val3')] + ) + ], + levels=[ + Level(identifier='LVL-3', title='Level 3', description='Level 3 description', + bom_ref='lvl-3', requirements=['req-3']) + ]) + ] + )) + + # --- @@ -1318,4 +1375,6 @@ def get_bom_for_issue_630_empty_property() -> Bom: get_bom_for_issue_598_multiple_components_with_purl_qualifiers, get_bom_with_component_setuptools_with_v16_fields, get_bom_for_issue_630_empty_property, + get_bom_with_definitions_standards, + get_bom_with_definitions_and_detailed_standards, } diff --git a/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.0.xml.bin b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.0.xml.bin new file mode 100644 index 00000000..acb06612 --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.0.xml.bin @@ -0,0 +1,4 @@ + + + + diff --git a/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.1.xml.bin b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.1.xml.bin new file mode 100644 index 00000000..55ef5cda --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.1.xml.bin @@ -0,0 +1,4 @@ + + + + diff --git a/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.2.json.bin b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.2.json.bin new file mode 100644 index 00000000..8f473bd3 --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.2.json.bin @@ -0,0 +1,10 @@ +{ + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.2b.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.2" +} \ No newline at end of file diff --git a/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.2.xml.bin b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.2.xml.bin new file mode 100644 index 00000000..df1938ec --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.2.xml.bin @@ -0,0 +1,6 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + diff --git a/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.3.json.bin b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.3.json.bin new file mode 100644 index 00000000..02943890 --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.3.json.bin @@ -0,0 +1,10 @@ +{ + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.3a.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.3" +} \ No newline at end of file diff --git a/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.3.xml.bin b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.3.xml.bin new file mode 100644 index 00000000..8341ff60 --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.3.xml.bin @@ -0,0 +1,6 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + diff --git a/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.4.json.bin b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.4.json.bin new file mode 100644 index 00000000..48f1745d --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.4.json.bin @@ -0,0 +1,10 @@ +{ + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.4.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.4" +} \ No newline at end of file diff --git a/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.4.xml.bin b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.4.xml.bin new file mode 100644 index 00000000..d0a7d4c9 --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.4.xml.bin @@ -0,0 +1,6 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + diff --git a/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.5.json.bin b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.5.json.bin new file mode 100644 index 00000000..57b5e590 --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.5.json.bin @@ -0,0 +1,20 @@ +{ + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.5" +} \ No newline at end of file diff --git a/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.5.xml.bin b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.5.xml.bin new file mode 100644 index 00000000..f952637c --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_and_detailed_standards-1.5.xml.bin @@ -0,0 +1,10 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + val1 + val2 + + diff --git a/tests/_data/snapshots/get_bom_with_definitions_standards-1.0.xml.bin b/tests/_data/snapshots/get_bom_with_definitions_standards-1.0.xml.bin new file mode 100644 index 00000000..acb06612 --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_standards-1.0.xml.bin @@ -0,0 +1,4 @@ + + + + diff --git a/tests/_data/snapshots/get_bom_with_definitions_standards-1.1.xml.bin b/tests/_data/snapshots/get_bom_with_definitions_standards-1.1.xml.bin new file mode 100644 index 00000000..55ef5cda --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_standards-1.1.xml.bin @@ -0,0 +1,4 @@ + + + + diff --git a/tests/_data/snapshots/get_bom_with_definitions_standards-1.2.json.bin b/tests/_data/snapshots/get_bom_with_definitions_standards-1.2.json.bin new file mode 100644 index 00000000..8f473bd3 --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_standards-1.2.json.bin @@ -0,0 +1,10 @@ +{ + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.2b.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.2" +} \ No newline at end of file diff --git a/tests/_data/snapshots/get_bom_with_definitions_standards-1.2.xml.bin b/tests/_data/snapshots/get_bom_with_definitions_standards-1.2.xml.bin new file mode 100644 index 00000000..df1938ec --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_standards-1.2.xml.bin @@ -0,0 +1,6 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + diff --git a/tests/_data/snapshots/get_bom_with_definitions_standards-1.3.json.bin b/tests/_data/snapshots/get_bom_with_definitions_standards-1.3.json.bin new file mode 100644 index 00000000..02943890 --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_standards-1.3.json.bin @@ -0,0 +1,10 @@ +{ + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.3a.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.3" +} \ No newline at end of file diff --git a/tests/_data/snapshots/get_bom_with_definitions_standards-1.3.xml.bin b/tests/_data/snapshots/get_bom_with_definitions_standards-1.3.xml.bin new file mode 100644 index 00000000..8341ff60 --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_standards-1.3.xml.bin @@ -0,0 +1,6 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + diff --git a/tests/_data/snapshots/get_bom_with_definitions_standards-1.4.json.bin b/tests/_data/snapshots/get_bom_with_definitions_standards-1.4.json.bin new file mode 100644 index 00000000..48f1745d --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_standards-1.4.json.bin @@ -0,0 +1,10 @@ +{ + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.4.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.4" +} \ No newline at end of file diff --git a/tests/_data/snapshots/get_bom_with_definitions_standards-1.4.xml.bin b/tests/_data/snapshots/get_bom_with_definitions_standards-1.4.xml.bin new file mode 100644 index 00000000..d0a7d4c9 --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_standards-1.4.xml.bin @@ -0,0 +1,6 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + diff --git a/tests/_data/snapshots/get_bom_with_definitions_standards-1.5.json.bin b/tests/_data/snapshots/get_bom_with_definitions_standards-1.5.json.bin new file mode 100644 index 00000000..57b5e590 --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_standards-1.5.json.bin @@ -0,0 +1,20 @@ +{ + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.5" +} \ No newline at end of file diff --git a/tests/_data/snapshots/get_bom_with_definitions_standards-1.5.xml.bin b/tests/_data/snapshots/get_bom_with_definitions_standards-1.5.xml.bin new file mode 100644 index 00000000..f952637c --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_standards-1.5.xml.bin @@ -0,0 +1,10 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + val1 + val2 + + diff --git a/tests/_data/snapshots/get_bom_with_definitions_standards-1.6.json.bin b/tests/_data/snapshots/get_bom_with_definitions_standards-1.6.json.bin new file mode 100644 index 00000000..0e831517 --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_standards-1.6.json.bin @@ -0,0 +1,36 @@ +{ + "definitions": { + "standards": [ + { + "description": "Some description", + "externalReferences": [ + { + "type": "website", + "url": "https://cyclonedx.org" + } + ], + "name": "Some Standard", + "owner": "Some Owner", + "version": "1.2.3" + } + ] + }, + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.6" +} \ No newline at end of file diff --git a/tests/_data/snapshots/get_bom_with_definitions_standards-1.6.xml.bin b/tests/_data/snapshots/get_bom_with_definitions_standards-1.6.xml.bin new file mode 100644 index 00000000..212fca8f --- /dev/null +++ b/tests/_data/snapshots/get_bom_with_definitions_standards-1.6.xml.bin @@ -0,0 +1,25 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + val1 + val2 + + + + + Some Standard + 1.2.3 + Some description + Some Owner + + + https://cyclonedx.org + + + + + +