import importlib.util from pathlib import Path import pytest spec = importlib.util.spec_from_file_location( "create_sitting_approvals", Path(__file__).resolve().parents[1] / "tools" / "create_sitting_approvals.py", ) create = importlib.util.module_from_spec(spec) spec.loader.exec_module(create) def test_dry_run_lists_seven_and_skips_c01(): report = create.dry_run() assert report["posted"] is False assert report["skipped"] == ["infd-20260914-c01"] assert len(report["memo_ids"]) == 7 assert "infd-20260914-c01" not in report["memo_ids"] assert report["memo_ids"][0] == "infd-20260914-c02" assert report["memo_ids"][-1] == "infd-20260914-d04" def test_require_attended_refuses_this_shell(): with pytest.raises(ValueError, match="attended_reader_required"): create.require_attended() @pytest.mark.parametrize( "origin,ok", [ ("http://127.0.0.1:18281", True), ("http://approval-engine.approval-engine.svc.cluster.local:8080", True), ("https://evil.example", False), ("http://10.43.103.108:8080", False), (None, False), ], ) def test_approval_origin_is_loopback_or_in_cluster_only(origin, ok): assert create._approval_origin_ok(origin) is ok