From db6443f1381cc1173f17c2f98e845a5af5daf72d Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Wed, 12 Feb 2025 16:56:25 +0100 Subject: [PATCH] tests: simplify tests for `crypto_refs` Signed-off-by: Jan Kowalleck --- tests/_data/models.py | 29 +--------- ...t_bom_for_issue_692_components-1.0.xml.bin | 10 ---- ...t_bom_for_issue_692_components-1.1.xml.bin | 9 --- ..._bom_for_issue_692_components-1.2.json.bin | 35 ------------ ...t_bom_for_issue_692_components-1.2.xml.bin | 22 -------- ..._bom_for_issue_692_components-1.3.json.bin | 35 ------------ ...t_bom_for_issue_692_components-1.3.xml.bin | 22 -------- ..._bom_for_issue_692_components-1.4.json.bin | 34 ------------ ...t_bom_for_issue_692_components-1.4.xml.bin | 21 ------- ..._bom_for_issue_692_components-1.5.json.bin | 44 --------------- ...t_bom_for_issue_692_components-1.5.xml.bin | 25 --------- ..._bom_for_issue_692_components-1.6.json.bin | 55 ------------------- ...t_bom_for_issue_692_components-1.6.xml.bin | 34 ------------ ...bom_v1_6_with_crypto_protocol-1.6.json.bin | 4 ++ ..._bom_v1_6_with_crypto_protocol-1.6.xml.bin | 2 + 15 files changed, 7 insertions(+), 374 deletions(-) delete mode 100644 tests/_data/snapshots/get_bom_for_issue_692_components-1.0.xml.bin delete mode 100644 tests/_data/snapshots/get_bom_for_issue_692_components-1.1.xml.bin delete mode 100644 tests/_data/snapshots/get_bom_for_issue_692_components-1.2.json.bin delete mode 100644 tests/_data/snapshots/get_bom_for_issue_692_components-1.2.xml.bin delete mode 100644 tests/_data/snapshots/get_bom_for_issue_692_components-1.3.json.bin delete mode 100644 tests/_data/snapshots/get_bom_for_issue_692_components-1.3.xml.bin delete mode 100644 tests/_data/snapshots/get_bom_for_issue_692_components-1.4.json.bin delete mode 100644 tests/_data/snapshots/get_bom_for_issue_692_components-1.4.xml.bin delete mode 100644 tests/_data/snapshots/get_bom_for_issue_692_components-1.5.json.bin delete mode 100644 tests/_data/snapshots/get_bom_for_issue_692_components-1.5.xml.bin delete mode 100644 tests/_data/snapshots/get_bom_for_issue_692_components-1.6.json.bin delete mode 100644 tests/_data/snapshots/get_bom_for_issue_692_components-1.6.xml.bin diff --git a/tests/_data/models.py b/tests/_data/models.py index c2c9d896..60a823c8 100644 --- a/tests/_data/models.py +++ b/tests/_data/models.py @@ -239,6 +239,7 @@ def get_crypto_properties_protocol() -> CryptoProperties: ] ) ], + crypto_refs=[BomRef('for-test-2'), BomRef('for-test-1')], ), oid='an-oid-here' ) @@ -708,33 +709,6 @@ def get_bom_for_issue_328_components() -> Bom: return bom -def get_bom_for_issue_692_components() -> Bom: - """regression test for issue #692 - see https://github.com/CycloneDX/cyclonedx-python-lib/issues/692 - """ - bom = _make_bom() - - comp_root = Component(type=ComponentType.APPLICATION, - name='my application', version='1', bom_ref='my-project') - comp_test = Component( - name='comp_test', - type=ComponentType.APPLICATION, - bom_ref='crypto/protocol/test', - crypto_properties=CryptoProperties( - asset_type=CryptoAssetType.PROTOCOL, - protocol_properties=ProtocolProperties( - type=ProtocolPropertiesType.TLS, - version='1.2', - crypto_refs=[BomRef(value='for-test')] - ), - oid='1.3.18.0.2.32.104', - )) - bom.metadata.component = comp_root - bom.register_dependency(comp_root, [comp_test]) - bom.components = [comp_test] - return bom - - def get_component_setuptools_complete(include_pedigree: bool = True) -> Component: component = get_component_setuptools_simple(bom_ref='my-specific-bom-ref-for-dings') component.supplier = get_org_entity_1() @@ -1476,5 +1450,4 @@ def get_bom_with_definitions_and_detailed_standards() -> Bom: get_bom_with_lifecycles, get_bom_with_definitions_standards, get_bom_with_definitions_and_detailed_standards, - get_bom_for_issue_692_components, } diff --git a/tests/_data/snapshots/get_bom_for_issue_692_components-1.0.xml.bin b/tests/_data/snapshots/get_bom_for_issue_692_components-1.0.xml.bin deleted file mode 100644 index 0b4f3121..00000000 --- a/tests/_data/snapshots/get_bom_for_issue_692_components-1.0.xml.bin +++ /dev/null @@ -1,10 +0,0 @@ - - - - - comp_test - - false - - - diff --git a/tests/_data/snapshots/get_bom_for_issue_692_components-1.1.xml.bin b/tests/_data/snapshots/get_bom_for_issue_692_components-1.1.xml.bin deleted file mode 100644 index cdbdc649..00000000 --- a/tests/_data/snapshots/get_bom_for_issue_692_components-1.1.xml.bin +++ /dev/null @@ -1,9 +0,0 @@ - - - - - comp_test - - - - diff --git a/tests/_data/snapshots/get_bom_for_issue_692_components-1.2.json.bin b/tests/_data/snapshots/get_bom_for_issue_692_components-1.2.json.bin deleted file mode 100644 index c85fed05..00000000 --- a/tests/_data/snapshots/get_bom_for_issue_692_components-1.2.json.bin +++ /dev/null @@ -1,35 +0,0 @@ -{ - "components": [ - { - "bom-ref": "crypto/protocol/test", - "name": "comp_test", - "type": "application", - "version": "" - } - ], - "dependencies": [ - { - "ref": "crypto/protocol/test" - }, - { - "dependsOn": [ - "crypto/protocol/test" - ], - "ref": "my-project" - } - ], - "metadata": { - "component": { - "bom-ref": "my-project", - "name": "my application", - "type": "application", - "version": "1" - }, - "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_for_issue_692_components-1.2.xml.bin b/tests/_data/snapshots/get_bom_for_issue_692_components-1.2.xml.bin deleted file mode 100644 index 7159c20c..00000000 --- a/tests/_data/snapshots/get_bom_for_issue_692_components-1.2.xml.bin +++ /dev/null @@ -1,22 +0,0 @@ - - - - 2023-01-07T13:44:32.312678+00:00 - - my application - 1 - - - - - comp_test - - - - - - - - - - diff --git a/tests/_data/snapshots/get_bom_for_issue_692_components-1.3.json.bin b/tests/_data/snapshots/get_bom_for_issue_692_components-1.3.json.bin deleted file mode 100644 index 0e73c637..00000000 --- a/tests/_data/snapshots/get_bom_for_issue_692_components-1.3.json.bin +++ /dev/null @@ -1,35 +0,0 @@ -{ - "components": [ - { - "bom-ref": "crypto/protocol/test", - "name": "comp_test", - "type": "application", - "version": "" - } - ], - "dependencies": [ - { - "ref": "crypto/protocol/test" - }, - { - "dependsOn": [ - "crypto/protocol/test" - ], - "ref": "my-project" - } - ], - "metadata": { - "component": { - "bom-ref": "my-project", - "name": "my application", - "type": "application", - "version": "1" - }, - "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_for_issue_692_components-1.3.xml.bin b/tests/_data/snapshots/get_bom_for_issue_692_components-1.3.xml.bin deleted file mode 100644 index 1a345752..00000000 --- a/tests/_data/snapshots/get_bom_for_issue_692_components-1.3.xml.bin +++ /dev/null @@ -1,22 +0,0 @@ - - - - 2023-01-07T13:44:32.312678+00:00 - - my application - 1 - - - - - comp_test - - - - - - - - - - diff --git a/tests/_data/snapshots/get_bom_for_issue_692_components-1.4.json.bin b/tests/_data/snapshots/get_bom_for_issue_692_components-1.4.json.bin deleted file mode 100644 index de8c1ced..00000000 --- a/tests/_data/snapshots/get_bom_for_issue_692_components-1.4.json.bin +++ /dev/null @@ -1,34 +0,0 @@ -{ - "components": [ - { - "bom-ref": "crypto/protocol/test", - "name": "comp_test", - "type": "application" - } - ], - "dependencies": [ - { - "ref": "crypto/protocol/test" - }, - { - "dependsOn": [ - "crypto/protocol/test" - ], - "ref": "my-project" - } - ], - "metadata": { - "component": { - "bom-ref": "my-project", - "name": "my application", - "type": "application", - "version": "1" - }, - "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_for_issue_692_components-1.4.xml.bin b/tests/_data/snapshots/get_bom_for_issue_692_components-1.4.xml.bin deleted file mode 100644 index 790a9c18..00000000 --- a/tests/_data/snapshots/get_bom_for_issue_692_components-1.4.xml.bin +++ /dev/null @@ -1,21 +0,0 @@ - - - - 2023-01-07T13:44:32.312678+00:00 - - my application - 1 - - - - - comp_test - - - - - - - - - diff --git a/tests/_data/snapshots/get_bom_for_issue_692_components-1.5.json.bin b/tests/_data/snapshots/get_bom_for_issue_692_components-1.5.json.bin deleted file mode 100644 index 2e82d6fe..00000000 --- a/tests/_data/snapshots/get_bom_for_issue_692_components-1.5.json.bin +++ /dev/null @@ -1,44 +0,0 @@ -{ - "components": [ - { - "bom-ref": "crypto/protocol/test", - "name": "comp_test", - "type": "application" - } - ], - "dependencies": [ - { - "ref": "crypto/protocol/test" - }, - { - "dependsOn": [ - "crypto/protocol/test" - ], - "ref": "my-project" - } - ], - "metadata": { - "component": { - "bom-ref": "my-project", - "name": "my application", - "type": "application", - "version": "1" - }, - "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_for_issue_692_components-1.5.xml.bin b/tests/_data/snapshots/get_bom_for_issue_692_components-1.5.xml.bin deleted file mode 100644 index c762bfa1..00000000 --- a/tests/_data/snapshots/get_bom_for_issue_692_components-1.5.xml.bin +++ /dev/null @@ -1,25 +0,0 @@ - - - - 2023-01-07T13:44:32.312678+00:00 - - my application - 1 - - - - - comp_test - - - - - - - - - - val1 - val2 - - diff --git a/tests/_data/snapshots/get_bom_for_issue_692_components-1.6.json.bin b/tests/_data/snapshots/get_bom_for_issue_692_components-1.6.json.bin deleted file mode 100644 index 0e0cba5d..00000000 --- a/tests/_data/snapshots/get_bom_for_issue_692_components-1.6.json.bin +++ /dev/null @@ -1,55 +0,0 @@ -{ - "components": [ - { - "bom-ref": "crypto/protocol/test", - "cryptoProperties": { - "assetType": "protocol", - "oid": "1.3.18.0.2.32.104", - "protocolProperties": { - "cryptoRefArray": [ - "for-test" - ], - "type": "tls", - "version": "1.2" - } - }, - "name": "comp_test", - "type": "application" - } - ], - "dependencies": [ - { - "ref": "crypto/protocol/test" - }, - { - "dependsOn": [ - "crypto/protocol/test" - ], - "ref": "my-project" - } - ], - "metadata": { - "component": { - "bom-ref": "my-project", - "name": "my application", - "type": "application", - "version": "1" - }, - "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_for_issue_692_components-1.6.xml.bin b/tests/_data/snapshots/get_bom_for_issue_692_components-1.6.xml.bin deleted file mode 100644 index 7b536be5..00000000 --- a/tests/_data/snapshots/get_bom_for_issue_692_components-1.6.xml.bin +++ /dev/null @@ -1,34 +0,0 @@ - - - - 2023-01-07T13:44:32.312678+00:00 - - my application - 1 - - - - - comp_test - - protocol - - tls - 1.2 - for-test - - 1.3.18.0.2.32.104 - - - - - - - - - - - val1 - val2 - - diff --git a/tests/_data/snapshots/get_bom_v1_6_with_crypto_protocol-1.6.json.bin b/tests/_data/snapshots/get_bom_v1_6_with_crypto_protocol-1.6.json.bin index ccf5bc61..cd0c2007 100644 --- a/tests/_data/snapshots/get_bom_v1_6_with_crypto_protocol-1.6.json.bin +++ b/tests/_data/snapshots/get_bom_v1_6_with_crypto_protocol-1.6.json.bin @@ -38,6 +38,10 @@ "name": "TLS_CHACHA20_POLY1305_SHA256" } ], + "cryptoRefArray": [ + "for-test-1", + "for-test-2" + ], "type": "tls", "version": "1.3" } diff --git a/tests/_data/snapshots/get_bom_v1_6_with_crypto_protocol-1.6.xml.bin b/tests/_data/snapshots/get_bom_v1_6_with_crypto_protocol-1.6.xml.bin index 96a5db6e..5392e824 100644 --- a/tests/_data/snapshots/get_bom_v1_6_with_crypto_protocol-1.6.xml.bin +++ b/tests/_data/snapshots/get_bom_v1_6_with_crypto_protocol-1.6.xml.bin @@ -44,6 +44,8 @@ + for-test-1 + for-test-2 an-oid-here