mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-09-19 09:40:13 +00:00
Covers the security fixes that landed across both repos: - auth.spec.ts: login persists nz-jwt cookie and getProfile succeeds; password change bumps TokenVersion + revokes the old cookie so the pre-change JWT can no longer auth (regression guard for the keyId+session backend rewrite). - cron-csrf.spec.ts: POST /api/v1/cron/:id/manual succeeds while GET is no longer routable (regression guard for the cron CSRF fix). - fm-csrf.spec.ts: POST /api/v1/file is reachable while GET is no longer routable (regression guard for the FM CSRF fix). - visibility.spec.ts: an anonymous caller cannot see a server-group that contains zero guest-visible servers (regression guard for the server-group leak fix). Fixtures wrap the noisy login + cleanup boilerplate. tsconfig is scoped to tests/e2e so the suite stays out of the production tsc project graph. Playwright config starts the Vite dev server (npm run dev) and expects a backend reachable at the URL Vite proxies to. CI workflow follow-up commit wires the backend up. Co-authored-by: cloudcode <cloudcode@users.noreply.github.com>
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { expect } from "@playwright/test"
|
|
|
|
import { test } from "./fixtures"
|
|
|
|
test("manual cron trigger goes through POST, not GET", async ({ adminPage: page }) => {
|
|
const created = await page.request.post("/api/v1/cron", {
|
|
data: {
|
|
name: "e2e-cron-csrf",
|
|
task_type: 0,
|
|
scheduler: "@every 1h",
|
|
command: "true",
|
|
servers: [],
|
|
cover: 0,
|
|
push_successful: false,
|
|
notification_group_id: 0,
|
|
},
|
|
})
|
|
expect(created.ok(), "create cron via POST must succeed").toBeTruthy()
|
|
const { data: cronID } = (await created.json()) as { data: number }
|
|
expect(typeof cronID).toBe("number")
|
|
|
|
try {
|
|
const getResp = await page.request.get(`/api/v1/cron/${cronID}/manual`, {
|
|
failOnStatusCode: false,
|
|
})
|
|
expect(
|
|
getResp.status() === 404 || getResp.status() === 405,
|
|
`GET must no longer be routable (got ${getResp.status()})`,
|
|
).toBeTruthy()
|
|
|
|
const postResp = await page.request.post(`/api/v1/cron/${cronID}/manual`)
|
|
expect(postResp.ok(), `POST must succeed (got ${postResp.status()})`).toBeTruthy()
|
|
const body = await postResp.json()
|
|
expect(body.success).toBe(true)
|
|
} finally {
|
|
await page.request.post("/api/v1/batch-delete/cron", { data: [cronID] })
|
|
}
|
|
})
|