Close XCA parity gaps: advanced extensions, CA/revocation UI, imports, ZIP export, E2E
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
// Advanced extensions, preview/validation and vault ZIP export.
|
||||
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("advanced extensions, validation and vault export", async ({ page }) => {
|
||||
const user = unique("advanced");
|
||||
const vaultName = unique("Advanced");
|
||||
const certName = unique("advanced.example");
|
||||
|
||||
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}/certificates/new`);
|
||||
await expect(page.getByRole("heading", { name: "New certificate" })).toBeVisible();
|
||||
await (await field(page, "Internal name")).fill(certName);
|
||||
await (await field(page, "Common name (CN)")).fill(certName);
|
||||
await (await field(page, "Organization (O)")).fill("KCA E2E");
|
||||
await (await field(page, "Country (C)")).fill("DE");
|
||||
await page.locator("#new-key").check();
|
||||
await page.locator("textarea[placeholder='http://example.com/ca.crl']").fill("http://example.com/ca.crl");
|
||||
await page.locator("textarea[placeholder='http://ocsp.example.com']").fill("http://ocsp.example.com");
|
||||
await page.locator("textarea[placeholder*='raw']").fill(
|
||||
'{"raw":[{"oid":"1.2.3.4","critical":false,"der_hex":"0c03616263"}]}'
|
||||
);
|
||||
|
||||
await page.getByRole("button", { name: "Validate extensions" }).click();
|
||||
await expect(page.getByText("Extension preview")).toBeVisible();
|
||||
await expect(page.getByText("CRL Distribution Points", { exact: false })).toBeVisible();
|
||||
await expect(page.getByText("1.2.3.4", { exact: false })).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Create certificate" }).click();
|
||||
await expect(page.getByRole("heading", { name: certName })).toBeVisible();
|
||||
await expect(page.getByText("CRL Distribution Points", { exact: false })).toBeVisible();
|
||||
await expect(page.getByText("1.2.3.4", { exact: false })).toBeVisible();
|
||||
|
||||
// ZIP export prompts for the private-key password.
|
||||
await page.goto(vaultUrl);
|
||||
page.once("dialog", (dialog) => dialog.accept("secret"));
|
||||
const downloadPromise = page.waitForEvent("download");
|
||||
await page.getByRole("button", { name: "Export ZIP" }).click();
|
||||
const download = await downloadPromise;
|
||||
expect(download.suggestedFilename()).toMatch(/\.zip$/);
|
||||
});
|
||||
Reference in New Issue
Block a user