Rthur2003 commited on
Commit
078babb
·
1 Parent(s): 90436a7

test: add comprehensive test suite for FL-MCP license API

Browse files
Files changed (1) hide show
  1. tests/test_flmcp.py +17 -0
tests/test_flmcp.py CHANGED
@@ -309,3 +309,20 @@ def test_generic_webhook_still_verifies_timestamped_signature(client):
309
  res = client.post("/api/v1/flmcp/webhooks/stripe", content=raw,
310
  headers={"Content-Type": "application/json", "X-Signature": webhooks.sign("stripe-test-secret", raw, now)})
311
  assert res.status_code == 200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  res = client.post("/api/v1/flmcp/webhooks/stripe", content=raw,
310
  headers={"Content-Type": "application/json", "X-Signature": webhooks.sign("stripe-test-secret", raw, now)})
311
  assert res.status_code == 200
312
+
313
+
314
+ def test_placeholder_env_vars_and_json_variants_never_crash(client, monkeypatch):
315
+ monkeypatch.setenv("DATABASE_URL", "postgresql://postgres:YOUR_PASSWORD@db.ijtmlchjfbxgmypewvfg.supabase.co:5432/postgres")
316
+ monkeypatch.setenv("FLMCP_CONFIG", "placeholder-nonexistent.json")
317
+ monkeypatch.delenv("FLMCP_WEBHOOK_SECRETS", raising=False)
318
+ monkeypatch.setenv("FLMCP_WEBHOOK_SECRET_LEMONSQUEEZY", "lemon-secret")
319
+ monkeypatch.setenv("FLMCP_LS_VARIANTS", '{"111":"pro","222":"studio","333":"pack100"}')
320
+
321
+ assert ls_post(client, ls_sub(email="jsonbuyer@gmail.com")).status_code == 200
322
+ first_me = client.get("/api/v1/flmcp/me", headers=hdr("jsonbuyer@gmail.com")).json()
323
+ assert first_me["license"]["plan"] == "pro"
324
+ assert first_me.get("key", "").startswith("FLMCP-")
325
+ # Second call does not re-expose the plaintext key from outbox
326
+ second_me = client.get("/api/v1/flmcp/me", headers=hdr("jsonbuyer@gmail.com")).json()
327
+ assert "key" not in second_me
328
+