41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Phase-1.0BH repository guardrails."""
|
|
|
|
import argparse, hashlib, json
|
|
from pathlib import Path
|
|
import unittest
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--root", type=Path, required=True)
|
|
root = parser.parse_args().root
|
|
|
|
|
|
class Phase10BHGuardrails(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
cls.data = json.loads((root / "manifests/retroarch/phase-1.0bh-bounded-sdl-executor.json").read_text(encoding="utf-8"))
|
|
|
|
def test_parent_and_executor(self) -> None:
|
|
parent = root / "manifests/retroarch/phase-1.0bg-dormant-sdl-request-compiler.json"
|
|
self.assertEqual(hashlib.sha256(parent.read_bytes()).hexdigest(),
|
|
self.data["source_bindings"]["phase10bg_manifest_sha256"])
|
|
executor = self.data["executor"]
|
|
for key in ("attempt_consumed_before_preflight", "exact_request_order",
|
|
"exit_output_utf8_semantics_bounded", "success_reuse_forbidden",
|
|
"failure_reuse_forbidden", "exact_fake_facades_only"):
|
|
self.assertTrue(executor[key])
|
|
for key in ("real_process_present", "real_filesystem_present", "cli_present"):
|
|
self.assertFalse(executor[key])
|
|
|
|
def test_only_reassessment_is_open(self) -> None:
|
|
auth = self.data["authorizations"]
|
|
self.assertTrue(auth["real_facade_reassessment_authorized"])
|
|
for key, value in auth.items():
|
|
if key != "real_facade_reassessment_authorized":
|
|
self.assertFalse(value, key)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(argv=[__file__])
|