Validate module catalog provenance and availability

This commit is contained in:
2026-08-06 22:42:08 +02:00
parent 9ceb1b8c22
commit 44196f5620
5 changed files with 216 additions and 4 deletions
+77
View File
@@ -3502,6 +3502,16 @@ finally:
"version": "0.1.4",
"python_package": "govoplan-files",
"python_ref": "govoplan-files==0.1.4",
"availability": "available",
"configuration_requirements": ["Object storage binding"],
"release_notes_url": "https://git.example.test/modules/files/releases/v0.1.4",
"source": {
"repository": "govoplan-files",
"tag": "v0.1.4",
"commit": "a" * 40,
"repository_url": "https://git.example.test/modules/govoplan-files",
"revision_url": "https://git.example.test/modules/govoplan-files/commit/" + "a" * 40,
},
"dependencies": ["access"],
"optional_dependencies": ["mail"],
"migration_safety": "forward_only",
@@ -3584,11 +3594,78 @@ finally:
)
self.assertEqual("0" * 64, catalog[0]["artifact_integrity"]["python"]["sha256"])
self.assertEqual(123, catalog[0]["artifact_integrity"]["python"]["size"])
self.assertEqual("available", catalog[0]["availability"])
self.assertEqual(["Object storage binding"], catalog[0]["configuration_requirements"])
self.assertEqual("v0.1.4", catalog[0]["source"]["tag"])
self.assertEqual("a" * 40, catalog[0]["source"]["commit"])
self.assertEqual(
"https://git.example.test/modules/files/releases/v0.1.4",
catalog[0]["release_notes_url"],
)
validation = validate_module_package_catalog(catalog_path)
self.assertTrue(validation["valid"])
self.assertEqual("files", validation["modules"][0]["module_id"])
def test_module_package_catalog_requires_reason_for_withdrawn_release(self) -> None:
root = Path(tempfile.mkdtemp(prefix="govoplan-module-package-catalog-withdrawn-", dir=_TEST_ROOT))
catalog_path = root / "catalog.json"
catalog_path.write_text(json.dumps({
"modules": [{
"module_id": "files",
"version": "0.1.4",
"availability": "withdrawn",
"python_package": "govoplan-files",
"python_ref": "govoplan-files==0.1.4",
}],
}), encoding="utf-8")
validation = validate_module_package_catalog(catalog_path)
self.assertFalse(validation["valid"])
self.assertIn("availability_reason", str(validation["error"]))
def test_module_package_catalog_rejects_invalid_source_provenance(self) -> None:
invalid_sources = (
{
"repository": "../govoplan-files",
"tag": "v0.1.4",
"commit": "a" * 40,
},
{
"repository": "govoplan-files",
"tag": "v0.1.4",
"commit": "not-a-commit",
},
{
"repository": "govoplan-files",
"tag": "v0.1.4",
"commit": "a" * 40,
"repository_url": "http://git.example.test/govoplan-files",
},
)
for index, source in enumerate(invalid_sources):
with self.subTest(source=source):
root = Path(tempfile.mkdtemp(
prefix=f"govoplan-module-package-catalog-source-{index}-",
dir=_TEST_ROOT,
))
catalog_path = root / "catalog.json"
catalog_path.write_text(json.dumps({
"modules": [{
"module_id": "files",
"version": "0.1.4",
"python_package": "govoplan-files",
"python_ref": "govoplan-files==0.1.4",
"source": source,
}],
}), encoding="utf-8")
validation = validate_module_package_catalog(catalog_path)
self.assertFalse(validation["valid"])
self.assertIn("source", str(validation["error"]).lower())
def test_module_package_catalog_warns_about_interface_range_mismatch(self) -> None:
root = Path(tempfile.mkdtemp(prefix="govoplan-module-package-catalog-interfaces-", dir=_TEST_ROOT))
catalog_path = root / "catalog.json"