Skip to content

Commit ab862e7

Browse files
authored
test: tidy up test beds (#333)
* test: consolidate imports * test: recreate all fixtures * test: docs Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 0853d14 commit ab862e7

File tree

113 files changed

+1795
-1706
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1795
-1706
lines changed

tests/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
# SPDX-License-Identifier: Apache-2.0
1818
# Copyright (c) OWASP Foundation. All Rights Reserved.
1919

20-
from os import path
20+
from os import getenv, path
2121

2222
FIXTURES_DIRECTORY = path.join(path.dirname(__file__), 'fixtures')
23+
24+
RECREATE_SNAPSHOTS = bool(getenv('CDX_TEST_RECREATE_SNAPSHOTS'))
25+
if RECREATE_SNAPSHOTS:
26+
print('!!! WILL RECREATE ALL SNAPSHOTS !!!')

tests/fixtures/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# TEST FIXTURES
2+
3+
## RE-CREATION
4+
5+
Some assets here can be (re-)created automatically, by setting the env var `CDX_TEST_RECREATE_SNAPSHOTS=1`.
6+
It might also help to set `PYTHONHASHSEED=0`!
7+
As a shortcut just run:
8+
9+
```shell
10+
CDX_TEST_RECREATE_SNAPSHOTS=1 poetry run tox -e py
11+
```
12+
13+
The files will be written as is, which might not be human-readable. feel free to reformat the files manually.

tests/fixtures/json/1.2/bom_dependencies.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"$schema": "http://cyclonedx.org/schema/bom-1.2b.schema.json",
33
"bomFormat": "CycloneDX",
44
"specVersion": "1.2",
5-
"serialNumber": "urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79",
5+
"serialNumber": "urn:uuid:7ddbdb7d-6f51-4ea6-83c1-bf780cece8e2",
66
"version": 1,
77
"metadata": {
8-
"timestamp": "2021-09-01T10:50:42.051979+00:00",
8+
"timestamp": "2023-01-07T11:40:00.491974+00:00",
99
"tools": [
1010
{
1111
"vendor": "CycloneDX",
1212
"name": "cyclonedx-python-lib",
13-
"version": "VERSION"
13+
"version": "3.1.2"
1414
}
1515
]
1616
},
@@ -28,23 +28,23 @@
2828
],
2929
"purl": "pkg:pypi/[email protected]?extension=tar.gz"
3030
},
31-
{
31+
{
3232
"type": "library",
3333
"bom-ref": "pkg:pypi/[email protected]?extension=tar.gz",
3434
"name": "toml",
3535
"version": "0.10.2",
36-
"purl": "pkg:pypi/[email protected]?extension=tar.gz",
3736
"hashes": [
3837
{
3938
"alg": "SHA-256",
4039
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
4140
}
4241
],
42+
"purl": "pkg:pypi/[email protected]?extension=tar.gz",
4343
"externalReferences": [
4444
{
45-
"type": "distribution",
4645
"url": "https://cyclonedx.org",
47-
"comment": "No comment"
46+
"comment": "No comment",
47+
"type": "distribution"
4848
}
4949
]
5050
}
@@ -61,4 +61,4 @@
6161
"dependsOn": []
6262
}
6363
]
64-
}
64+
}

tests/fixtures/json/1.2/bom_dependencies_component.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"$schema": "http://cyclonedx.org/schema/bom-1.2b.schema.json",
33
"bomFormat": "CycloneDX",
44
"specVersion": "1.2",
5-
"serialNumber": "urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79",
5+
"serialNumber": "urn:uuid:d3c403f8-187f-4c3a-ae93-2d62f50689c0",
66
"version": 1,
77
"metadata": {
8-
"timestamp": "2021-09-01T10:50:42.051979+00:00",
8+
"timestamp": "2023-01-07T11:40:00.538713+00:00",
99
"tools": [
1010
{
1111
"vendor": "CycloneDX",
1212
"name": "cyclonedx-python-lib",
13-
"version": "VERSION"
13+
"version": "3.1.2"
1414
}
1515
],
1616
"component": {
@@ -28,23 +28,23 @@
2828
}
2929
},
3030
"components": [
31-
{
31+
{
3232
"type": "library",
3333
"bom-ref": "pkg:pypi/[email protected]?extension=tar.gz",
3434
"name": "toml",
3535
"version": "0.10.2",
36-
"purl": "pkg:pypi/[email protected]?extension=tar.gz",
3736
"hashes": [
3837
{
3938
"alg": "SHA-256",
4039
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
4140
}
4241
],
42+
"purl": "pkg:pypi/[email protected]?extension=tar.gz",
4343
"externalReferences": [
4444
{
45-
"type": "distribution",
4645
"url": "https://cyclonedx.org",
47-
"comment": "No comment"
46+
"comment": "No comment",
47+
"type": "distribution"
4848
}
4949
]
5050
}
@@ -61,4 +61,4 @@
6161
"dependsOn": []
6262
}
6363
]
64-
}
64+
}

