Skip to content

Commit 2be5db0

Browse files
committed
wip: update tests as per comments
need help not able to use component type as cryptographic-asset is this expected? `unsupported <ComponentType.CRYPTOGRAPHIC_ASSET: 'cryptographic-asset'> for view <class 'cyclonedx.schema.schema.SchemaVersion1Dot0'>` Instead for sake of testing I made it APPLCATION, then it makes 2 tests failed for newly added model with v1.6 first time its file not found ```log FileNotFoundError: [Errno 2] No such file or directory: '~/tests/_data/snapshots/get_bom_for_issue_692_components-1.6.xml.bin' ``` second time if i run it shows Some random BomRef in component vs None ```log '_metadata': {'%conv': "<class 'cyclonedx.model.bom.BomMetaData'>", '_authors': ('%conv:%set',), '_component': {'%conv': '<class ' "'cyclonedx.model.component.Component'>", '_author': None, '_authors': ('%conv:%set',), '_bom_ref': {'%conv': '<class ' "'cyclonedx.model.bom_ref.BomRef'>", - '_value': None}, + '_value': 'BomRef.38463980644277784.9724125994765944'}, '_components': ('%conv:%set',), '_copyright': None, '_cpe': None, '_crypto_properties': None, '_description': None, '_evidence': None, ```
1 parent fe75348 commit 2be5db0

File tree

4 files changed

+29
-184
lines changed

4 files changed

+29
-184
lines changed

cyclonedx/schema/_res/bom-1.6.SNAPSHOT.xsd

+1-1
Original file line numberDiff line numberDiff line change
@@ -7429,7 +7429,7 @@ limitations under the License.
74297429
</xs:sequence>
74307430
</xs:complexType>
74317431
</xs:element>
7432-
<xs:element name="cryptoRef" type="bom:refType" minOccurs="0" maxOccurs="unbounded">
7432+
<xs:element name="cryptoRefArray" type="bom:refType" minOccurs="0" maxOccurs="unbounded">
74337433
<xs:annotation>
74347434
<xs:documentation>A protocol-related cryptographic assets</xs:documentation>
74357435
</xs:annotation>

tests/_data/models.py

+28
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,33 @@ def get_bom_for_issue_328_components() -> Bom:
708708
return bom
709709

710710

711+
def get_bom_for_issue_692_components() -> Bom:
712+
"""regression test for issue #692
713+
see https://github.com/CycloneDX/cyclonedx-python-lib/issues/692
714+
"""
715+
bom = _make_bom()
716+
717+
comp_root = Component(type=ComponentType.APPLICATION,
718+
name='my application', version='1')
719+
comp_test = Component(
720+
name='comp_test',
721+
type=ComponentType.APPLICATION,
722+
bom_ref='crypto/protocol/test',
723+
crypto_properties=CryptoProperties(
724+
asset_type=CryptoAssetType.PROTOCOL,
725+
protocol_properties=ProtocolProperties(
726+
type=ProtocolPropertiesType.TLS,
727+
version='1.2',
728+
crypto_ref_array=[BomRef(value='for-test')]
729+
),
730+
oid='1.3.18.0.2.32.104',
731+
))
732+
bom.metadata.component = comp_root
733+
bom.register_dependency(comp_root, [comp_test])
734+
bom.components = [comp_test]
735+
return bom
736+
737+
711738
def get_component_setuptools_complete(include_pedigree: bool = True) -> Component:
712739
component = get_component_setuptools_simple(bom_ref='my-specific-bom-ref-for-dings')
713740
component.supplier = get_org_entity_1()
@@ -1357,4 +1384,5 @@ def get_bom_with_definitions_standards() -> Bom:
13571384
get_bom_for_issue_630_empty_property,
13581385
get_bom_with_lifecycles,
13591386
get_bom_with_definitions_standards,
1387+
get_bom_for_issue_692_components,
13601388
}

tests/_data/own/json/1.6/issue692.json

-170
This file was deleted.

tests/test_deserialize_json.py

-13
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,3 @@ def test_regression_issue690(self) -> None:
100100
json = json_loads(f.read())
101101
bom: Bom = Bom.from_json(json) # <<< is expected to not crash
102102
self.assertIsNotNone(bom)
103-
104-
def test_regression_issue692(self) -> None:
105-
"""
106-
regression test for issue#692.
107-
see https://github.com/CycloneDX/cyclonedx-python-lib/issues/692
108-
"""
109-
json_file = join(OWN_DATA_DIRECTORY, 'json',
110-
SchemaVersion.V1_6.to_version(),
111-
'issue692.json')
112-
with open(json_file) as f:
113-
json = json_loads(f.read())
114-
bom: Bom = Bom.from_json(json) # <<< is expected to not crash
115-
self.assertIsNotNone(bom)

0 commit comments

Comments
 (0)