Skip to content

Commit 03b35f4

Browse files
authored
feat: allow empty OrganizationalContact object (#772)
fixes #771 --------- Signed-off-by: Johannes Feichtner <[email protected]> Signed-off-by: Johannes Feichtner <[email protected]>
1 parent 97fc1a2 commit 03b35f4

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

cyclonedx/model/contact.py

-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
from .._internal.bom_ref import bom_ref_from_str as _bom_ref_from_str
2525
from .._internal.compare import ComparableTuple as _ComparableTuple
26-
from ..exception.model import NoPropertiesProvidedException
2726
from ..schema.schema import SchemaVersion1Dot6
2827
from . import XsUri
2928
from .bom_ref import BomRef
@@ -202,10 +201,6 @@ def __init__(
202201
phone: Optional[str] = None,
203202
email: Optional[str] = None,
204203
) -> None:
205-
if not name and not phone and not email:
206-
raise NoPropertiesProvidedException(
207-
'One of name, email or phone must be supplied for an OrganizationalContact - none supplied.'
208-
)
209204
self.name = name
210205
self.email = email
211206
self.phone = phone

tests/_data/own/json/1.6/issue771.json

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

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_issue771(self) -> None:
92+
"""
93+
regression test for issue#771.
94+
see https://github.com/CycloneDX/cyclonedx-python-lib/issues/771
95+
"""
96+
json_file = join(OWN_DATA_DIRECTORY, 'json',
97+
SchemaVersion.V1_6.to_version(),
98+
'issue771.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_issue764(self) -> None:
92105
"""
93106
regression test for issue#764.

0 commit comments

Comments
 (0)