Remove the pending guest-requests section — nothing to approve anymore
The portal provisions member invites immediately (approval gate removed 2026-11-08), so the panel drops the Guest requests tab (queue, decisions, badge and their JS) and the approve/reject API hops. Kept: the Guests list (member-invited guests show inviter, credits, expiry, status, same as admin-created ones) and the duplicate-send guard, now fed by the portal's GET /admin/guest-ledger (ledger only — no pending key). Test updated: the guard no longer has a pending branch; a legacy pending-shaped payload is inert.
This commit is contained in:
1 parent
74165f1957
commit
f9c2ae6417
2 files changed
+46
-233
No files matched your search
+20
-14
@@ -4,6 +4,11 @@
|
||||
# treats the page JS — slicing, not importing (importing app.main pulls in
|
||||
# app.oidc → authlib, which the steward host does not have).
|
||||
#
|
||||
# The guard reads the portal's guests ledger only: the member guest-request
|
||||
# queue is GONE with the approval gate (removed 2026-11-08 — member
|
||||
# invitations provision immediately, nothing is ever pending), so there is
|
||||
# no "pending" branch to test and no payload carrying one.
|
||||
#
|
||||
# Run: python3 tests/test_guest_guard.py
|
||||
import re
|
||||
import sys
|
||||
@@ -30,37 +35,38 @@ LEDGER_ACTIVE = [{"id": 3, "inviter": "info@inference.coop",
|
||||
"recipient": "friend@example.com", "status": "active"}]
|
||||
LEDGER_LAPSED = [{"id": 3, "inviter": "info@inference.coop",
|
||||
"recipient": "friend@example.com", "status": "expired"}]
|
||||
PENDING_REQ = [{"id": 7, "inviter": "alice@example.com",
|
||||
"recipient": "someone@example.com", "status": "pending"}]
|
||||
EMPTY = {"ledger": [], "pending": []}
|
||||
EMPTY = {"ledger": []}
|
||||
|
||||
# An ACTIVE guest for the email → refuse, message names the email.
|
||||
refusal = guard({"ledger": LEDGER_ACTIVE, "pending": []}, "friend@example.com")
|
||||
refusal = guard({"ledger": LEDGER_ACTIVE}, "friend@example.com")
|
||||
check("active guest refused", refusal is not None and refusal.startswith(
|
||||
"A guest account for friend@example.com already exists"), True)
|
||||
check("active refusal states no second account",
|
||||
"no second account" in (refusal or ""), True)
|
||||
|
||||
# Case/whitespace of the submitted email must not dodge the match.
|
||||
check("case-insensitive match", guard({"ledger": LEDGER_ACTIVE, "pending": []},
|
||||
check("case-insensitive match", guard({"ledger": LEDGER_ACTIVE},
|
||||
" Friend@Example.COM ") is not None, True)
|
||||
|
||||
# A PENDING member request for the email → refuse as "awaits activation".
|
||||
refusal = guard({"ledger": [], "pending": PENDING_REQ}, "someone@example.com")
|
||||
check("pending request refused", refusal is not None and
|
||||
"awaits activation" in refusal and "someone@example.com" in refusal, True)
|
||||
# The guard no longer knows a "pending" state: a payload shaped like the old
|
||||
# guest-requests response carries nothing the guard would act on.
|
||||
check("legacy pending-shaped payload is inert",
|
||||
guard({"ledger": [], "pending": [{"id": 7, "inviter": "alice@example.com",
|
||||
"recipient": "someone@example.com",
|
||||
"status": "pending"}]},
|
||||
"someone@example.com"), None)
|
||||
|
||||
# Lapsed (expired/depleted) ledger row is NOT a live account: no panel-side
|
||||
# refusal — the portal's one-guest-per-recipient-ever guard is the authority.
|
||||
check("expired ledger row falls through",
|
||||
guard({"ledger": LEDGER_LAPSED, "pending": []}, "friend@example.com"), None)
|
||||
guard({"ledger": LEDGER_LAPSED}, "friend@example.com"), None)
|
||||
|
||||
# Someone else's guest/request never blocks a new address.
|
||||
# Someone else's guest never blocks a new address.
|
||||
check("other recipients ignored",
|
||||
guard({"ledger": LEDGER_ACTIVE, "pending": PENDING_REQ}, "new@example.com"), None)
|
||||
guard({"ledger": LEDGER_ACTIVE}, "new@example.com"), None)
|
||||
|
||||
# Empty/missing queues (portal unreadable → guard falls through, never blocks).
|
||||
check("empty queues pass", guard(EMPTY, "friend@example.com"), None)
|
||||
# Empty/missing ledger (portal unreadable → guard falls through, never blocks).
|
||||
check("empty ledger passes", guard(EMPTY, "friend@example.com"), None)
|
||||
check("missing keys pass", guard({}, "friend@example.com"), None)
|
||||
check("blank email passes (route validates first)", guard(EMPTY, ""), None)
|
||||
|
||||
|
||||
Reference in new issue
Block a user