|
14 | 14 | # |
15 | 15 | # SPDX-License-Identifier: Apache-2.0 |
16 | 16 | # Copyright (c) OWASP Foundation. All Rights Reserved. |
17 | | - |
18 | | - |
| 17 | +import warnings |
19 | 18 | from typing import Callable, Tuple |
20 | 19 | from unittest import TestCase |
21 | 20 | from uuid import uuid4 |
|
29 | 28 | from cyclonedx.model.component import Component, ComponentType |
30 | 29 | from cyclonedx.model.contact import OrganizationalContact, OrganizationalEntity |
31 | 30 | from cyclonedx.model.license import DisjunctiveLicense |
| 31 | +from cyclonedx.output.json import JsonV1Dot6 |
32 | 32 | from tests._data.models import ( |
33 | 33 | get_bom_component_licenses_invalid, |
34 | 34 | get_bom_component_nested_licenses_invalid, |
@@ -133,6 +133,15 @@ def test_empty_bom(self) -> None: |
133 | 133 | self.assertFalse(bom.services) |
134 | 134 | self.assertFalse(bom.external_references) |
135 | 135 |
|
| 136 | + def test_root_component_only_bom(self) -> None: |
| 137 | + with warnings.catch_warnings(): |
| 138 | + warnings.simplefilter('error', UserWarning) # Turn UserWarnings into errors |
| 139 | + try: |
| 140 | + bom = Bom(metadata=BomMetaData(component=Component(name='test', version='1.2'))) |
| 141 | + _ = JsonV1Dot6(bom).output_as_string() |
| 142 | + except UserWarning as e: |
| 143 | + self.fail(f"A warning with 'warn' was issued: {e}") |
| 144 | + |
136 | 145 | def test_empty_bom_defined_serial(self) -> None: |
137 | 146 | serial_number = uuid4() |
138 | 147 | bom = Bom(serial_number=serial_number) |
|
0 commit comments