From ebef5f212fec13fc8c9bf00553f9bf3f77a0d3f6 Mon Sep 17 00:00:00 2001 From: Paul Horton Date: Wed, 27 Jul 2022 17:58:25 +0100 Subject: [PATCH] aded XML output tests for Issue #275 Signed-off-by: Paul Horton --- .../xml/1.0/bom_issue_275_components.xml | 22 ++++++ .../xml/1.1/bom_issue_275_components.xml | 19 +++++ .../xml/1.2/bom_issue_275_components.xml | 43 ++++++++++++ .../xml/1.3/bom_issue_275_components.xml | 43 ++++++++++++ .../xml/1.4/bom_issue_275_components.xml | 69 +++++++++++++++++++ tests/test_output_xml.py | 31 +++++++++ 6 files changed, 227 insertions(+) create mode 100644 tests/fixtures/xml/1.0/bom_issue_275_components.xml create mode 100644 tests/fixtures/xml/1.1/bom_issue_275_components.xml create mode 100644 tests/fixtures/xml/1.2/bom_issue_275_components.xml create mode 100644 tests/fixtures/xml/1.3/bom_issue_275_components.xml create mode 100644 tests/fixtures/xml/1.4/bom_issue_275_components.xml diff --git a/tests/fixtures/xml/1.0/bom_issue_275_components.xml b/tests/fixtures/xml/1.0/bom_issue_275_components.xml new file mode 100644 index 00000000..c8a909c2 --- /dev/null +++ b/tests/fixtures/xml/1.0/bom_issue_275_components.xml @@ -0,0 +1,22 @@ + + + + + comp_a + 1.0.0 + false + + + comp_b + 1.0.0 + false + + + comp_c + 1.0.0 + false + + + + + \ No newline at end of file diff --git a/tests/fixtures/xml/1.1/bom_issue_275_components.xml b/tests/fixtures/xml/1.1/bom_issue_275_components.xml new file mode 100644 index 00000000..579eca0f --- /dev/null +++ b/tests/fixtures/xml/1.1/bom_issue_275_components.xml @@ -0,0 +1,19 @@ + + + + + comp_a + 1.0.0 + + + comp_b + 1.0.0 + + + comp_c + 1.0.0 + + + + + \ No newline at end of file diff --git a/tests/fixtures/xml/1.2/bom_issue_275_components.xml b/tests/fixtures/xml/1.2/bom_issue_275_components.xml new file mode 100644 index 00000000..f707c02c --- /dev/null +++ b/tests/fixtures/xml/1.2/bom_issue_275_components.xml @@ -0,0 +1,43 @@ + + + + 2021-09-01T10:50:42.051979+00:00 + + + CycloneDX + cyclonedx-python-lib + VERSION + + + + app + 1.0.0 + + + + + comp_a + 1.0.0 + + + comp_b + 1.0.0 + + + comp_c + 1.0.0 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/fixtures/xml/1.3/bom_issue_275_components.xml b/tests/fixtures/xml/1.3/bom_issue_275_components.xml new file mode 100644 index 00000000..25d31646 --- /dev/null +++ b/tests/fixtures/xml/1.3/bom_issue_275_components.xml @@ -0,0 +1,43 @@ + + + + 2021-09-01T10:50:42.051979+00:00 + + + CycloneDX + cyclonedx-python-lib + VERSION + + + + app + 1.0.0 + + + + + comp_a + 1.0.0 + + + comp_b + 1.0.0 + + + comp_c + 1.0.0 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/fixtures/xml/1.4/bom_issue_275_components.xml b/tests/fixtures/xml/1.4/bom_issue_275_components.xml new file mode 100644 index 00000000..67e58b1e --- /dev/null +++ b/tests/fixtures/xml/1.4/bom_issue_275_components.xml @@ -0,0 +1,69 @@ + + + + 2021-09-01T10:50:42.051979+00:00 + + + CycloneDX + cyclonedx-python-lib + VERSION + + + https://github.com/CycloneDX/cyclonedx-python-lib/actions + + + https://pypi.org/project/cyclonedx-python-lib/ + + + https://cyclonedx.github.io/cyclonedx-python-lib/ + + + https://github.com/CycloneDX/cyclonedx-python-lib/issues + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md + + + https://github.com/CycloneDX/cyclonedx-python-lib + + + https://cyclonedx.org + + + + + + app + 1.0.0 + + + + + comp_a + 1.0.0 + + + comp_b + 1.0.0 + + + comp_c + 1.0.0 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/test_output_xml.py b/tests/test_output_xml.py index 621b964b..b888151d 100644 --- a/tests/test_output_xml.py +++ b/tests/test_output_xml.py @@ -49,6 +49,7 @@ from cyclonedx.model.bom import Bom from cyclonedx.output import SchemaVersion, get_instance from tests.base import BaseXmlTestCase +from tests.data import get_bom_for_issue_275_components class TestOutputXml(BaseXmlTestCase): @@ -485,6 +486,36 @@ def test_bom_v1_4_dependencies_invalid(self) -> None: fixture='bom_dependencies.xml' ) + def test_bom_v1_4_issue_275_components(self) -> None: + self._validate_xml_bom( + bom=get_bom_for_issue_275_components(), schema_version=SchemaVersion.V1_4, + fixture='bom_issue_275_components.xml' + ) + + def test_bom_v1_3_issue_275_components(self) -> None: + self._validate_xml_bom( + bom=get_bom_for_issue_275_components(), schema_version=SchemaVersion.V1_3, + fixture='bom_issue_275_components.xml' + ) + + def test_bom_v1_2_issue_275_components(self) -> None: + self._validate_xml_bom( + bom=get_bom_for_issue_275_components(), schema_version=SchemaVersion.V1_2, + fixture='bom_issue_275_components.xml' + ) + + def test_bom_v1_1_issue_275_components(self) -> None: + self._validate_xml_bom( + bom=get_bom_for_issue_275_components(), schema_version=SchemaVersion.V1_1, + fixture='bom_issue_275_components.xml' + ) + + def test_bom_v1_0_issue_275_components(self) -> None: + self._validate_xml_bom( + bom=get_bom_for_issue_275_components(), schema_version=SchemaVersion.V1_0, + fixture='bom_issue_275_components.xml' + ) + # Helper methods def _validate_xml_bom(self, bom: Bom, schema_version: SchemaVersion, fixture: str) -> None: outputter = get_instance(bom=bom, schema_version=schema_version)