Skip to content

Commit 472bded

Browse files
authored
feat: allow empty OrganizationalEntity object (#768)
fixes #764 Signed-off-by: Johannes Feichtner <[email protected]>
1 parent b8cbb59 commit 472bded

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

Diff for: cyclonedx/model/contact.py

-4
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,6 @@ def __init__(
296296
contacts: Optional[Iterable[OrganizationalContact]] = None,
297297
address: Optional[PostalAddress] = None,
298298
) -> None:
299-
if name is None and not urls and not contacts:
300-
raise NoPropertiesProvidedException(
301-
'One of name, urls or contacts must be supplied for an OrganizationalEntity - none supplied.'
302-
)
303299
self.name = name
304300
self.address = address
305301
self.urls = urls or [] # type:ignore[assignment]

Diff for: tests/_data/own/json/1.6/issue764.json

+26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: tests/test_deserialize_json.py

+13
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ def test(ls: LicenseRepository) -> None:
8888
test(list(bom.components)[0].licenses)
8989
test(list(bom.services)[0].licenses)
9090

91+
def test_regression_issue764(self) -> None:
92+
"""
93+
regression test for issue#764.
94+
see https://github.com/CycloneDX/cyclonedx-python-lib/issues/764
95+
"""
96+
json_file = join(OWN_DATA_DIRECTORY, 'json',
97+
SchemaVersion.V1_6.to_version(),
98+
'issue764.json')
99+
with open(json_file) as f:
100+
json = json_loads(f.read())
101+
bom: Bom = Bom.from_json(json) # <<< is expected to not crash
102+
self.assertIsNotNone(bom)
103+
91104
def test_regression_issue690(self) -> None:
92105
"""
93106
regressio test for issue#690.

0 commit comments

Comments
 (0)