This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Phase-1.0CA hash-verifier correction guardrails."""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--root", type=Path, required=True)
|
||||
root = parser.parse_args().root
|
||||
|
||||
|
||||
class Phase10CAGuardrails(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
cls.data = json.loads((root / "manifests/retroarch/phase-1.0ca-cleanup-result-and-hash-verifier-correction-gate.json").read_text(encoding="utf-8"))
|
||||
|
||||
def test_parent_and_cleanup_result(self) -> None:
|
||||
parent = root / "manifests/retroarch/phase-1.0bz-exact-sdl-stage-cleanup-gate.json"
|
||||
self.assertEqual(hashlib.sha256(parent.read_bytes()).hexdigest(), self.data["source_bindings"]["phase10bz_manifest_sha256"])
|
||||
result = self.data["cleanup_result"]
|
||||
self.assertEqual(result["attempts"], 1)
|
||||
self.assertEqual(result["exit_code"], 0)
|
||||
self.assertTrue(result["stage_absent_after"])
|
||||
self.assertTrue(result["worktree_metadata_absent_after"])
|
||||
self.assertTrue(result["source_clean_after"])
|
||||
self.assertFalse(result["other_worktrees_removed"])
|
||||
|
||||
def test_hash_verifier_is_exact(self) -> None:
|
||||
correction = self.data["authorized_source_correction"]
|
||||
self.assertEqual(correction["operation"], "verify_patch_target_hashes")
|
||||
self.assertEqual(correction["executable"], "/usr/bin/sha256sum")
|
||||
self.assertRegex(correction["executable_sha256"], r"^[0-9a-f]{64}$")
|
||||
self.assertEqual(len(correction["expected_sha256"]), 4)
|
||||
self.assertEqual(correction["timeout_seconds"], 30)
|
||||
self.assertTrue(correction["hash_bind_executable_in_runner"])
|
||||
self.assertFalse(correction["automatic_retry"])
|
||||
|
||||
def test_only_source_change_is_open(self) -> None:
|
||||
auth = self.data["authorizations"]
|
||||
self.assertTrue(auth["request_graph_source_change_authorized"])
|
||||
for key, value in auth.items():
|
||||
if key != "request_graph_source_change_authorized":
|
||||
self.assertFalse(value, key)
|
||||
self.assertFalse(self.data["decision"]["materialization_allowed"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(argv=[__file__])
|
||||
Reference in New Issue
Block a user