Files
kca/e2e/tests/crypto.spec.js
woggioni 1a7b4a10e8
CI / Build and push docker image (push) Successful in 37s
CI / Build and push OCSP image (push) Successful in 38s
Add full XCA curve and digest parity
2026-10-26 12:06:17 +08:00

69 lines
3.4 KiB
JavaScript

// XCA curve and signature-hash options through the real SPA.
const { test, expect } = require("@playwright/test");
function unique(prefix) {
return `${prefix}-${Date.now()}-${Math.floor(Math.random() * 1000)}`;
}
async function field(page, label) {
return page.locator("label").filter({ hasText: label }).first().locator("..").locator("input, select, textarea").first();
}
async function login(page, username) {
await page.goto("/login");
await page.getByRole("link", { name: "Sign in with default" }).click();
await page.getByPlaceholder("Enter any user/subject").fill(username);
await page.getByRole("button", { name: "Sign-in" }).click();
await expect(page.getByRole("heading", { name: "Vaults" })).toBeVisible();
}
test("all curve options, per-key hashes and default curve persistence", async ({ page }) => {
const user = unique("crypto");
const vaultName = unique("Crypto Vault");
const keyName = unique("compat-key");
const requestName = unique("compat-request");
await login(page, user);
await page.getByRole("button", { name: "New vault" }).click();
await page.getByPlaceholder("Production PKI").fill(vaultName);
await page.getByRole("button", { name: "Create vault" }).click();
await page.getByRole("link", { name: vaultName }).click();
const vaultUrl = page.url();
await page.goto(`${vaultUrl}/keys/new`);
await (await field(page, "Key type")).selectOption("ec");
const curve = await field(page, "Curve");
await expect(curve.locator("option")).toHaveCount(79);
await curve.selectOption("secp112r1");
await expect(page.getByText(/secp112r1 is marked as insecure/)).toBeVisible();
await (await field(page, "Internal name")).fill(keyName);
await page.getByRole("button", { name: "Generate key" }).click();
await expect(page.getByRole("heading", { name: keyName })).toBeVisible();
await expect(page.getByText("secp112r1", { exact: true })).toBeVisible();
await page.goto(`${vaultUrl}/requests/new`);
await (await field(page, "Internal name")).fill(requestName);
await (await field(page, "Common name (CN)")).fill("compat.example.com");
await page.locator("label").filter({ hasText: "Existing key" }).locator("xpath=following-sibling::select[1]").selectOption({ label: `${keyName} (EC)` });
const hash = await field(page, "Signature hash");
await expect(hash.locator("option")).toHaveCount(9);
await expect(hash.locator('option[value="md5"]')).toHaveCount(0);
await expect(hash.locator('option[value="ripemd160"]')).toHaveCount(0);
await hash.selectOption("sha3-256");
await page.getByRole("button", { name: "Create request" }).click();
await expect(page.getByRole("heading", { name: requestName })).toBeVisible();
await expect(page.getByText("ecdsa_with_SHA3-256", { exact: true })).toBeVisible();
await page.goto(`${vaultUrl}/settings`);
await (await field(page, "Default key type")).selectOption("ec");
const defaultCurve = await field(page, "Curve");
await expect(defaultCurve.locator("option")).toHaveCount(79);
await defaultCurve.selectOption("prime192v2");
await (await field(page, "Default signature hash")).selectOption("ripemd160");
await page.getByRole("button", { name: "Save settings" }).click();
await expect(page.getByText("Settings saved.")).toBeVisible();
await page.reload();
await expect(await field(page, "Curve")).toHaveValue("prime192v2");
await expect(await field(page, "Default signature hash")).toHaveValue("ripemd160");
});