security: verify OC orders, fail-closed revoke, per-IP rate buckets, escaped guest email
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
1 parent
5a0a3decbe
commit
c9726f4029
6 files changed
+264
-104
No files matched your search
@@ -101,6 +101,20 @@ async def order_amount_ok(_order_id_v2=None):
|
||||
return 5000
|
||||
|
||||
|
||||
async def order_details_ok(_order_id_v2=None):
|
||||
"""Verified OC order for the credit-pack fixture (2026-11-19 hardening)."""
|
||||
return {
|
||||
"id": "or_testOrderId123",
|
||||
"status": "PAID",
|
||||
"frequency": "ONETIME",
|
||||
"amount": {"valueInCents": 5000},
|
||||
"platformTipAmount": {"valueInCents": 0},
|
||||
"fromAccount": {"slug": MEMBER_SLUG},
|
||||
"toAccount": {"slug": m.OC_COLLECTIVE_SLUG},
|
||||
"tier": {"name": "Credit pack"},
|
||||
}
|
||||
|
||||
|
||||
async def budget_noop(_email):
|
||||
return 0.0
|
||||
|
||||
@@ -118,6 +132,7 @@ async def main():
|
||||
|
||||
m.sync_team_budget_from_balance = budget_noop # no LiteLLM calls in a test
|
||||
m.get_order_amount = order_amount_ok
|
||||
m.get_order_details = order_details_ok
|
||||
|
||||
async with REAL_ASYNC_CLIENT(transport=transport, base_url="http://test") as c:
|
||||
# --- 1. AUTH: a wrong token is still a 401. ---
|
||||
@@ -181,7 +196,7 @@ async def main():
|
||||
m.get_credit_balance(MEMBER_EMAIL) == 50.0)
|
||||
ref = m.credit_pack_reference(MEMBER_SLUG, {"idV2": ORDER_ID})
|
||||
check("grant: the ledger row is keyed on the OC order (idempotence key)",
|
||||
ref == f"oc:{MEMBER_SLUG}:{ORDER_ID}" and m.credit_reference_exists(ref))
|
||||
ref == f"oc:{ORDER_ID}" and m.credit_reference_exists(ref))
|
||||
|
||||
# --- 4. Re-delivery moves no money. ---
|
||||
r = await c.post(url, json=PAYLOAD)
|
||||
|
||||
Reference in new issue
Block a user