Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck committed Aug 16, 2024
1 parent 75d20d2 commit a3b5eca
Show file tree
Hide file tree
Showing 51 changed files with 1,018 additions and 125 deletions.
80 changes: 65 additions & 15 deletions tests/_data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,14 @@ def get_bom_with_tools() -> Bom:
return _make_bom(
metadata=BomMetaData(
tools=(
Tool(name='test-tool-b', version='1.33.7'),
Tool(name='test-tool-a', version='23.42'),
Tool(name='test-tool-b'),
Tool(vendor='example',
name='test-tool-a',
version='1.33.7',
hashes=[HashType.from_composite_str(
'sha256:adbbbe72c8f023b4a2d96a3978f69d94873ab2fef424e0298287c3368519c1a6')],
external_references=[get_external_reference_1()],
),
)
)
)
Expand All @@ -1063,10 +1069,15 @@ def get_bom_with_tools_with_component_migrate() -> Bom:
metadata=BomMetaData(
tools=ToolsRepository(
components=(
Component(type=ComponentType.APPLICATION, group='adobe',
name='test-component', version='1.2.3', bom_ref='test-component'),
Component(type=ComponentType.APPLICATION, group='acme',
name='other-component', bom_ref='other-component'),
Component(name='test-component', bom_ref='test-component'),
Component(type=ComponentType.APPLICATION,
bom_ref='other-component',
group='acme',
name='other-component',
hashes=[HashType.from_composite_str(
'sha256:49b420bd8d8182542a76d4422e0c7890dcc88a3d8ddad04da06366d8c40ac8ca')],
external_references=[get_external_reference_1()],
),
)
)
)
Expand All @@ -1079,7 +1090,11 @@ def get_bom_with_tools_with_service_migrate() -> Bom:
tools=ToolsRepository(
services=(
Service(name='test-service', bom_ref='test-service'),
Service(name='other-service', bom_ref='other-service'),
Service(group='acme',
name='other-service',
bom_ref='other-service',
external_references=[get_external_reference_1()],
),
)
)
)
Expand All @@ -1091,14 +1106,23 @@ def get_bom_with_tools_with_component_and_service_migrate() -> Bom:
metadata=BomMetaData(
tools=ToolsRepository(
components=(
Component(type=ComponentType.APPLICATION, group='adobe',
name='test-component', version='1.2.3', bom_ref='test-component'),
Component(type=ComponentType.APPLICATION, group='acme',
name='other-component', bom_ref='other-component'),
Component(name='test-component', bom_ref='test-component'),
Component(type=ComponentType.APPLICATION,
bom_ref='other-component',
group='acme',
name='other-component',
hashes=[HashType.from_composite_str(
'sha256:49b420bd8d8182542a76d4422e0c7890dcc88a3d8ddad04da06366d8c40ac8ca')],
external_references=[get_external_reference_1()],
),
),
services=(
Service(name='test-service', bom_ref='test-service'),
Service(name='other-service', bom_ref='other-service'),
Service(group='acme',
name='other-service',
bom_ref='other-service',
external_references=[get_external_reference_1()],
),
)
)
)
Expand All @@ -1110,9 +1134,35 @@ def get_bom_with_tools_with_component_and_service_and_tools_migrate() -> Bom:
tcomp = tools.components
tserv = tools.services
ttools = tools.tools
tcomp.add(Component(type=ComponentType.APPLICATION, name='test-component', version='1.2.3'))
tserv.add(Service(name='test-service', bom_ref='my-service'))
ttools.add(Tool(name='test-tool', version='1.33.7'))
tcomp.update((
Component(name='test-component', bom_ref='test-component'),
Component(type=ComponentType.APPLICATION,
bom_ref='other-component',
group='acme',
name='other-component',
hashes=[HashType.from_composite_str(
'sha256:49b420bd8d8182542a76d4422e0c7890dcc88a3d8ddad04da06366d8c40ac8ca')],
external_references=[get_external_reference_1()],
),
))
tserv.update((
Service(name='test-service', bom_ref='test-service'),
Service(group='acme',
name='other-service',
bom_ref='other-service',
external_references=[get_external_reference_1()],
),
))
ttools.update((
Tool(name='test-tool-b'),
Tool(vendor='example',
name='test-tool-a',
version='1.33.7',
hashes=[HashType.from_composite_str(
'sha256:adbbbe72c8f023b4a2d96a3978f69d94873ab2fef424e0298287c3368519c1a6')],
external_references=[get_external_reference_1()],
),
))
return _make_bom(metadata=BomMetaData(tools=tools))


