Skip to content

Commit fef2e7c

Browse files
committed
tests: enum CryptoMode
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent d27a097 commit fef2e7c

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

cyclonedx/model/crypto.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ class CryptoCertificationLevel(str, Enum):
197197

198198
@serializable.serializable_enum
199199
class CryptoMode(str, Enum):
200+
# TODO: rename to `CryptoAlgorithmMode`
201+
200202
"""
201203
This is our internal representation of the cryptoPropertiesType.algorithmProperties.mode ENUM type
202204
within the CycloneDX standard.

tests/test_enums.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,35 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any,
759759
super()._test_cases_render(bom, of, sv)
760760

761761

762+
763+
@ddt
764+
class TestEnumCryptoMode(_EnumTestCase):
765+
766+
@idata(set(chain(
767+
dp_cases_from_xml_schemas(f"./{SCHEMA_NS}complexType[@name='cryptoPropertiesType']/{SCHEMA_NS}sequence/{SCHEMA_NS}element[@name='algorithmProperties']/{SCHEMA_NS}complexType/{SCHEMA_NS}sequence/{SCHEMA_NS}element[@name='mode']/{SCHEMA_NS}simpleType"),
768+
dp_cases_from_json_schemas('definitions', 'cryptoProperties', 'properties', 'algorithmProperties', 'properties', 'mode'),
769+
)))
770+
def test_knows_value(self, value: str) -> None:
771+
super()._test_knows_value(CryptoMode, value)
772+
773+
@named_data(*(d for d in NAMED_OF_SV if d[2] >= SchemaVersion.V1_6 ))
774+
def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None:
775+
bom = _make_bom(
776+
components=[
777+
Component(
778+
name=f'CryptoMode: {cm.name}', bom_ref=f'dummy-CIP:{cm.name}',
779+
type=ComponentType.CRYPTOGRAPHIC_ASSET,
780+
crypto_properties=CryptoProperties(
781+
asset_type=CryptoAssetType.ALGORITHM,
782+
algorithm_properties=AlgorithmProperties(
783+
mode=cm
784+
)
785+
)
786+
) for cm in CryptoMode
787+
])
788+
super()._test_cases_render(bom, of, sv)
789+
790+
762791
"""
763792
@ddt
764793
class TestEnum...(_EnumTestCase):
@@ -782,8 +811,6 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any,
782811

783812
"""
784813
missing:
785-
- CryptoCertificationLevel
786-
- CryptoMode
787814
- CryptoPadding
788815
- CryptoFunction
789816
- RelatedCryptoMaterialType

0 commit comments

Comments
 (0)