Trial page: throwaway ring poll to test a screen with a phone, swept after 2 h

This commit is contained in:
2026-08-16 22:11:33 +01:00
parent 1992397659
commit 60f5cffe08
9 changed files with 98 additions and 3 deletions
+23
View File
@@ -667,3 +667,26 @@ def test_entry_redirect(server):
p = create(server)
r = httpx.get(f"{server['base']}/V/{p['id'].upper()}", follow_redirects=False, verify=server["verify"])
assert r.status_code == 301 and r.headers["location"] == f"/v/{p['id']}"
def test_trial_enrolls_then_expires(server):
r = httpx.post(server["base"] + "/api/trial", verify=server["verify"])
assert r.status_code == 200
p = r.json()
assert "admin_key" not in p
async def run():
async with projector(server, p) as next_token:
c = await enroll(server, p, next_token)
await c.aclose()
asyncio.run(run())
# age it past the ttl, the next trial sweeps it away with everything it held
con = sqlite3.connect(server["db"])
con.execute("UPDATE polls SET created_at=created_at-? WHERE id=?", (3 * 3600 * 1000, p["id"]))
con.commit()
assert httpx.post(server["base"] + "/api/trial", verify=server["verify"]).status_code == 200
assert con.execute("SELECT COUNT(*) FROM polls WHERE id=?", (p["id"],)).fetchone()[0] == 0
assert con.execute("SELECT COUNT(*) FROM voters WHERE poll_id=?", (p["id"],)).fetchone()[0] == 0
con.close()
assert httpx.get(f"{server['base']}/screen/{p['id']}", verify=server["verify"]).status_code == 404