Expand Down
12 changes: 9 additions & 3 deletions tests/_data/snapshots/get_bom_with_tools-1.2.json.bin
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
"timestamp": "2023-01-07T13:44:32.312678+00:00",
"tools": [
{
"hashes": [
{
"alg": "SHA-256",
"content": "adbbbe72c8f023b4a2d96a3978f69d94873ab2fef424e0298287c3368519c1a6"
}
],
"name": "test-tool-a",
"version": "23.42"
"vendor": "example",
"version": "1.33.7"
},
{
"name": "test-tool-b",
"version": "1.33.7"
"name": "test-tool-b"
}
]
},
Expand Down
7 changes: 5 additions & 2 deletions tests/_data/snapshots/get_bom_with_tools-1.2.xml.bin
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
<timestamp>2023-01-07T13:44:32.312678+00:00</timestamp>
<tools>
<tool>
<vendor>example</vendor>
<name>test-tool-a</name>
<version>23.42</version>
<version>1.33.7</version>
<hashes>
<hash alg="SHA-256">adbbbe72c8f023b4a2d96a3978f69d94873ab2fef424e0298287c3368519c1a6</hash>
</hashes>
</tool>
<tool>
<name>test-tool-b</name>
<version>1.33.7</version>
</tool>
</tools>
</metadata>
Expand Down
12 changes: 9 additions & 3 deletions tests/_data/snapshots/get_bom_with_tools-1.3.json.bin
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
"timestamp": "2023-01-07T13:44:32.312678+00:00",
"tools": [
{
"hashes": [
{
"alg": "SHA-256",
"content": "adbbbe72c8f023b4a2d96a3978f69d94873ab2fef424e0298287c3368519c1a6"
}
],
"name": "test-tool-a",
"version": "23.42"
"vendor": "example",
"version": "1.33.7"
},
{
"name": "test-tool-b",
"version": "1.33.7"
"name": "test-tool-b"
}
]
},
Expand Down
7 changes: 5 additions & 2 deletions tests/_data/snapshots/get_bom_with_tools-1.3.xml.bin
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
<timestamp>2023-01-07T13:44:32.312678+00:00</timestamp>
<tools>
<tool>
<vendor>example</vendor>
<name>test-tool-a</name>
<version>23.42</version>
<version>1.33.7</version>
<hashes>
<hash alg="SHA-256">adbbbe72c8f023b4a2d96a3978f69d94873ab2fef424e0298287c3368519c1a6</hash>
</hashes>
</tool>
<tool>
<name>test-tool-b</name>
<version>1.33.7</version>
</tool>
</tools>
</metadata>
Expand Down
25 changes: 22 additions & 3 deletions tests/_data/snapshots/get_bom_with_tools-1.4.json.bin
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,31 @@
"timestamp": "2023-01-07T13:44:32.312678+00:00",
"tools": [
{
"externalReferences": [
{
"comment": "No comment",
"hashes": [
{
"alg": "SHA-256",
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
}
],
"type": "distribution",
"url": "https://cyclonedx.org"
}
],
"hashes": [
{
"alg": "SHA-256",
"content": "adbbbe72c8f023b4a2d96a3978f69d94873ab2fef424e0298287c3368519c1a6"
}
],
"name": "test-tool-a",
"version": "23.42"
"vendor": "example",
"version": "1.33.7"
},
{
"name": "test-tool-b",
"version": "1.33.7"
"name": "test-tool-b"
}
]
},
Expand Down
16 changes: 14 additions & 2 deletions tests/_data/snapshots/get_bom_with_tools-1.4.xml.bin
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@
<timestamp>2023-01-07T13:44:32.312678+00:00</timestamp>
<tools>
<tool>
<vendor>example</vendor>
<name>test-tool-a</name>
<version>23.42</version>
<version>1.33.7</version>
<hashes>
<hash alg="SHA-256">adbbbe72c8f023b4a2d96a3978f69d94873ab2fef424e0298287c3368519c1a6</hash>
</hashes>
<externalReferences>
<reference type="distribution">
<url>https://cyclonedx.org</url>
<comment>No comment</comment>
<hashes>
<hash alg="SHA-256">806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b</hash>
</hashes>
</reference>
</externalReferences>
</tool>
<tool>
<name>test-tool-b</name>
<version>1.33.7</version>
</tool>
</tools>
</metadata>
Expand Down
25 changes: 22 additions & 3 deletions tests/_data/snapshots/get_bom_with_tools-1.5.json.bin
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,31 @@
"timestamp": "2023-01-07T13:44:32.312678+00:00",
"tools": [
{
"externalReferences": [
{
"comment": "No comment",
"hashes": [
{
"alg": "SHA-256",
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
}
],
"type": "distribution",
"url": "https://cyclonedx.org"
}
],
"hashes": [
{
"alg": "SHA-256",
"content": "adbbbe72c8f023b4a2d96a3978f69d94873ab2fef424e0298287c3368519c1a6"
}
],
"name": "test-tool-a",
"version": "23.42"
"vendor": "example",
"version": "1.33.7"
},
{
"name": "test-tool-b",
"version": "1.33.7"
"name": "test-tool-b"
}
]
},
Expand Down
16 changes: 14 additions & 2 deletions tests/_data/snapshots/get_bom_with_tools-1.5.xml.bin
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@
<timestamp>2023-01-07T13:44:32.312678+00:00</timestamp>
<tools>
<tool>
<vendor>example</vendor>
<name>test-tool-a</name>
<version>23.42</version>
<version>1.33.7</version>
<hashes>
<hash alg="SHA-256">adbbbe72c8f023b4a2d96a3978f69d94873ab2fef424e0298287c3368519c1a6</hash>
</hashes>
<externalReferences>
<reference type="distribution">
<url>https://cyclonedx.org</url>
<comment>No comment</comment>
<hashes>
<hash alg="SHA-256">806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b</hash>
</hashes>
</reference>
</externalReferences>
</tool>
<tool>
<name>test-tool-b</name>
<version>1.33.7</version>
</tool>
</tools>
</metadata>
Expand Down
25 changes: 22 additions & 3 deletions tests/_data/snapshots/get_bom_with_tools-1.6.json.bin
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,31 @@
"timestamp": "2023-01-07T13:44:32.312678+00:00",
"tools": [
{
"externalReferences": [
{
"comment": "No comment",
"hashes": [
{
"alg": "SHA-256",
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
}
],
"type": "distribution",
"url": "https://cyclonedx.org"
}
],
"hashes": [
{
"alg": "SHA-256",
"content": "adbbbe72c8f023b4a2d96a3978f69d94873ab2fef424e0298287c3368519c1a6"
}
],
"name": "test-tool-a",
"version": "23.42"
"vendor": "example",
"version": "1.33.7"
},
{
"name": "test-tool-b",
"version": "1.33.7"
"name": "test-tool-b"
}
]
},
Expand Down
16 changes: 14 additions & 2 deletions tests/_data/snapshots/get_bom_with_tools-1.6.xml.bin
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@
<timestamp>2023-01-07T13:44:32.312678+00:00</timestamp>
<tools>
<tool>
<vendor>example</vendor>
<name>test-tool-a</name>
<version>23.42</version>
<version>1.33.7</version>
<hashes>
<hash alg="SHA-256">adbbbe72c8f023b4a2d96a3978f69d94873ab2fef424e0298287c3368519c1a6</hash>
</hashes>
<externalReferences>
<reference type="distribution">
<url>https://cyclonedx.org</url>
<comment>No comment</comment>
<hashes>
<hash alg="SHA-256">806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b</hash>
</hashes>
</reference>
</externalReferences>
</tool>
<tool>
<name>test-tool-b</name>
<version>1.33.7</version>
</tool>
</tools>
</metadata>
Expand Down
Loading

0 comments on commit a3b5eca

Please sign in to comment.