Skip to content

Commit acbd3fc

Browse files
committed
feat: allow empty OrganizationalContact object
Signed-off-by: Johannes Feichtner <[email protected]>
1 parent 97fc1a2 commit acbd3fc

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

cyclonedx/model/contact.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,6 @@ def __init__(
202202
phone: Optional[str] = None,
203203
email: Optional[str] = None,
204204
) -> 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-
)
209205
self.name = name
210206
self.email = email
211207
self.phone = phone

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

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test_deserialize_json.py

Lines changed: 13 additions & 0 deletions
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)