fix(api): a token hiccup is not "reconnect"; reorders and approvals are one unit each
Deep review of the debt burn: - `refusal_reason` told the user to reconnect on ANY token-endpoint failure — a 5xx, a 429, a misconfigured client — while the grant stayed and the account still read as connected, with no connect button. Only `invalid_grant` (the one that drops the grant) means reconnect now. - `pins.reorder` writes only the rows that change, so two overlapping reorders each skipped rows that matched in their own stale snapshot and interleaved into two pins on one slot. It locks the user's pins first; the second waits and deals from the first's result. - Adding a whitelist entry committed the invite and the activation it implies separately, and its audit row was written before a new invite had an id (target NULL). One transaction, flushed for the id. - The mutation convention test skipped async routes and dicts returned by name: request-access, purge-discovery and the subscription sync answered without `ok`. They do now, and the test covers both. The helper-commit check looked only at `_`-names; it reads every non-route function, which listed two deliberate committers (upsert_pending_invite, ensure_welcome) — now allowlisted with their reasons.
This commit is contained in:
@@ -168,3 +168,15 @@ def test_deleting_the_user_also_clears_the_way_to_re_invite(db, make_user, as_us
|
||||
assert (
|
||||
db.execute(select(Invite).where(Invite.email == member.email)).scalar_one_or_none() is None
|
||||
)
|
||||
|
||||
|
||||
def test_whitelisting_a_new_address_audits_it_by_id(db, make_user, as_user):
|
||||
"""The audit row was written before the new invite had an id, so it named no target."""
|
||||
from app.models import AuditLog
|
||||
|
||||
admin = make_user(role="admin")
|
||||
r = as_user(admin).post("/api/admin/invites", json={"email": "fresh-e27@example.com"})
|
||||
assert r.status_code == 200
|
||||
inv = db.scalar(select(Invite).where(Invite.email == "fresh-e27@example.com"))
|
||||
row = db.scalar(select(AuditLog).where(AuditLog.target_type == "invite"))
|
||||
assert row is not None and row.target_id == str(inv.id)
|
||||
|
||||
Reference in New Issue
Block a user