CI / skip-ci-check (pull_request) Successful in 4s
CI / docker-ci (pull_request) Successful in 6s
CI / secret-scan (pull_request) Successful in 11s
CI / viewer-unit (pull_request) Failing after 1m3s
CI / admin-unit (pull_request) Failing after 1m1s
CI / e2e (pull_request) Failing after 59s
- upload.smoke.spec.ts / gallery.search-filters.spec.ts: replace
waitForResponse/text-scrape with typed interceptNetworkCall spies (status
+ JSON shape) on the real upload POST and the filtered /api/search GET.
- api.fastapi-login.spec.ts: Zod-validate the FastAPI TokenResponse and
/auth/me UserResponse instead of loose casts. gallery.search-filters.spec.ts
gets the same treatment for the Prisma-backed SearchResponse.
- prod.smoke.spec.ts: opt-in (PROD_BASE_URL) health + login-page check on a
real PROD host; skips as a no-op until the PROD LXC exists (none does yet
per `pct list` — see ROADMAP).
- viewer.write-gates.spec.ts: NextAuth (browser-session) hasWriteAccess gate
on POST /api/faces/{id}/identify — viewer 403s, admin passes through.
Provisioned a third, independent auth-DB user (e2e-viewer@levkine.ca,
hasWriteAccess=false) for this via ansible's provision-punimtag-e2e-user.py
(see that repo for the vault/Infisical/Gitea/Vaultwarden side).
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import { z } from 'zod';
|
|
import { test, expect } from '../fixtures';
|
|
|
|
/**
|
|
* FastAPI `/api/v1/auth/login` uses a *separate* user DB from NextAuth.
|
|
* Set E2E_API_USERNAME + E2E_API_PASSWORD (or reuse admin FastAPI creds) to enable.
|
|
*
|
|
* Schemas mirror `backend/schemas/auth.py` (`TokenResponse` / `UserResponse`).
|
|
*/
|
|
const TokenResponse = z.object({
|
|
access_token: z.string().min(1),
|
|
refresh_token: z.string().min(1),
|
|
password_change_required: z.boolean(),
|
|
});
|
|
|
|
const UserResponse = z.object({
|
|
username: z.string().min(1),
|
|
is_admin: z.boolean(),
|
|
role: z.string().min(1),
|
|
permissions: z.record(z.boolean()),
|
|
});
|
|
type TokenResponse = z.infer<typeof TokenResponse>;
|
|
type UserResponse = z.infer<typeof UserResponse>;
|
|
|
|
test.describe('fastapi login @smoke', () => {
|
|
test('login returns bearer token when API creds set', async ({ api, timings }) => {
|
|
const username = process.env.E2E_API_USERNAME || '';
|
|
const password = process.env.E2E_API_PASSWORD || '';
|
|
test.skip(!username || !password, 'E2E_API_USERNAME/PASSWORD required for FastAPI auth');
|
|
|
|
const res = await timings.measure('api_login', () =>
|
|
api.post<TokenResponse>('/api/v1/auth/login', {
|
|
body: { username, password },
|
|
expectedStatus: 200,
|
|
schema: TokenResponse,
|
|
}),
|
|
);
|
|
expect(res.data.access_token).toBeTruthy();
|
|
|
|
const authed = api.withAuthBearer(res.data.access_token);
|
|
const me = await timings.measure('api_me', () =>
|
|
authed.get<UserResponse>('/api/v1/auth/me', { expectedStatus: 200, schema: UserResponse }),
|
|
);
|
|
expect(me.status).toBe(200);
|
|
expect(me.data.username).toBe(username);
|
|
});
|
|
});
|