64 lines
3.5 KiB
TypeScript
64 lines
3.5 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
import { authConfig, triggerErrors } from '../../support/auth-config';
|
|
import { userByEmail } from '../../support/db';
|
|
import { GoTrueClient, randomEmail, randomPassword, validMetadata } from '../../support/gotrue';
|
|
|
|
const gotrue = new GoTrueClient();
|
|
|
|
test.describe('KTO-01 Kriterium 2: Altersbestaetigung (api)', () => {
|
|
test('KTO-01 Kriterium 2: Signup ohne age_confirmed -> 500 age_confirmation_required, kein Nutzer', async () => {
|
|
const email = randomEmail();
|
|
const res = await gotrue.signUp(email, randomPassword(), validMetadata({ age_confirmed: undefined }));
|
|
expect(res.status).toBe(500);
|
|
// Body-Format (Spike B0 (f), Spec 4.4/F13): die App unterscheidet daran Eingabefehler von SMTP-Ausfall.
|
|
expect(res.body).toEqual({ code: 'P0001', message: triggerErrors.ageConfirmationRequired });
|
|
expect(res.headers.get('x-sb-error-code')).toBe('unexpected_failure');
|
|
expect(await userByEmail(email)).toBeUndefined();
|
|
});
|
|
|
|
test('KTO-01 Kriterium 2: age_confirmed=false wird ebenfalls abgelehnt', async () => {
|
|
const email = randomEmail();
|
|
const res = await gotrue.signUp(email, randomPassword(), validMetadata({ age_confirmed: false }));
|
|
expect(res.status).toBe(500);
|
|
expect(res.body.message).toBe(triggerErrors.ageConfirmationRequired);
|
|
expect(await userByEmail(email)).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
test.describe('QUE-04 Kriterium 1 / F5: Zustimmung und Version der Rechtstexte (api)', () => {
|
|
test('QUE-04 Kriterium 1: Signup ohne terms_accepted -> terms_acceptance_required', async () => {
|
|
const email = randomEmail();
|
|
const res = await gotrue.signUp(email, randomPassword(), validMetadata({ terms_accepted: undefined }));
|
|
expect(res.status).toBe(500);
|
|
// Body-Format (Spike B0 (f), Spec 4.4/F13): die App unterscheidet daran Eingabefehler von SMTP-Ausfall.
|
|
expect(res.body).toEqual({ code: 'P0001', message: triggerErrors.termsAcceptanceRequired });
|
|
expect(res.headers.get('x-sb-error-code')).toBe('unexpected_failure');
|
|
expect(await userByEmail(email)).toBeUndefined();
|
|
});
|
|
|
|
test('QUE-04 Kriterium 1: Signup ohne terms_version -> terms_version_required', async () => {
|
|
const email = randomEmail();
|
|
const res = await gotrue.signUp(email, randomPassword(), validMetadata({ terms_version: undefined }));
|
|
expect(res.status).toBe(500);
|
|
// Body-Format (Spike B0 (f), Spec 4.4/F13): die App unterscheidet daran Eingabefehler von SMTP-Ausfall.
|
|
expect(res.body).toEqual({ code: 'P0001', message: triggerErrors.termsVersionRequired });
|
|
expect(res.headers.get('x-sb-error-code')).toBe('unexpected_failure');
|
|
expect(await userByEmail(email)).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
test.describe('KTO-01 Kriterium 3: Passwortregeln (api)', () => {
|
|
test(`KTO-01 Kriterium 3: AUTH-CFG-05 ${authConfig.passwordMinLength - 1} Zeichen -> 422 weak_password (length)`, async () => {
|
|
const email = randomEmail();
|
|
const res = await gotrue.signUp(email, 'a'.repeat(authConfig.passwordMinLength - 1));
|
|
expect(res.status).toBe(422);
|
|
expect(res.body.error_code).toBe('weak_password');
|
|
expect(res.body.weak_password?.reasons).toContain('length');
|
|
expect(await userByEmail(email)).toBeUndefined();
|
|
});
|
|
|
|
test(`KTO-01 Kriterium 3: AUTH-CFG-05/-06 genau ${authConfig.passwordMinLength} Zeichen ohne Zeichenklassen werden akzeptiert`, async () => {
|
|
const res = await gotrue.signUp(randomEmail(), 'a'.repeat(authConfig.passwordMinLength));
|
|
expect(res.status).toBe(200);
|
|
});
|
|
});
|