44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Guardrails for the tracked Phase-1.0AD boundary."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
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 Phase10ADGuardrails(unittest.TestCase):
|
|
def setUp(self) -> None:
|
|
self.manifest = json.loads((ROOT / "manifests/retroarch/phase-1.0ad-inactive-activation.json").read_text(encoding="utf-8"))
|
|
|
|
def test_activation_is_empty(self) -> None:
|
|
activation = self.manifest["activation"]
|
|
self.assertFalse(activation["active"])
|
|
for name in ("target_address", "target_port", "run_id", "not_before",
|
|
"expires_at", "launcher_sha256", "payload_sha256",
|
|
"approval_sha256"):
|
|
self.assertIsNone(activation[name])
|
|
|
|
def test_no_authority_exists(self) -> None:
|
|
self.assertFalse(any(self.manifest["authorizations"].values()))
|
|
self.assertFalse(self.manifest["decision"]["device_action_allowed"])
|
|
self.assertFalse(self.manifest["decision"]["bigapp_launcher_implementation_allowed"])
|
|
|
|
def test_contract_has_no_live_import(self) -> None:
|
|
source = (ROOT / "tools/phase10ad_activation_contract.py").read_text(encoding="utf-8")
|
|
for statement in ("import socket", "import selectors", "import requests",
|
|
"from socket", "subprocess"):
|
|
self.assertNotIn(statement, source)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(argv=[__file__])
|