Let Cards players delete their account and read a privacy notice
Add a Compte section with a privacy notice and a confirmed deletion that anonymises the player row, erases their possessions and cancels open trades. The public contact comes from CARDS_PRIVACY_CONTACT, which production now requires before enabling the game. The admin E2E no longer relies on a pull from the previous test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
155187d01f
commit
e60fbd4e9b
16 changed files with 319 additions and 10 deletions
|
|
@ -278,3 +278,34 @@ test("the administrator list is applied to existing accounts at startup", async
|
|||
assert.equal(isAdmin(third, DEV_DISCORD_ID), false);
|
||||
third.close();
|
||||
});
|
||||
|
||||
test("the privacy contact is published only when valid and required to enable the game in production", async (t) => {
|
||||
const base = { NODE_ENV: "production", CARDS_DB_PATH: ":memory:", CARDS_PUBLIC_ORIGIN: "https://cards.invalid" };
|
||||
for (const contact of [undefined, "", "not-an-email"]) {
|
||||
assert.throws(() => createCardsApiHandler({ projectRoot: resolve("."), enabled: true, env: { ...base, CARDS_PRIVACY_CONTACT: contact } }), /CARDS_PRIVACY_CONTACT/);
|
||||
}
|
||||
const disabled = createCardsApiHandler({ projectRoot: resolve("."), enabled: false, env: { ...base, CARDS_PRIVACY_CONTACT: "privacy@example.invalid" } });
|
||||
assert.equal((await call(disabled, { path: "/api/cards/config" })).json.privacyContact, null);
|
||||
|
||||
const handler = createCardsApiHandler({ projectRoot: resolve("."), enabled: true, env: { ...base, CARDS_PRIVACY_CONTACT: "privacy@example.invalid" } });
|
||||
t.after(() => handler.close());
|
||||
assert.equal((await call(handler, { path: "/api/cards/config" })).json.privacyContact, "privacy@example.invalid");
|
||||
|
||||
const development = createCardsApiHandler({ projectRoot: resolve("."), enabled: true, databasePath: ":memory:", env: { NODE_ENV: "test" } });
|
||||
t.after(() => development.close());
|
||||
assert.equal((await call(development, { path: "/api/cards/config" })).json.privacyContact, null);
|
||||
});
|
||||
|
||||
test("account deletion needs a CSRF token, clears the session cookie and logs the player out", async (t) => {
|
||||
const handler = createCardsApiHandler({ projectRoot: resolve("."), enabled: true, devAuth: false, databasePath: ":memory:", env: { NODE_ENV: "test" } });
|
||||
t.after(() => handler.close());
|
||||
const player = handler.service.upsertPlayer({ discordId: "api-leaver", displayName: "Leaver" });
|
||||
const session = handler.service.createSession(player.id);
|
||||
const cookie = `sokkog_cards_session=${session.token}`;
|
||||
assert.equal((await call(handler, { method: "DELETE", path: "/api/cards/account" })).status, 401);
|
||||
assert.equal((await call(handler, { method: "DELETE", path: "/api/cards/account", headers: { cookie } })).status, 403);
|
||||
const deleted = await call(handler, { method: "DELETE", path: "/api/cards/account", headers: { cookie, "x-csrf-token": session.csrfToken } });
|
||||
assert.equal(deleted.status, 200);
|
||||
assert.match(String(deleted.headers["set-cookie"]), /sokkog_cards_session=;.*Max-Age=0/);
|
||||
assert.equal((await call(handler, { path: "/api/cards/session", headers: { cookie } })).json.authenticated, false);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue