Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/cbz-g11-auditor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
with:
python-version: '3.11'
- name: Run census controls normally
run: env -u PYTHONPATH -u PYTHONHOME -u PYTHONPYCACHEPREFIX -u PYTHONSTARTUP -u PYTHONUSERBASE python3 -B -S -m unittest tests.test_g11_census
run: env -u PYTHONPATH -u PYTHONHOME -u PYTHONPYCACHEPREFIX -u PYTHONSTARTUP -u PYTHONUSERBASE python3 -B -S -m unittest tests.test_g11_census tests.test_g11_current_architecture_references
- name: Run census controls with optimization
run: env -u PYTHONPATH -u PYTHONHOME -u PYTHONPYCACHEPREFIX -u PYTHONSTARTUP -u PYTHONUSERBASE python3 -B -S -O -m unittest tests.test_g11_census
run: env -u PYTHONPATH -u PYTHONHOME -u PYTHONPYCACHEPREFIX -u PYTHONSTARTUP -u PYTHONUSERBASE python3 -B -S -O -m unittest tests.test_g11_census tests.test_g11_current_architecture_references
- name: Run mutation self-test normally
run: env -u PYTHONPATH -u PYTHONHOME -u PYTHONPYCACHEPREFIX -u PYTHONSTARTUP -u PYTHONUSERBASE python3 -B -S tools/cbz/g11_mutation_selftest.py
- name: Run mutation self-test with optimization
Expand Down
8 changes: 4 additions & 4 deletions tests/test_architecture_artifact_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ def invoke(self, packet=None, *, expected=None, raw=None, args=None, audit=None)
packet = self.packet if packet is None else packet
expected = pins_for(packet) if expected is None else expected
raw = canonical(packet) + b"\n" if raw is None else raw
flags = ["-B", "-S"]
if sys.flags.optimize:
flags.append("-" + "O" * sys.flags.optimize)
flags = (["-B", "-S"]
+ (["-O"] if sys.flags.optimize else [])
+ (["-O"] if sys.flags.optimize > 1 else []))
env = dict(os.environ)
env.pop("PYTHONOPTIMIZE", None)
arguments = self.flag_args(expected) if args is None else args
Expand All @@ -262,7 +262,7 @@ def launch(command, pass_fds=()):
)

if audit is None:
return launch([sys.executable, *flags, str(CLI), *arguments])
return launch([sys.executable] + flags + [str(CLI), *arguments])
with tempfile.TemporaryDirectory(prefix="TEST-audit-report-") as report_directory:
report_root = Path(report_directory)
launcher = report_root / "trusted_launcher.py"
Expand Down
8 changes: 4 additions & 4 deletions tests/test_architecture_evidence_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,13 @@ def run_adapter(self, packet=None, *, raw=None, expected=None, arguments=None):
arguments = []
for name in ("repository", "commit", "run-id", "run-attempt"):
arguments.extend(["--expected-" + name, identity[name]])
flags = ["-B", "-S"]
if sys.flags.optimize:
flags.append("-" + "O" * sys.flags.optimize)
flags = (["-B", "-S"]
+ (["-O"] if sys.flags.optimize else [])
+ (["-O"] if sys.flags.optimize > 1 else []))
env = os.environ.copy()
env.pop("PYTHONOPTIMIZE", None)
try:
return subprocess.run([sys.executable, *flags, str(CLI), *arguments], input=raw,
return subprocess.run([sys.executable] + flags + [str(CLI), *arguments], input=raw,
cwd=self.cwd, env=env, capture_output=True, text=True, encoding="utf-8",
timeout=20, check=False)
except subprocess.TimeoutExpired:
Expand Down
24 changes: 20 additions & 4 deletions tests/test_architecture_graph_artifact_readback.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,10 @@ def invoke(self, raw=None, *, members=None, expected=None, arguments=None, path=
path.write_bytes(raw)
expected = self.expected(raw, members) if expected is None else expected
arguments = self.arguments(path, expected) if arguments is None else arguments
flags = ["-B", "-S"]
if sys.flags.optimize:
flags.append("-" + "O" * sys.flags.optimize)
command = [sys.executable, *flags, str(CLI), *arguments]
flags = (["-B", "-S"]
+ (["-O"] if sys.flags.optimize else [])
+ (["-O"] if sys.flags.optimize > 1 else []))
command = [sys.executable] + flags + [str(CLI), *arguments]
if audit:
command = [sys.executable, *flags, "-I", "-c", AUDIT_LAUNCHER, str(self.cwd), str(path),
str(self.cwd / "TEST-private-secret"), str(self.cwd / "TEST-observer.json"), str(CLI),
Expand Down Expand Up @@ -484,6 +484,22 @@ def refused(self, raw=None, **kwargs):
self.assertEqual(result.stdout, b"", "refusal published partial or success JSON")
self.assertEqual(result.stderr, REFUSAL, "refusal exposed paths/member data or variable diagnostics")

def test_direct_cli_smoke_is_statically_attributed_and_accepts_valid_archive(self):
raw = classic_zip(self.entries(self.base))
path = self.cwd / "TEST-direct-input.zip"
path.write_bytes(raw)
expected = self.expected(raw, self.base)
arguments = self.arguments(path, expected)
flags = (["-B", "-S"]
+ (["-O"] if sys.flags.optimize else [])
+ (["-O"] if sys.flags.optimize > 1 else []))
result = subprocess.run(
[sys.executable] + flags + [str(CLI), *arguments],
cwd=self.cwd, capture_output=True, timeout=20, check=False,
)
self.assertEqual(result.returncode, 0, result.stdout[-2000:] + result.stderr)
self.assertEqual(result.stderr, b"")

def test_valid_archive_is_one_stable_non_scientific_unit_with_original_receipt(self):
first, one = self.accepted()
_, two = self.accepted(path=self.cwd / "TEST-second-input.zip")
Expand Down
43 changes: 43 additions & 0 deletions tests/test_g11_current_architecture_references.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Repository integration controls for current architecture CLI references."""

import sys
import unittest
from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "tools" / "cbz"))
import g11_census as g11 # noqa: E402


ARCHITECTURE_TOOLS = (
"tools/architecture_evidence_adapter.py",
"tools/architecture_graph_artifact_readback.py",
"tools/artifact_index_export.py",
)

REFERENCE_SOURCES = (
"tests/test_architecture_evidence_adapter.py",
"tests/test_architecture_graph_artifact_readback.py",
"tests/test_architecture_artifact_index.py",
"tests/test_architecture_cli_boundaries.py",
)


class CurrentArchitectureReferences(unittest.TestCase):
def test_architecture_clis_have_static_execution_references(self):
paths = (*ARCHITECTURE_TOOLS, *REFERENCE_SOURCES)
files = {path: (ROOT / path).read_bytes() for path in paths}
report = g11.census(files, sorted(files))["tools"]
self.assertEqual(
{path: report[path]["referenced"] for path in ARCHITECTURE_TOOLS},
{
"tools/architecture_evidence_adapter.py": True,
"tools/architecture_graph_artifact_readback.py": True,
"tools/artifact_index_export.py": True,
},
)


if __name__ == "__main__":
unittest.main()
Loading