fix(wireguard): проверять конфигурацию до импорта
This commit is contained in:
1 parent
7ce43adc07
commit
479f2adc78
14 files changed
+247
-30
No files matched your search
@@ -208,6 +208,27 @@ test("WireGuard: импорт сохраняет форму без подтве
|
||||
expect(attempts).toBe(5)
|
||||
})
|
||||
|
||||
test("WireGuard: ошибка проверки .conf сохраняет клиентский шаблон и выбранный сервер", async ({ page }) => {
|
||||
await setup(page, "/wireguard?server=2")
|
||||
const content = "[Interface]\n# PrivateKey = <заполните ключ>\n[Peer]\n# AllowedIPs = <укажите сети>"
|
||||
let attempts = 0
|
||||
await page.route("**/api/wireguard/import", route => {
|
||||
expect(route.request().postDataJSON()).toMatchObject({ serverId: "2", content, dryRun: false })
|
||||
attempts++
|
||||
return route.fulfill({ status: 400, json: { error: "Заполните PrivateKey: клиентский шаблон нельзя применить без приватного ключа" } })
|
||||
})
|
||||
await page.getByRole("button", { name: "Импорт", exact: true }).click()
|
||||
const dialog = page.getByRole("dialog", { name: "Импорт конфига WireGuard" })
|
||||
await expect(dialog).toContainText("без Name используется имя wg0")
|
||||
await dialog.getByLabel("Конфигурация WireGuard", { exact: true }).fill(content)
|
||||
await dialog.getByRole("button", { name: "Применить на роутер" }).click()
|
||||
await expect(dialog.getByRole("alert")).toContainText("Заполните PrivateKey")
|
||||
await expect(dialog.getByLabel("Конфигурация WireGuard", { exact: true })).toHaveValue(content)
|
||||
await expect(dialog.getByLabel("Сервер", { exact: true })).toHaveValue("2")
|
||||
await expect(dialog.getByRole("button", { name: "Применить на роутер" })).toBeEnabled()
|
||||
expect(attempts).toBe(1)
|
||||
})
|
||||
|
||||
test("WireGuard: импорт удерживает форму до ответа и разрешает повтор", async ({ page }) => {
|
||||
await setup(page, "/wireguard?server=1")
|
||||
let attempts = 0
|
||||
|
||||
Reference in new issue
Block a user