[elbe-devel] [PATCH v5 5/7] elbepack: tests: cyclonedx: add cyclonedx schema test
Eduard Krein
eduard.krein at linutronix.de
Mon Jul 1 17:01:17 CEST 2024
Add schema test that validates the generated sample sbom
with the adherence to the cyclonedx 1.6 specifications.
Signed-off-by: Eduard Krein <eduard.krein at linutronix.de>
---
.../tests/cyclonedx/test_cyclonedx_sbom.py | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 elbepack/tests/cyclonedx/test_cyclonedx_sbom.py
diff --git a/elbepack/tests/cyclonedx/test_cyclonedx_sbom.py b/elbepack/tests/cyclonedx/test_cyclonedx_sbom.py
new file mode 100644
index 00000000..7fb43c9c
--- /dev/null
+++ b/elbepack/tests/cyclonedx/test_cyclonedx_sbom.py
@@ -0,0 +1,27 @@
+# ELBE - Debian Based Embedded Rootfilesystem Builder
+# SPDX-License-Identifier: GPL-3.0-or-later
+# SPDX-FileCopyrightText: 2020 Linutronix GmbH
+
+import json
+import pathlib
+
+import jsonschema
+
+from elbepack.directories import run_elbe
+
+here = pathlib.Path(__file__).parent
+
+
+def generate_test_bom():
+ source_dir = here.joinpath('build-simple-example')
+ ps = run_elbe([
+ 'cyclonedx-sbom', '-d', source_dir,
+ ], check=True, capture_output=True)
+ return json.loads(ps.stdout)
+
+
+def test_schema():
+ test_bom = generate_test_bom()
+ with here.joinpath('bom-1.6.schema.json').open() as f:
+ bom_schema = json.load(f)
+ jsonschema.validate(test_bom, bom_schema)
--
2.39.2
More information about the elbe-devel
mailing list