fix(ipsec): удалять сертификат только по явной привязке

This commit is contained in:
Denozordec committed 2026-10-10 21:26:48 +07:00
1 parent d52c48e5ed
commit 057b530364
16 files changed
+644 -22

No files matched your search

+24
View File
@@ -1,5 +1,29 @@
import { test, expect } from "@playwright/test"
for (const width of [1280,320]) {
test(`IPsec: удаление PSK объясняет сохранение сертификатов ${width}px`, async ({ page }) => {
await page.setViewportSize({ width, height: 1000 })
let deleted = false
const certificate = { id: "cert", rosId: "cert:*D", serverId: "1", serverName: "Роутер", name: "Отдельный сертификат", kind: "cert", certName: "ipsec-user-psk", authMethod: "certificate", online: false, disabled: false, managed: true }
await page.route("**/health", r => r.fulfill({ json: { ok: true } }))
await page.route("**/api/**", r => {
const path = new URL(r.request().url()).pathname
if (r.request().method() === "DELETE") { expect(decodeURIComponent(path)).toBe("/api/ipsec/users/1/identity:*P"); deleted = true; return r.fulfill({ json: { ok: true } }) }
return r.fulfill({ json: path === "/api/ipsec" ? { servers: [{ serverId: "1", serverName: "Роутер", initialized: true, ike2Ready: true, natRuleManaged: false, clientsTotal: deleted ? 1 : 2, clientsOnline: 0 }], clients: [certificate,...(deleted ? [] : [{ ...certificate, id: "psk", rosId: "identity:*P", certName: undefined, name: "PSK клиент", kind: "psk", authMethod: "pre-shared-key" }])] }
: path === "/api/servers" ? [{ id: 1, name: "Роутер", host: "192.0.2.1", enabled: true, type: "exit-node", country: "RU", status: "online" }] : path === "/api/auth/config" ? { required: false } : {} })
})
await page.goto("/ipsec?server=1")
await page.locator("tr[data-row-id]").filter({ has: page.getByRole("button", { name: "PSK клиент", exact: true }) }).getByRole("button", { name: "Удалить клиента", exact: true }).click()
const dialog = page.getByRole("alertdialog")
await expect(dialog).toContainText("Сертификаты останутся на роутере")
await expect(dialog.getByRole("checkbox")).toHaveCount(0)
await dialog.getByRole("button", { name: "Удалить", exact: true }).click()
await expect(dialog).toHaveCount(0)
await expect(page.getByRole("button", { name: "PSK клиент", exact: true })).toHaveCount(0)
await expect(page.getByRole("button", { name: "Отдельный сертификат", exact: true })).toBeVisible()
})
}
for (const width of [1280, 320]) for (const shared of [false, true]) {
test(`IPsec: сохранить сертификат при удалении identity shared=${shared} ${width}px`, async ({ page }) => {
await page.setViewportSize({ width, height: 1000 })