Skip to content

Commit

Permalink
aded XML output tests for Issue #275
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Horton <[email protected]>
  • Loading branch information
madpah committed Jul 27, 2022
1 parent 8a455e1 commit e7fbca6
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/fixtures/xml/1.0/bom_issue_275_components.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<bom xmlns="http://cyclonedx.org/schema/bom/1.0" version="1">
<components>
<component type="library">
<name>comp_a</name>
<version>1.0.0</version>
<modified>false</modified>
</component>
<component type="library">
<name>comp_b</name>
<version>1.0.0</version>
<modified>false</modified>
<components>
<component type="library">
<name>comp_c</name>
<version>1.0.0</version>
<modified>false</modified>
</component>
</components>
</component>
</components>
</bom>
19 changes: 19 additions & 0 deletions tests/fixtures/xml/1.1/bom_issue_275_components.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<bom xmlns="http://cyclonedx.org/schema/bom/1.1" version="1">
<components>
<component type="library" bom-ref="17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda">
<name>comp_a</name>
<version>1.0.0</version>
</component>
<component type="library" bom-ref="0b049d09-64c0-4490-a0f5-c84d9aacf857">
<name>comp_b</name>
<version>1.0.0</version>
<components>
<component type="library" bom-ref="cd3e9c95-9d41-49e7-9924-8cf0465ae789">
<name>comp_c</name>
<version>1.0.0</version>
</component>
</components>
</component>
</components>
</bom>
43 changes: 43 additions & 0 deletions tests/fixtures/xml/1.2/bom_issue_275_components.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<bom xmlns="http://cyclonedx.org/schema/bom/1.2" version="1">
<metadata>
<timestamp>2021-09-01T10:50:42.051979+00:00</timestamp>
<tools>
<tool>
<vendor>CycloneDX</vendor>
<name>cyclonedx-python-lib</name>
<version>VERSION</version>
</tool>
</tools>
<component type="library" bom-ref="be2c6502-7e9a-47db-9a66-e34f729810a3">
<name>app</name>
<version>1.0.0</version>
</component>
</metadata>
<components>
<component type="library" bom-ref="17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda">
<name>comp_a</name>
<version>1.0.0</version>
</component>
<component type="library" bom-ref="0b049d09-64c0-4490-a0f5-c84d9aacf857">
<name>comp_b</name>
<version>1.0.0</version>
<components>
<component type="library" bom-ref="cd3e9c95-9d41-49e7-9924-8cf0465ae789">
<name>comp_c</name>
<version>1.0.0</version>
</component>
</components>
</component>
</components>
<dependencies>
<dependency ref="be2c6502-7e9a-47db-9a66-e34f729810a3">
<dependency ref="17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda" />
<dependency ref="0b049d09-64c0-4490-a0f5-c84d9aacf857" />
</dependency>
<dependency ref="17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda" />
<dependency ref="0b049d09-64c0-4490-a0f5-c84d9aacf857">
<dependency ref="cd3e9c95-9d41-49e7-9924-8cf0465ae789" />
</dependency>
</dependencies>
</bom>
43 changes: 43 additions & 0 deletions tests/fixtures/xml/1.3/bom_issue_275_components.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<bom xmlns="http://cyclonedx.org/schema/bom/1.3" version="1">
<metadata>
<timestamp>2021-09-01T10:50:42.051979+00:00</timestamp>
<tools>
<tool>
<vendor>CycloneDX</vendor>
<name>cyclonedx-python-lib</name>
<version>VERSION</version>
</tool>
</tools>
<component type="library" bom-ref="be2c6502-7e9a-47db-9a66-e34f729810a3">
<name>app</name>
<version>1.0.0</version>
</component>
</metadata>
<components>
<component type="library" bom-ref="17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda">
<name>comp_a</name>
<version>1.0.0</version>
</component>
<component type="library" bom-ref="0b049d09-64c0-4490-a0f5-c84d9aacf857">
<name>comp_b</name>
<version>1.0.0</version>
<components>
<component type="library" bom-ref="cd3e9c95-9d41-49e7-9924-8cf0465ae789">
<name>comp_c</name>
<version>1.0.0</version>
</component>
</components>
</component>
</components>
<dependencies>
<dependency ref="be2c6502-7e9a-47db-9a66-e34f729810a3">
<dependency ref="17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda" />
<dependency ref="0b049d09-64c0-4490-a0f5-c84d9aacf857" />
</dependency>
<dependency ref="17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda" />
<dependency ref="0b049d09-64c0-4490-a0f5-c84d9aacf857">
<dependency ref="cd3e9c95-9d41-49e7-9924-8cf0465ae789" />
</dependency>
</dependencies>
</bom>
69 changes: 69 additions & 0 deletions tests/fixtures/xml/1.4/bom_issue_275_components.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<bom xmlns="http://cyclonedx.org/schema/bom/1.4" version="1">
<metadata>
<timestamp>2021-09-01T10:50:42.051979+00:00</timestamp>
<tools>
<tool>
<vendor>CycloneDX</vendor>
<name>cyclonedx-python-lib</name>
<version>VERSION</version>
<externalReferences>
<reference type="build-system">
<url>https://github.com/CycloneDX/cyclonedx-python-lib/actions</url>
</reference>
<reference type="distribution">
<url>https://pypi.org/project/cyclonedx-python-lib/</url>
</reference>
<reference type="documentation">
<url>https://cyclonedx.github.io/cyclonedx-python-lib/</url>
</reference>
<reference type="issue-tracker">
<url>https://github.com/CycloneDX/cyclonedx-python-lib/issues</url>
</reference>
<reference type="license">
<url>https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE</url>
</reference>
<reference type="release-notes">
<url>https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md</url>
</reference>
<reference type="vcs">
<url>https://github.com/CycloneDX/cyclonedx-python-lib</url>
</reference>
<reference type="website">
<url>https://cyclonedx.org</url>
</reference>
</externalReferences>
</tool>
</tools>
<component type="library" bom-ref="be2c6502-7e9a-47db-9a66-e34f729810a3">
<name>app</name>
<version>1.0.0</version>
</component>
</metadata>
<components>
<component type="library" bom-ref="17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda">
<name>comp_a</name>
<version>1.0.0</version>
</component>
<component type="library" bom-ref="0b049d09-64c0-4490-a0f5-c84d9aacf857">
<name>comp_b</name>
<version>1.0.0</version>
<components>
<component type="library" bom-ref="cd3e9c95-9d41-49e7-9924-8cf0465ae789">
<name>comp_c</name>
<version>1.0.0</version>
</component>
</components>
</component>
</components>
<dependencies>
<dependency ref="be2c6502-7e9a-47db-9a66-e34f729810a3">
<dependency ref="17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda" />
<dependency ref="0b049d09-64c0-4490-a0f5-c84d9aacf857" />
</dependency>
<dependency ref="17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda" />
<dependency ref="0b049d09-64c0-4490-a0f5-c84d9aacf857">
<dependency ref="cd3e9c95-9d41-49e7-9924-8cf0465ae789" />
</dependency>
</dependencies>
</bom>
31 changes: 31 additions & 0 deletions tests/test_output_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e7fbca6

Please sign in to comment.