Skip to content

Commit 4474bf4

Browse files
committed
feat: add detailed test fixtures related to bom.definitions
Signed-off-by: Hakan Dilek <[email protected]>
1 parent 2b02f34 commit 4474bf4

13 files changed

+379
-1
lines changed

tests/_data/models.py

+47-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
RelatedCryptoMaterialState,
7979
RelatedCryptoMaterialType,
8080
)
81-
from cyclonedx.model.definition import Definitions, Standard
81+
from cyclonedx.model.definition import CreId, Definitions, Level, Requirement, Standard
8282
from cyclonedx.model.dependency import Dependency
8383
from cyclonedx.model.impact_analysis import (
8484
ImpactAnalysisAffectedStatus,
@@ -1310,6 +1310,51 @@ def get_bom_with_definitions_standards() -> Bom:
13101310
)
13111311

13121312

1313+
def get_bom_with_definitions_and_detailed_standards() -> Bom:
1314+
"""
1315+
Returns a BOM with definitions and multiple detailed standards including requirements and levels.
1316+
"""
1317+
return _make_bom(
1318+
definitions=Definitions(
1319+
standards=[
1320+
Standard(name='Some Standard', version='1.2.3', description='Some description', bom_ref='some-standard',
1321+
owner='Some Owner', external_references=[get_external_reference_1()],
1322+
requirements=[
1323+
Requirement(identifier='REQ-1', title='Requirement 1', text='some requirement text',
1324+
bom_ref='req-1', descriptions=['Requirement 1 described here', 'and here'],
1325+
open_cre=[CreId('CRE:1-2')], properties=[Property(name='key1', value='val1')]
1326+
),
1327+
Requirement(identifier='REQ-2', title='Requirement 2', text='some requirement text',
1328+
bom_ref='req-2', descriptions=['Requirement 2 described here'],
1329+
open_cre=[CreId('CRE:1-2'), CreId('CRE:3-4')],
1330+
properties=[Property(name='key2', value='val2')],
1331+
parent='req-1'
1332+
),
1333+
],
1334+
levels=[
1335+
Level(identifier='LVL-1', title='Level 1', description='Level 1 description',
1336+
bom_ref='lvl-1', ),
1337+
Level(identifier='LVL-2', title='Level 2', description='Level 2 description',
1338+
bom_ref='lvl-2', )
1339+
]),
1340+
Standard(name='Other Standard', version='1.0.0', description='Other description',
1341+
bom_ref='other-standard', owner='Other Owner',
1342+
external_references=[get_external_reference_2()],
1343+
requirements=[
1344+
Requirement(identifier='REQ-3', title='Requirement 3', text='some requirement text',
1345+
bom_ref='req-3', descriptions=['Requirement 3 described here', 'and here'],
1346+
open_cre=[CreId('CRE:5-6'), CreId('CRE:7-8')],
1347+
properties=[Property(name='key3', value='val3')]
1348+
)
1349+
],
1350+
levels=[
1351+
Level(identifier='LVL-3', title='Level 3', description='Level 3 description',
1352+
bom_ref='lvl-3', )
1353+
])
1354+
]
1355+
))
1356+
1357+
13131358
# ---
13141359

13151360

