2026-08-09 02:00:58 +02:00
|
|
|
from pathlib import Path
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ROOT = Path(__file__).parents[1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UserEnginePlatformExpansionContractTests(unittest.TestCase):
|
|
|
|
|
def test_contract_keeps_authorization_fail_closed(self):
|
|
|
|
|
text = (ROOT / "docs/user-engine-platform-expansion-contract.md").read_text()
|
|
|
|
|
self.assertIn("fail closed", text)
|
|
|
|
|
self.assertIn("decision ID", text)
|
|
|
|
|
self.assertIn("USER_ENGINE_FLEX_AUTH_URL", text)
|
|
|
|
|
|
|
|
|
|
def test_contract_requires_idempotent_bounded_delivery(self):
|
|
|
|
|
text = (ROOT / "docs/user-engine-platform-expansion-contract.md").read_text()
|
|
|
|
|
self.assertIn("Idempotency-Key", text)
|
|
|
|
|
self.assertIn("bounded attempts", text)
|
|
|
|
|
self.assertIn("dead-letter", text)
|
|
|
|
|
self.assertIn("OpenBao", text)
|
|
|
|
|
|
2026-08-19 22:01:12 +02:00
|
|
|
def test_desired_manifest_authenticates_flex_auth_calls(self):
|
2026-08-09 02:00:58 +02:00
|
|
|
manifest = (ROOT / "sso-mfa/k8s/user-engine/runtime.yaml").read_text()
|
2026-08-19 22:01:12 +02:00
|
|
|
self.assertIn("USER_ENGINE_FLEX_AUTH_URL", manifest)
|
|
|
|
|
self.assertIn("USER_ENGINE_FLEX_AUTH_TOKEN_FILE", manifest)
|
|
|
|
|
self.assertIn("serviceAccountName: user-engine", manifest)
|
|
|
|
|
self.assertIn("audience: flex-auth", manifest)
|
|
|
|
|
self.assertIn("mountPath: /var/run/secrets/flex-auth-caller", manifest)
|
|
|
|
|
self.assertIn("automountServiceAccountToken: false", manifest)
|
2026-08-09 02:00:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
unittest.main()
|