tests/fixtures/json/1.2/bom_external_references.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"$schema": "http://cyclonedx.org/schema/bom-1.2b.schema.json",
33
"bomFormat": "CycloneDX",
44
"specVersion": "1.2",
5-
"serialNumber": "urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79",
5+
"serialNumber": "urn:uuid:06480655-292f-4ab5-8d84-52ac0023a161",
66
"version": 1,
77
"metadata": {
8-
"timestamp": "2021-09-01T10:50:42.051979+00:00",
8+
"timestamp": "2023-01-07T11:40:00.241228+00:00",
99
"tools": [
1010
{
1111
"vendor": "CycloneDX",
1212
"name": "cyclonedx-python-lib",
13-
"version": "VERSION"
13+
"version": "3.1.2"
1414
}
1515
]
1616
},
@@ -25,4 +25,4 @@
2525
"type": "website"
2626
}
2727
]
28-
}
28+
}
Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
11
{
2-
"$schema": "http://cyclonedx.org/schema/bom-1.2b.schema.json",
3-
"bomFormat": "CycloneDX",
4-
"components": [
5-
{
6-
"bom-ref": "17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda",
7-
"name": "comp_a",
8-
"type": "library",
9-
"version": "1.0.0"
10-
},
11-
{
12-
"bom-ref": "0b049d09-64c0-4490-a0f5-c84d9aacf857",
13-
"components": [
14-
{
15-
"bom-ref": "cd3e9c95-9d41-49e7-9924-8cf0465ae789",
16-
"name": "comp_c",
17-
"type": "library",
18-
"version": "1.0.0"
19-
}
20-
],
21-
"name": "comp_b",
22-
"type": "library",
23-
"version": "1.0.0"
24-
}
2+
"$schema": "http://cyclonedx.org/schema/bom-1.2b.schema.json",
3+
"bomFormat": "CycloneDX",
4+
"specVersion": "1.2",
5+
"serialNumber": "urn:uuid:d571cf4c-efeb-4603-b744-a58a3e95410a",
6+
"version": 1,
7+
"metadata": {
8+
"timestamp": "2023-01-07T11:40:00.654095+00:00",
9+
"tools": [
10+
{
11+
"vendor": "CycloneDX",
12+
"name": "cyclonedx-python-lib",
13+
"version": "3.1.2"
14+
}
2515
],
26-
"dependencies": [
27-
{
28-
"dependsOn": [
29-
"17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda",
30-
"0b049d09-64c0-4490-a0f5-c84d9aacf857"
31-
],
32-
"ref": "be2c6502-7e9a-47db-9a66-e34f729810a3"
33-
},
34-
{
35-
"dependsOn": [],
36-
"ref": "17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda"
37-
},
16+
"component": {
17+
"type": "library",
18+
"bom-ref": "be2c6502-7e9a-47db-9a66-e34f729810a3",
19+
"name": "app",
20+
"version": "1.0.0"
21+
}
22+
},
23+
"components": [
24+
{
25+
"type": "library",
26+
"bom-ref": "17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda",
27+
"name": "comp_a",
28+
"version": "1.0.0"
29+
},
30+
{
31+
"type": "library",
32+
"bom-ref": "0b049d09-64c0-4490-a0f5-c84d9aacf857",
33+
"name": "comp_b",
34+
"version": "1.0.0",
35+
"components": [
3836
{
39-
"dependsOn": [
40-
"cd3e9c95-9d41-49e7-9924-8cf0465ae789"
41-
],
42-
"ref": "0b049d09-64c0-4490-a0f5-c84d9aacf857"
37+
"type": "library",
38+
"bom-ref": "cd3e9c95-9d41-49e7-9924-8cf0465ae789",
39+
"name": "comp_c",
40+
"version": "1.0.0"
4341
}
44-
],
45-
"metadata": {
46-
"component": {
47-
"bom-ref": "be2c6502-7e9a-47db-9a66-e34f729810a3",
48-
"name": "app",
49-
"type": "library",
50-
"version": "1.0.0"
51-
},
52-
"timestamp": "2022-07-27T10:06:17.101289+00:00",
53-
"tools": [
54-
{
55-
"name": "cyclonedx-python-lib",
56-
"vendor": "CycloneDX",
57-
"version": "0.11.0"
58-
}
59-
]
42+
]
43+
}
44+
],
45+
"dependencies": [
46+
{
47+
"ref": "be2c6502-7e9a-47db-9a66-e34f729810a3",
48+
"dependsOn": [
49+
"0b049d09-64c0-4490-a0f5-c84d9aacf857",
50+
"17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda"
51+
]
52+
},
53+
{
54+
"ref": "17e3b199-dc0b-42ef-bfdd-1fa81a1e3eda",
55+
"dependsOn": []
6056
},
61-
"serialNumber": "urn:uuid:b1d647c9-e4c5-4d8f-be8a-1751ac3ad4d5",
62-
"specVersion": "1.2",
63-
"version": 1
64-
}
57+
{
58+
"ref": "0b049d09-64c0-4490-a0f5-c84d9aacf857",
59+
"dependsOn": [
60+
"cd3e9c95-9d41-49e7-9924-8cf0465ae789"
61+
]
62+
}
63+
]
64+
}

tests/fixtures/json/1.2/bom_services_complex.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"$schema": "http://cyclonedx.org/schema/bom-1.2b.schema.json",
33
"bomFormat": "CycloneDX",
44
"specVersion": "1.2",
5-
"serialNumber": "urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79",
5+
"serialNumber": "urn:uuid:08037a6e-b713-4d63-87db-34e399d87a22",
66
"version": 1,
77
"metadata": {
8-
"timestamp": "2021-09-01T10:50:42.051979+00:00",
8+
"timestamp": "2023-01-07T11:40:00.700266+00:00",
99
"tools": [
1010
{
1111
"vendor": "CycloneDX",
1212
"name": "cyclonedx-python-lib",
13-
"version": "VERSION"
13+
"version": "3.1.2"
1414
}
1515
],
1616
"component": {
@@ -24,20 +24,20 @@
2424
{
2525
"bom-ref": "my-specific-bom-ref-for-my-first-service",
2626
"provider": {
27+
"name": "CycloneDX",
28+
"url": [
29+
"https://cyclonedx.org"
30+
],
2731
"contact": [
2832
{
29-
"email": "[email protected]",
30-
"name": "Paul Horton"
31-
},
32-
{
33-
"email": "[email protected]",
3433
"name": "A N Other",
34+
"email": "[email protected]",
3535
"phone": "+44 (0)1234 567890"
36+
},
37+
{
38+
"name": "Paul Horton",
39+
"email": "[email protected]"
3640
}
37-
],
38-
"name": "CycloneDX",
39-
"url": [
40-
"https://cyclonedx.org"
4141
]
4242
},
4343
"group": "a-group",
@@ -52,8 +52,8 @@
5252
"x-trust-boundary": true,
5353
"data": [
5454
{
55-
"classification": "public",
56-
"flow": "outbound"
55+
"flow": "outbound",
56+
"classification": "public"
5757
}
5858
],
5959
"licenses": [
@@ -63,15 +63,15 @@
6363
],
6464
"externalReferences": [
6565
{
66+
"url": "https://cyclonedx.org",
6667
"comment": "No comment",
68+
"type": "distribution",
6769
"hashes": [
6870
{
6971
"alg": "SHA-256",
7072
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
7173
}
72-
],
73-
"type": "distribution",
74-
"url": "https://cyclonedx.org"
74+
]
7575
}
7676
]
7777
},
@@ -86,4 +86,4 @@
8686
"dependsOn": []
8787
}
8888
]
89-
}
89+
}

0 commit comments

Comments
 (0)