oidc.py: single-sourced shared module; guest pill consumes the portal's state

- app/oidc.py is now a byte-identical copy of the canonical module
  (ops-docs: scripts/shared/oidc_client.py); this app's identity (logger
  name, session cookie, session salt) is set via oidc.configure() in
  main.py with the app's historical values, so existing sessions survive.
  tests/test_oidc_sync.py pins the copy to the canonical revision.
- Guests list: the pill CONSUMES the portal-served `state` (the single
  invited-vs-active derivation now lives in the portal and is tested
  there). The local active-flag re-derivation is deleted — the shim is
  first-served-field-wins (state → guest_status), so the previous payload
  shape renders identically during a portal rollback. Guests harness
  extended: invited-wins-over-ledger-active, served expired, and a
  payload with neither field renders NO derived pill text.
This commit is contained in:
inference-bot committed 2026-11-11 05:23:05 +00:00
1 parent 267a573eda
commit 80acfaed3b
4 files changed
+160 -16

No files matched your search

+37
View File
@@ -116,6 +116,43 @@ await runLoad({
assert(g.indexOf("2026-12-01") !== -1, "expired guest keeps its expiry date");
}
// ---- The consolidation: the panel CONSUMES the portal's `state` ----
// The portal is the single derivation point (tested there); the panel derives
// nothing from flags. state='invited' wins even though the ledger underneath
// still says active — a provisioned-but-not-set-up guest is never 'active'.
await runLoad({
members: [memberRow("alice@example.com", 2)],
guests: [
{ email: "pending@example.com", username: null, active: true, account_type: "guest",
guest_inviter: "alice@example.com", credit_balance: 2, credits_remaining: 2,
guest_expires_at: "2027-02-01T00:00:00", guest_status: "active", state: "invited",
state_reason: "awaiting setup — invite sent 2026-11-10, not yet accepted",
spend: 0, all_time_spend: 0 },
{ email: "served-expired@example.com", username: null, active: true, account_type: "guest",
guest_inviter: "alice@example.com", credit_balance: 2, credits_remaining: 2,
guest_expires_at: "2026-12-01T00:00:00", state: "expired",
spend: 0, all_time_spend: 0 },
{ email: "flagonly@example.com", username: null, active: true, account_type: "guest",
guest_inviter: "alice@example.com", credit_balance: 2, credits_remaining: 2,
guest_expires_at: "2027-02-01T00:00:00",
spend: 0, all_time_spend: 0 },
],
totals: { members: 1, total_spend: 2, total_all_time_spend: 20,
operator_spend: 0, operator_all_time_spend: 0 },
});
{
const g = document.getElementById("guest-rows").innerHTML;
assert(/pill invited[^>]*>invited</.test(g),
"portal-served state='invited' wins over the ledger's active (never 'active' before setup)");
assert(g.indexOf("awaiting setup") !== -1,
"invited tooltip names the awaiting-setup reason");
assert(/pill inactive[^>]*>expired</.test(g),
"portal-served state='expired' renders without any local derivation");
const flagRow = g.slice(g.indexOf("flagonly@example.com"));
assert(!/>active</.test(flagRow),
"no active flag, no served state: NO pill text is derived from the flag (derivation deleted)");
}
// ---- Empty list: the section disappears entirely ----
await runLoad({
members: [memberRow("alice@example.com", 2)],