@@ -1357,4 +1402,5 @@ def get_bom_with_definitions_standards() -> Bom:
13571402
get_bom_for_issue_630_empty_property,
13581403
get_bom_with_lifecycles,
13591404
get_bom_with_definitions_standards,
1405+
get_bom_with_definitions_and_detailed_standards,
13601406
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" ?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.0" version="1">
3+
<components/>
4+
</bom>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" ?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.1" serialNumber="urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac" version="1">
3+
<components/>
4+
</bom>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"metadata": {
3+
"timestamp": "2023-01-07T13:44:32.312678+00:00"
4+
},
5+
"serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac",
6+
"version": 1,
7+
"$schema": "http://cyclonedx.org/schema/bom-1.2b.schema.json",
8+
"bomFormat": "CycloneDX",
9+
"specVersion": "1.2"
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" ?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.2" serialNumber="urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac" version="1">
3+
<metadata>
4+
<timestamp>2023-01-07T13:44:32.312678+00:00</timestamp>
5+
</metadata>
6+
</bom>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"metadata": {
3+
"timestamp": "2023-01-07T13:44:32.312678+00:00"
4+
},
5+
"serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac",
6+
"version": 1,
7+
"$schema": "http://cyclonedx.org/schema/bom-1.3a.schema.json",
8+
"bomFormat": "CycloneDX",
9+
"specVersion": "1.3"
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" ?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.3" serialNumber="urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac" version="1">
3+
<metadata>
4+
<timestamp>2023-01-07T13:44:32.312678+00:00</timestamp>
5+
</metadata>
6+
</bom>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"metadata": {
3+
"timestamp": "2023-01-07T13:44:32.312678+00:00"
4+
},
5+
"serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac",
6+
"version": 1,
7+
"$schema": "http://cyclonedx.org/schema/bom-1.4.schema.json",
8+
"bomFormat": "CycloneDX",
9+
"specVersion": "1.4"
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" ?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.4" serialNumber="urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac" version="1">
3+
<metadata>
4+
<timestamp>2023-01-07T13:44:32.312678+00:00</timestamp>
5+
</metadata>
6+
</bom>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"metadata": {
3+
"timestamp": "2023-01-07T13:44:32.312678+00:00"
4+
},
5+
"properties": [
6+
{
7+
"name": "key1",
8+
"value": "val1"
9+
},
10+
{
11+
"name": "key2",
12+
"value": "val2"
13+
}
14+
],
15+
"serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac",
16+
"version": 1,
17+
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
18+
"bomFormat": "CycloneDX",
19+
"specVersion": "1.5"
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" ?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.5" serialNumber="urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac" version="1">
3+
<metadata>
4+
<timestamp>2023-01-07T13:44:32.312678+00:00</timestamp>
5+
</metadata>
6+
<properties>
7+
<property name="key1">val1</property>
8+
<property name="key2">val2</property>
9+
</properties>
10+
</bom>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{
2+
"definitions": {
3+
"standards": [
4+
{
5+
"bom-ref": "other-standard",
6+
"description": "Other description",
7+
"externalReferences": [
8+
{
9+
"type": "website",
10+
"url": "https://cyclonedx.org"
11+
}
12+
],
13+
"levels": [
14+
{
15+
"bom-ref": "lvl-3",
16+
"description": "Level 3 description",
17+
"identifier": "LVL-3",
18+
"title": "Level 3"
19+
}
20+
],
21+
"name": "Other Standard",
22+
"owner": "Other Owner",
23+
"requirements": [
24+
{
25+
"bom-ref": "req-3",
26+
"descriptions": [
27+
"Requirement 3 described here",
28+
"and here"
29+
],
30+
"identifier": "REQ-3",
31+
"openCre": [
32+
"CRE:5-6",
33+
"CRE:7-8"
34+
],
35+
"properties": [
36+
{
37+
"name": "key3",
38+
"value": "val3"
39+
}
40+
],
41+
"text": "some requirement text",
42+
"title": "Requirement 3"
43+
}
44+
],
45+
"version": "1.0.0"
46+
},
47+
{
48+
"bom-ref": "some-standard",
49+
"description": "Some description",
50+
"externalReferences": [
51+
{
52+
"comment": "No comment",
53+
"hashes": [
54+
{
55+
"alg": "SHA-256",
56+
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
57+
}
58+
],
59+
"type": "distribution",
60+
"url": "https://cyclonedx.org"
61+
}
62+
],
63+
"levels": [
64+
{
65+
"bom-ref": "lvl-1",
66+
"description": "Level 1 description",
67+
"identifier": "LVL-1",
68+
"title": "Level 1"
69+
},
70+
{
71+
"bom-ref": "lvl-2",
72+
"description": "Level 2 description",
73+
"identifier": "LVL-2",
74+
"title": "Level 2"
75+
}
76+
],
77+
"name": "Some Standard",
78+
"owner": "Some Owner",
79+
"requirements": [
80+
{
81+
"bom-ref": "req-1",
82+
"descriptions": [
83+
"Requirement 1 described here",
84+
"and here"
85+
],
86+
"identifier": "REQ-1",
87+
"openCre": [
88+
"CRE:1-2"
89+
],
90+
"properties": [
91+
{
92+
"name": "key1",
93+
"value": "val1"
94+
}
95+
],
96+
"text": "some requirement text",
97+
"title": "Requirement 1"
98+
},
99+
{
100+
"bom-ref": "req-2",
101+
"descriptions": [
102+
"Requirement 2 described here"
103+
],
104+
"identifier": "REQ-2",
105+
"openCre": [
106+
"CRE:1-2",
107+
"CRE:3-4"
108+
],
109+
"parent": "req-1",
110+
"properties": [
111+
{
112+
"name": "key2",
113+
"value": "val2"
114+
}
115+
],
116+
"text": "some requirement text",
117+
"title": "Requirement 2"
118+
}
119+
],
120+
"version": "1.2.3"
121+
}
122+
]
123+
},
124+
"metadata": {
125+
"timestamp": "2023-01-07T13:44:32.312678+00:00"
126+
},
127+
"properties": [
128+
{
129+
"name": "key1",
130+
"value": "val1"
131+
},
132+
{
133+
"name": "key2",
134+
"value": "val2"
135+
}
136+
],
137+
"serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac",
138+
"version": 1,
139+
"$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json",
140+
"bomFormat": "CycloneDX",
141+
"specVersion": "1.6"
142+
}

0 commit comments

Comments
 (0)