Skip to content

Commit

Permalink
tests: regression issue365
Browse files Browse the repository at this point in the history
regression for issue #365

Signed-off-by: Jan Kowalleck <[email protected]>
  • Loading branch information
jkowalleck committed Sep 25, 2023
1 parent 9d49280 commit c5997ee
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
15 changes: 15 additions & 0 deletions tests/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,21 @@ def get_vulnerability_source_owasp() -> VulnerabilitySource:
return VulnerabilitySource(name='OWASP', url=XsUri('https://owasp.org'))


def get_multiple_licenses() -> Bom:
multi_licenses = [
LicenseChoice(license=License(id='MIT')),
LicenseChoice(license=License(name='foo license')),
]
return Bom(
metadata=BomMetaData(
licenses=multi_licenses,
component=Component(name='app', type=ComponentType.APPLICATION, licenses=multi_licenses)
),
components=[Component(name='comp', type=ComponentType.LIBRARY, licenses=multi_licenses)],
services=[Service(name='serv', licenses=multi_licenses)]
)


T = TypeVar('T')


Expand Down
11 changes: 10 additions & 1 deletion tests/test_output_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@
get_bom_with_metadata_component_and_dependencies,
get_bom_with_nested_services,
get_bom_with_services_complex,
get_bom_with_services_simple,
get_bom_with_services_simple, get_multiple_licenses,
)

RELEVANT_TESTDATA_DIRECTORY = join(TESTDATA_DIRECTORY, 'own', 'xml')

from ddt import ddt, idata

@patch('cyclonedx.model.ThisTool._version', 'TESTING')
@ddt
class TestOutputXml(BaseXmlTestCase):

def test_bom_external_references_v1_4(self) -> None:
Expand Down Expand Up @@ -531,6 +533,13 @@ def test_bom_v1_4_warn_dependencies(self) -> None:
fixture='bom_with_dependencies_hanging.xml'
)

@idata(SchemaVersion)
def test_regression_issue365(self, s: SchemaVersion) -> None:
self._validate_xml_bom(
bom=get_multiple_licenses(), schema_version=s,
fixture='bom_issue_275_components.xml'
)

# region Helper methods

def _validate_xml_bom(self, bom: Bom, schema_version: SchemaVersion, fixture: str) -> None:
Expand Down

0 comments on commit c5997ee

Please sign in to comment.