feat(server): DELETE /api/me deletes your account; smoke test cleans up after itself

This commit is contained in:
Benjamin Oezcan
2026-11-19 09:59:19 +01:00
parent 4535ac7d8a
commit 0ffa221e82
4 changed files with 14 additions and 0 deletions

View File

@@ -44,6 +44,14 @@ test('register: optional e-mail works as login too; duplicates and weak password
assert.equal((await S.json('POST', '/api/auth/register', { name: 'x', pass: 'secret123' })).body.error, 'BAD_NAME');
});
test('DELETE /api/me removes the account, its save and its tokens', async () => {
const r = await S.json('POST', '/api/auth/register', { name: 'Leaver', pass: 'secret123' });
await S.json('GET', '/api/online', undefined, r.body.idToken);
assert.equal((await S.json('DELETE', '/api/me', undefined, r.body.idToken)).body.ok, true);
assert.equal((await S.json('POST', '/api/auth/login', { login: 'leaver', pass: 'secret123' })).status, 400);
assert.equal((await S.json('POST', '/api/auth/refresh', { refreshToken: r.body.refreshToken })).status, 401);
});
test('wrong password is rejected', async () => {
const r = await S.json('POST', '/api/auth/login', { login: 'alice', pass: 'nope-nope' });
assert.equal(r.status, 400);