Add Google mailbox acceptance evidence workflow
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
|
||||
spec = importlib.util.spec_from_file_location("google_acceptance", Path(__file__).resolve().parents[1] / "deploy" / "google_acceptance.py")
|
||||
acceptance = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(acceptance)
|
||||
|
||||
|
||||
def valid_report():
|
||||
return {
|
||||
"schemaVersion": 1,
|
||||
"system": "google-mailbox",
|
||||
"releaseCommit": "a" * 40,
|
||||
"releaseRecordSha256": "b" * 64,
|
||||
"environment": "https://sandbox-guestops.futuresens.co.uk",
|
||||
"mailboxLabel": "sandbox mailbox A",
|
||||
"operator": "Test operator",
|
||||
"startedAt": "2026-09-29T10:00:00Z",
|
||||
"endedAt": "2026-09-29T11:00:00Z",
|
||||
"acceptedAt": "2026-09-29T12:00:00Z",
|
||||
"acceptedBy": "Test approver",
|
||||
"scenarios": [
|
||||
{"id": scenario, "status": "pass", "evidence": [f"restricted-ticket-{index}"]}
|
||||
for index, scenario in enumerate(sorted(acceptance.SCENARIOS), 1)
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
class GoogleAcceptanceTests(unittest.TestCase):
|
||||
def test_complete_record_is_accepted(self):
|
||||
acceptance.validate(valid_report())
|
||||
|
||||
def test_missing_or_unpassed_scenario_is_rejected(self):
|
||||
report = valid_report()
|
||||
report["scenarios"].pop()
|
||||
with self.assertRaisesRegex(ValueError, "exact required scenario"):
|
||||
acceptance.validate(report)
|
||||
report = valid_report()
|
||||
report["scenarios"][0]["status"] = "not-run"
|
||||
with self.assertRaisesRegex(ValueError, "has not passed"):
|
||||
acceptance.validate(report)
|
||||
|
||||
def test_record_rejects_email_addresses_and_insecure_origin(self):
|
||||
report = valid_report()
|
||||
report["mailboxLabel"] = "real-address@example.invalid"
|
||||
with self.assertRaisesRegex(ValueError, "non-email alias"):
|
||||
acceptance.validate(report)
|
||||
report = valid_report()
|
||||
report["environment"] = "http://sandbox.example.invalid/path"
|
||||
with self.assertRaisesRegex(ValueError, "HTTPS origin"):
|
||||
acceptance.validate(report)
|
||||
|
||||
def test_record_rejects_bad_timestamps_and_evidence(self):
|
||||
report = valid_report()
|
||||
report["acceptedAt"] = "2026-09-29T09:00:00Z"
|
||||
with self.assertRaisesRegex(ValueError, "out of order"):
|
||||
acceptance.validate(report)
|
||||
report = valid_report()
|
||||
report["scenarios"][0]["evidence"] = ["guest@example.invalid"]
|
||||
with self.assertRaisesRegex(ValueError, "invalid evidence"):
|
||||
acceptance.validate(report)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user