From 0eb842e80c294b6d5f69c8bb664b887482591dfa Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 12 Jun 2023 11:30:52 -0700 Subject: [PATCH] test: Validate the source test manifests This helps prevent testing against invalid manifest data. It runs on the source's manifest data, using the highest schema version parsed for the source. --- test/run/test_sources.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/run/test_sources.py b/test/run/test_sources.py index d1e12dcc..9f058af3 100644 --- a/test/run/test_sources.py +++ b/test/run/test_sources.py @@ -127,6 +127,14 @@ def test_sources(source, case, tmp_path): items = desc.get("items", {}) options = desc.get("options", {}) + # What version to use for validation? + version = "2" if info.opts["2"] else "1" + schema = osbuild.meta.Schema(info.get_schema(version=version), source) + res = schema.validate(desc) + # NOTE: ValidationResult overrides __bool__ to return res.valid + if not res: + raise RuntimeError(f"Validation failed on {source}:{case}:{res.as_dict()}") + src = osbuild.sources.Source(info, items, options) with osbuild.objectstore.ObjectStore(tmp_path) as store, \