Shuffle/e2e/tests/api/krit05-sitzung.spec.ts
cschlaefke f302c56904 test(auth): add Playwright project with api tests for KTO-01 (GoTrue, Mailpit, db helper)
Refs #38

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-03 10:29:18 +01:00

30 lines
1.4 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { authConfig } from '../../support/auth-config';
import { sessionNotAfter } from '../../support/db';
import { GoTrueClient, randomEmail, randomPassword } from '../../support/gotrue';
const gotrue = new GoTrueClient();
test.describe('KTO-01 Kriterium 5: Sitzung bleibt bestehen (api)', () => {
test('KTO-01 Kriterium 5: AUTH-CFG-14/-16 Sitzung ohne Zeitbegrenzung, JWT-Laufzeit 3600 s', async () => {
const email = randomEmail();
const password = randomPassword();
await gotrue.createConfirmedUser(email, password);
const login = await gotrue.signIn(email, password);
expect(login.status).toBe(200);
expect(login.body.expires_in).toBe(authConfig.jwtExpirySeconds);
// AUTH-CFG-16: weder timebox noch inactivity_timeout -> not_after bleibt leer.
expect(await sessionNotAfter(email)).toEqual([null]);
});
test('KTO-01 Kriterium 5: AUTH-CFG-15 Refresh liefert neue Tokens, die Sitzung bleibt gueltig', async () => {
const email = randomEmail();
const password = randomPassword();
await gotrue.createConfirmedUser(email, password);
const login = await gotrue.signIn(email, password);
const refreshed = await gotrue.refresh(login.body.refresh_token);
expect(refreshed.status).toBe(200);
expect(refreshed.body.refresh_token).not.toBe(login.body.refresh_token);
expect((await gotrue.getUser(refreshed.body.access_token)).status).toBe(200);
});
});