Skip to content

Commit ebb168a

Browse files
authored
tests: check all enum completeness (#992)
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent bc97e1c commit ebb168a

89 files changed

Lines changed: 9637 additions & 18 deletions

File tree

Some content is hidden

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

cyclonedx/model/crypto.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class CryptoAssetType(str, Enum):
5959

6060
@serializable.serializable_enum
6161
class CryptoPrimitive(str, Enum):
62+
# TODO: rename to `CryptoAlgorithmPrimitive`
63+
6264
"""
6365
This is our internal representation of the cryptoPropertiesType.algorithmProperties.primitive ENUM type within the
6466
CycloneDX standard.
@@ -143,6 +145,8 @@ def deserialize(cls, o: Any) -> CryptoPrimitive:
143145

144146
@serializable.serializable_enum
145147
class CryptoExecutionEnvironment(str, Enum):
148+
# TODO: rename to `CryptoAlgorithmExecutionEnvironment`
149+
146150
"""
147151
This is our internal representation of the cryptoPropertiesType.algorithmProperties.executionEnvironment ENUM type
148152
within the CycloneDX standard.
@@ -158,13 +162,15 @@ class CryptoExecutionEnvironment(str, Enum):
158162
SOFTWARE_ENCRYPTED_RAM = 'software-encrypted-ram'
159163
SOFTWARE_PLAIN_RAM = 'software-plain-ram'
160164
SOFTWARE_TEE = 'software-tee'
161-
165+
# --
162166
OTHER = 'other'
163167
UNKNOWN = 'unknown'
164168

165169

166170
@serializable.serializable_enum
167171
class CryptoImplementationPlatform(str, Enum):
172+
# TODO: rename to `CryptoAlgorithmImplementationPlatform`
173+
168174
"""
169175
This is our internal representation of the cryptoPropertiesType.algorithmProperties.implementationPlatform ENUM type
170176
within the CycloneDX standard.
@@ -182,19 +188,21 @@ class CryptoImplementationPlatform(str, Enum):
182188
ARMV8_M = 'armv8-m'
183189
ARMV9_A = 'armv9-a'
184190
ARMV9_M = 'armv9-m'
185-
GENERIC = 'generic'
186191
PPC64 = 'ppc64'
187192
PPC64LE = 'ppc64le'
188193
S390X = 's390x'
189194
X86_32 = 'x86_32'
190195
X86_64 = 'x86_64'
191-
196+
# --
197+
GENERIC = 'generic'
192198
OTHER = 'other'
193199
UNKNOWN = 'unknown'
194200

195201

196202
@serializable.serializable_enum
197203
class CryptoCertificationLevel(str, Enum):
204+
# TODO: rename to `CryptoAlgorithmCertificationLevel`
205+
198206
"""
199207
This is our internal representation of the cryptoPropertiesType.algorithmProperties.certificationLevel ENUM type
200208
within the CycloneDX standard.
@@ -207,7 +215,7 @@ class CryptoCertificationLevel(str, Enum):
207215
"""
208216

209217
NONE = 'none'
210-
218+
# --
211219
FIPS140_1_L1 = 'fips140-1-l1'
212220
FIPS140_1_L2 = 'fips140-1-l2'
213221
FIPS140_1_L3 = 'fips140-1-l3'
@@ -234,13 +242,15 @@ class CryptoCertificationLevel(str, Enum):
234242
CC_EAL6_PLUS = 'cc-eal6+'
235243
CC_EAL7 = 'cc-eal7'
236244
CC_EAL7_PLUS = 'cc-eal7+'
237-
245+
# --
238246
OTHER = 'other'
239247
UNKNOWN = 'unknown'
240248

241249

242250
@serializable.serializable_enum
243251
class CryptoMode(str, Enum):
252+
# TODO: rename to `CryptoAlgorithmMode`
253+
244254
"""
245255
This is our internal representation of the cryptoPropertiesType.algorithmProperties.mode ENUM type
246256
within the CycloneDX standard.
@@ -259,13 +269,15 @@ class CryptoMode(str, Enum):
259269
ECB = 'ecb'
260270
GCM = 'gcm'
261271
OFB = 'ofb'
262-
272+
# --
263273
OTHER = 'other'
264274
UNKNOWN = 'unknown'
265275

266276

267277
@serializable.serializable_enum
268278
class CryptoPadding(str, Enum):
279+
# TODO: rename to `CryptoAlgorithmPadding`
280+
269281
"""
270282
This is our internal representation of the cryptoPropertiesType.algorithmProperties.padding ENUM type
271283
within the CycloneDX standard.
@@ -282,7 +294,7 @@ class CryptoPadding(str, Enum):
282294
PKCS1V15 = 'pkcs1v15'
283295
OAEP = 'oaep'
284296
RAW = 'raw'
285-
297+
# --
286298
OTHER = 'other'
287299
UNKNOWN = 'unknown'
288300

@@ -311,7 +323,7 @@ class CryptoFunction(str, Enum):
311323
SIGN = 'sign'
312324
TAG = 'tag'
313325
VERIFY = 'verify'
314-
326+
# --
315327
OTHER = 'other'
316328
UNKNOWN = 'unknown'
317329

@@ -785,7 +797,7 @@ class RelatedCryptoMaterialType(str, Enum):
785797
SIGNATURE = 'signature'
786798
TAG = 'tag'
787799
TOKEN = 'token' # nosec
788-
800+
# --
789801
OTHER = 'other'
790802
UNKNOWN = 'unknown'
791803

tests/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434

3535
_T = TypeVar('_T')
3636

37+
38+
PROJECT_ROOT_DIRECTORY = path.abspath(path.join(path.dirname(__file__), '..'))
39+
PROJECT_LIB_DIRECTORY = path.join(PROJECT_ROOT_DIRECTORY, 'cyclonedx')
40+
PROJECT_LIB_MODELS_DIRECTORY = path.join(PROJECT_LIB_DIRECTORY, 'model')
41+
3742
_TESTDATA_DIRECTORY = path.join(path.dirname(__file__), '_data')
3843

3944
SCHEMA_TESTDATA_DIRECTORY = path.join(_TESTDATA_DIRECTORY, 'schemaTestData')
@@ -199,5 +204,5 @@ def load_pyproject() -> dict[str, Any]:
199204
from tomllib import load as toml_load
200205
else:
201206
from tomli import load as toml_load
202-
with open(path.join(path.dirname(__file__), '..', 'pyproject.toml'), 'rb') as f:
207+
with open(path.join(PROJECT_ROOT_DIRECTORY, 'pyproject.toml'), 'rb') as f:
203208
return toml_load(f)
Lines changed: 10 additions & 0 deletions
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.0" version="1">
3+
<components>
4+
<component type="library">
5+
<name>dummy</name>
6+
<version/>
7+
<modified>false</modified>
8+
</component>
9+
</components>
10+
</bom>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
<component type="library" bom-ref="dummy">
5+
<name>dummy</name>
6+
<version/>
7+
</component>
8+
</components>
9+
</bom>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"components": [
3+
{
4+
"bom-ref": "dummy",
5+
"name": "dummy",
6+
"type": "library",
7+
"version": ""
8+
}
9+
],
10+
"dependencies": [
11+
{
12+
"ref": "dummy"
13+
}
14+
],
15+
"metadata": {
16+
"timestamp": "2023-01-07T13:44:32.312678+00:00"
17+
},
18+
"serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac",
19+
"version": 1,
20+
"$schema": "http://cyclonedx.org/schema/bom-1.2b.schema.json",
21+
"bomFormat": "CycloneDX",
22+
"specVersion": "1.2"
23+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
<components>
7+
<component type="library" bom-ref="dummy">
8+
<name>dummy</name>
9+
<version/>
10+
</component>
11+
</components>
12+
<dependencies>
13+
<dependency ref="dummy"/>
14+
</dependencies>
15+
</bom>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"components": [
3+
{
4+
"bom-ref": "dummy",
5+
"evidence": {},
6+
"name": "dummy",
7+
"type": "library",
8+
"version": ""
9+
}
10+
],
11+
"dependencies": [
12+
{
13+
"ref": "dummy"
14+
}
15+
],
16+
"metadata": {
17+
"timestamp": "2023-01-07T13:44:32.312678+00:00"
18+
},
19+
"serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac",
20+
"version": 1,
21+
"$schema": "http://cyclonedx.org/schema/bom-1.3a.schema.json",
22+
"bomFormat": "CycloneDX",
23+
"specVersion": "1.3"
24+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
<components>
7+
<component type="library" bom-ref="dummy">
8+
<name>dummy</name>
9+
<version/>
10+
<evidence/>
11+
</component>
12+
</components>
13+
<dependencies>
14+
<dependency ref="dummy"/>
15+
</dependencies>
16+
</bom>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"components": [
3+
{
4+
"bom-ref": "dummy",
5+
"evidence": {},
6+
"name": "dummy",
7+
"type": "library"
8+
}
9+
],
10+
"dependencies": [
11+
{
12+
"ref": "dummy"
13+
}
14+
],
15+
"metadata": {
16+
"timestamp": "2023-01-07T13:44:32.312678+00:00"
17+
},
18+
"serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac",
19+
"version": 1,
20+
"$schema": "http://cyclonedx.org/schema/bom-1.4.schema.json",
21+
"bomFormat": "CycloneDX",
22+
"specVersion": "1.4"
23+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
<components>
7+
<component type="library" bom-ref="dummy">
8+
<name>dummy</name>
9+
<evidence/>
10+
</component>
11+
</components>
12+
<dependencies>
13+
<dependency ref="dummy"/>
14+
</dependencies>
15+
</bom>

0 commit comments

Comments
 (0)