Skip to content

Commit 19ea024

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

13 files changed

+378
-1
lines changed

tests/_data/models.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
RelatedCryptoMaterialState,
7979
RelatedCryptoMaterialType,
8080
)
81-
from cyclonedx.model.definition import DefinitionRepository, Standard
81+
from cyclonedx.model.definition import CreId, DefinitionRepository, Level, Requirement, Standard
8282
from cyclonedx.model.dependency import Dependency
8383
from cyclonedx.model.impact_analysis import (
8484
ImpactAnalysisAffectedStatus,
@@ -1287,6 +1287,51 @@ def get_bom_with_definitions_standards() -> Bom:
12871287
)
12881288

12891289

1290+
def get_bom_with_definitions_and_detailed_standards() -> Bom:
1291+
"""
1292+
Returns a BOM with definitions and multiple detailed standards including requirements and levels.
1293+
"""
1294+
return _make_bom(
1295+
definitions=DefinitionRepository(
1296+
standards=[
1297+
Standard(name='Some Standard', version='1.2.3', description='Some description', bom_ref='some-standard',
1298+
owner='Some Owner', external_references=[get_external_reference_1()],
1299+
requirements=[
1300+
Requirement(identifier='REQ-1', title='Requirement 1', text='some requirement text',
1301+
bom_ref='req-1', descriptions=['Requirement 1 described here', 'and here'],
1302+
open_cre=[CreId('CRE:1-2')], properties=[Property(name='key1', value='val1')]
1303+
),
1304+
Requirement(identifier='REQ-2', title='Requirement 2', text='some requirement text',
1305+
bom_ref='req-2', descriptions=['Requirement 2 described here'],
1306+
open_cre=[CreId('CRE:1-2'), CreId('CRE:3-4')],
1307+
properties=[Property(name='key2', value='val2')],
1308+
parent='req-1'
1309+
),
1310+
],
1311+
levels=[
1312+
Level(identifier='LVL-1', title='Level 1', description='Level 1 description',
1313+
bom_ref='lvl-1', ),
1314+
Level(identifier='LVL-2', title='Level 2', description='Level 2 description',
1315+
bom_ref='lvl-2', )
1316+
]),
1317+
Standard(name='Other Standard', version='1.0.0', description='Other description',
1318+
bom_ref='other-standard', owner='Other Owner',
1319+
external_references=[get_external_reference_2()],
1320+
requirements=[
1321+
Requirement(identifier='REQ-3', title='Requirement 3', text='some requirement text',
1322+
bom_ref='req-3', descriptions=['Requirement 3 described here', 'and here'],
1323+
open_cre=[CreId('CRE:5-6'), CreId('CRE:7-8')],
1324+
properties=[Property(name='key3', value='val3')]
1325+
)
1326+
],
1327+
levels=[
1328+
Level(identifier='LVL-3', title='Level 3', description='Level 3 description',
1329+
bom_ref='lvl-3', )
1330+
])
1331+
]
1332+
))
1333+
1334+
12901335
# ---
12911336

12921337

@@ -1333,4 +1378,5 @@ def get_bom_with_definitions_standards() -> Bom:
13331378
get_bom_with_component_setuptools_with_v16_fields,
13341379
get_bom_for_issue_630_empty_property,
13351380
get_bom_with_definitions_standards,
1381+
get_bom_with_definitions_and_detailed_standards,
13361382
}
Lines changed: 4 additions & 0 deletions
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>
Lines changed: 4 additions & 0 deletions
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>
Lines changed: 10 additions & 0 deletions
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+
}
Lines changed: 6 additions & 0 deletions
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>
Lines changed: 10 additions & 0 deletions
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+
}
Lines changed: 6 additions & 0 deletions
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>
Lines changed: 10 additions & 0 deletions
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+
}
Lines changed: 6 additions & 0 deletions
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>
Lines changed: 20 additions & 0 deletions
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+
}

0 commit comments

Comments
 (0)