Skip to content

Commit f504daa

Browse files
committed
additional tests to increase code coverage
Signed-off-by: Paul Horton <[email protected]>
1 parent a3e09d1 commit f504daa

11 files changed

+749
-8
lines changed

tests/_data/models.py

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def get_crypto_properties_algorithm() -> CryptoProperties:
161161
CryptoCertificationLevel.FIPS140_2_L3,
162162
CryptoCertificationLevel.OTHER
163163
],
164-
mode=CryptoMode.EC,
164+
mode=CryptoMode.ECB,
165165
padding=CryptoPadding.PKCS7,
166166
crypto_functions=[
167167
CryptoFunction.SIGN,
@@ -290,6 +290,47 @@ def get_bom_with_component_setuptools_with_v16_fields() -> Bom:
290290
return _make_bom(components=[component])
291291

292292

293+
def get_bom_with_component_setuptools_with_v16_fields_omnibor_id_invalid() -> Bom:
294+
component = get_component_setuptools_simple()
295+
component.manufacturer = get_org_entity_1()
296+
component.authors = [get_org_contact_1(), get_org_contact_2()]
297+
component.omnibor_ids = [OmniborId('gitoid:stuff:sha1:261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64')]
298+
return _make_bom(components=[component])
299+
300+
301+
def get_bom_with_component_setuptools_with_v16_fields_swhid_invalid() -> Bom:
302+
component = get_component_setuptools_simple()
303+
component.manufacturer = get_org_entity_1()
304+
component.authors = [get_org_contact_1(), get_org_contact_2()]
305+
component.omnibor_ids = [OmniborId('gitoid:blob:sha1:261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64')]
306+
component.swhids = [
307+
Swhid('swh:1:cntp:94a9ed024d3859793618152ea559a168bbcbb5e2'),
308+
]
309+
return _make_bom(components=[component])
310+
311+
312+
def get_component_crypto_asset_algorithm(
313+
bom_ref: Optional[str] = '8182921e-0588-472e-b8f9-9c527c68f067'
314+
) -> Component:
315+
return Component(
316+
name='My Algorithm', version='1.0', type=ComponentType.CRYPTOGRAPHIC_ASSET,
317+
bom_ref=bom_ref,
318+
crypto_properties=get_crypto_properties_algorithm(),
319+
tags=['algorithm']
320+
)
321+
322+
323+
def get_component_crypto_asset_certificate(
324+
bom_ref: Optional[str] = '1f4ed1e4-582a-4fa0-8c38-1b4facc16972'
325+
) -> Component:
326+
return Component(
327+
name='My Certificate', version='1.0', type=ComponentType.CRYPTOGRAPHIC_ASSET,
328+
bom_ref=bom_ref,
329+
crypto_properties=get_crypto_properties_certificate(),
330+
tags=['certificate']
331+
)
332+
333+
293334
def get_component_crypto_asset_protocol_tls_v13(
294335
bom_ref: Optional[str] = '26b1ce0f-bec6-4bfe-9db1-03b75a4ed1ec'
295336
) -> Component:
@@ -301,13 +342,45 @@ def get_component_crypto_asset_protocol_tls_v13(
301342
)
302343

303344

304-
def get_bom_v1_6_with_crypto() -> Bom:
345+
def get_component_crypto_asset_related_material(
346+
bom_ref: Optional[str] = '332b3cee-078c-4789-ab15-887565b6fac5'
347+
) -> Component:
348+
return Component(
349+
name='My Encrypted Thing', version='1.0', type=ComponentType.CRYPTOGRAPHIC_ASSET,
350+
bom_ref=bom_ref,
351+
crypto_properties=get_crypto_properties_related_material(),
352+
tags=['encrypted', 'data']
353+
)
354+
355+
356+
def get_bom_v1_6_with_crypto_algorithm() -> Bom:
357+
c = get_component_crypto_asset_algorithm()
358+
b = _make_bom(components=[c])
359+
b.register_dependency(c)
360+
return b
361+
362+
363+
def get_bom_v1_6_with_crypto_certificate() -> Bom:
364+
c = get_component_crypto_asset_certificate()
365+
b = _make_bom(components=[c])
366+
b.register_dependency(c)
367+
return b
368+
369+
370+
def get_bom_v1_6_with_crypto_protocol() -> Bom:
305371
c = get_component_crypto_asset_protocol_tls_v13()
306372
b = _make_bom(components=[c])
307373
b.register_dependency(c)
308374
return b
309375

310376

377+
def get_bom_v1_6_with_crypto_related_material() -> Bom:
378+
c = get_component_crypto_asset_related_material()
379+
b = _make_bom(components=[c])
380+
b.register_dependency(c)
381+
return b
382+
383+
311384
def get_bom_with_component_setuptools_no_component_version() -> Bom:
312385
return _make_bom(components=[get_component_setuptools_simple_no_version()])
313386

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"components": [
3+
{
4+
"bom-ref": "8182921e-0588-472e-b8f9-9c527c68f067",
5+
"cryptoProperties": {
6+
"algorithmProperties": {
7+
"certificationLevel": [
8+
"fips140-1-l1",
9+
"fips140-2-l3",
10+
"other"
11+
],
12+
"classicalSecurityLevel": 2,
13+
"cryptoFunctions": [
14+
"sign",
15+
"unknown"
16+
],
17+
"curve": "9n8y2oxty3ao83n8qc2g2x3qcw4jt4wj",
18+
"executionEnvironment": "software-plain-ram",
19+
"implementationPlatform": "generic",
20+
"mode": "ecb",
21+
"nistQuantumSecurityLevel": 2,
22+
"padding": "pkcs7",
23+
"parameterSetIdentifier": "a-parameter-set-id",
24+
"primitive": "kem"
25+
},
26+
"assetType": "algorithm",
27+
"oid": "an-oid-here"
28+
},
29+
"name": "My Algorithm",
30+
"tags": [
31+
"algorithm"
32+
],
33+
"type": "cryptographic-asset",
34+
"version": "1.0"
35+
}
36+
],
37+
"dependencies": [
38+
{
39+
"ref": "8182921e-0588-472e-b8f9-9c527c68f067"
40+
}
41+
],
42+
"metadata": {
43+
"timestamp": "2023-01-07T13:44:32.312678+00:00",
44+
"tools": [
45+
{
46+
"externalReferences": [
47+
{
48+
"type": "build-system",
49+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions"
50+
},
51+
{
52+
"type": "distribution",
53+
"url": "https://pypi.org/project/cyclonedx-python-lib/"
54+
},
55+
{
56+
"type": "documentation",
57+
"url": "https://cyclonedx-python-library.readthedocs.io/"
58+
},
59+
{
60+
"type": "issue-tracker",
61+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues"
62+
},
63+
{
64+
"type": "license",
65+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE"
66+
},
67+
{
68+
"type": "release-notes",
69+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md"
70+
},
71+
{
72+
"type": "vcs",
73+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib"
74+
},
75+
{
76+
"type": "website",
77+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme"
78+
}
79+
],
80+
"name": "cyclonedx-python-lib",
81+
"vendor": "CycloneDX",
82+
"version": "TESTING"
83+
}
84+
]
85+
},
86+
"serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac",
87+
"version": 1,
88+
"$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json",
89+
"bomFormat": "CycloneDX",
90+
"specVersion": "1.6"
91+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" ?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.6" serialNumber="urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac" version="1">
3+
<metadata>
4+
<timestamp>2023-01-07T13:44:32.312678+00:00</timestamp>
5+
<tools>
6+
<tool>
7+
<vendor>CycloneDX</vendor>
8+
<name>cyclonedx-python-lib</name>
9+
<version>TESTING</version>
10+
<externalReferences>
11+
<reference type="build-system">
12+
<url>https://github.com/CycloneDX/cyclonedx-python-lib/actions</url>
13+
</reference>
14+
<reference type="distribution">
15+
<url>https://pypi.org/project/cyclonedx-python-lib/</url>
16+
</reference>
17+
<reference type="documentation">
18+
<url>https://cyclonedx-python-library.readthedocs.io/</url>
19+
</reference>
20+
<reference type="issue-tracker">
21+
<url>https://github.com/CycloneDX/cyclonedx-python-lib/issues</url>
22+
</reference>
23+
<reference type="license">
24+
<url>https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE</url>
25+
</reference>
26+
<reference type="release-notes">
27+
<url>https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md</url>
28+
</reference>
29+
<reference type="vcs">
30+
<url>https://github.com/CycloneDX/cyclonedx-python-lib</url>
31+
</reference>
32+
<reference type="website">
33+
<url>https://github.com/CycloneDX/cyclonedx-python-lib/#readme</url>
34+
</reference>
35+
</externalReferences>
36+
</tool>
37+
</tools>
38+
</metadata>
39+
<components>
40+
<component type="cryptographic-asset" bom-ref="8182921e-0588-472e-b8f9-9c527c68f067">
41+
<name>My Algorithm</name>
42+
<version>1.0</version>
43+
<cryptoProperties>
44+
<assetType>algorithm</assetType>
45+
<algorithmProperties>
46+
<primitive>kem</primitive>
47+
<parameterSetIdentifier>a-parameter-set-id</parameterSetIdentifier>
48+
<curve>9n8y2oxty3ao83n8qc2g2x3qcw4jt4wj</curve>
49+
<executionEnvironment>software-plain-ram</executionEnvironment>
50+
<implementationPlatform>generic</implementationPlatform>
51+
<certificationLevel>fips140-1-l1</certificationLevel>
52+
<certificationLevel>fips140-2-l3</certificationLevel>
53+
<certificationLevel>other</certificationLevel>
54+
<mode>ecb</mode>
55+
<padding>pkcs7</padding>
56+
<cryptoFunctions>
57+
<cryptoFunction>sign</cryptoFunction>
58+
<cryptoFunction>unknown</cryptoFunction>
59+
</cryptoFunctions>
60+
<classicalSecurityLevel>2</classicalSecurityLevel>
61+
<nistQuantumSecurityLevel>2</nistQuantumSecurityLevel>
62+
</algorithmProperties>
63+
<oid>an-oid-here</oid>
64+
</cryptoProperties>
65+
<tags>
66+
<tag>algorithm</tag>
67+
</tags>
68+
</component>
69+
</components>
70+
<dependencies>
71+
<dependency ref="8182921e-0588-472e-b8f9-9c527c68f067"/>
72+
</dependencies>
73+
</bom>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"components": [
3+
{
4+
"bom-ref": "1f4ed1e4-582a-4fa0-8c38-1b4facc16972",
5+
"cryptoProperties": {
6+
"assetType": "certificate",
7+
"certificateProperties": {
8+
"certificateExtension": "csr",
9+
"certificateFormat": "pem",
10+
"issuerName": "Cloudflare Inc ECC CA-3",
11+
"notValidAfter": "2024-05-19T00:59:59.999999+00:00",
12+
"notValidBefore": "2023-05-19T01:00:00+00:00",
13+
"subjectName": "cyclonedx.org"
14+
},
15+
"oid": "an-oid-here"
16+
},
17+
"name": "My Certificate",
18+
"tags": [
19+
"certificate"
20+
],
21+
"type": "cryptographic-asset",
22+
"version": "1.0"
23+
}
24+
],
25+
"dependencies": [
26+
{
27+
"ref": "1f4ed1e4-582a-4fa0-8c38-1b4facc16972"
28+
}
29+
],
30+
"metadata": {
31+
"timestamp": "2023-01-07T13:44:32.312678+00:00",
32+
"tools": [
33+
{
34+
"externalReferences": [
35+
{
36+
"type": "build-system",
37+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions"
38+
},
39+
{
40+
"type": "distribution",
41+
"url": "https://pypi.org/project/cyclonedx-python-lib/"
42+
},
43+
{
44+
"type": "documentation",
45+
"url": "https://cyclonedx-python-library.readthedocs.io/"
46+
},
47+
{
48+
"type": "issue-tracker",
49+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues"
50+
},
51+
{
52+
"type": "license",
53+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE"
54+
},
55+
{
56+
"type": "release-notes",
57+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md"
58+
},
59+
{
60+
"type": "vcs",
61+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib"
62+
},
63+
{
64+
"type": "website",
65+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme"
66+
}
67+
],
68+
"name": "cyclonedx-python-lib",
69+
"vendor": "CycloneDX",
70+
"version": "TESTING"
71+
}
72+
]
73+
},
74+
"serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac",
75+
"version": 1,
76+
"$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json",
77+
"bomFormat": "CycloneDX",
78+
"specVersion": "1.6"
79+
}

0 commit comments

Comments
 (0)