mirror of
https://github.com/coder/coder.git
synced 2026-06-04 05:28:20 +00:00
962608cde0
Closes coder/internal#168 Gets rid of the "global state" authentication, and adds a `login` helper which should be called at the beginning of each test. This means that not every test needs to authenticated as admin, and we can even have tests that encompass multiple permission levels. We also now create more than just the single admin user during setup, so that we can have a set of users to pick from as appropriate.
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import type { Page } from "@playwright/test";
|
|
import { expect, test } from "@playwright/test";
|
|
import { API, type DeploymentConfig } from "api/api";
|
|
import {
|
|
findConfigOption,
|
|
setupApiCalls,
|
|
verifyConfigFlagBoolean,
|
|
verifyConfigFlagNumber,
|
|
verifyConfigFlagString,
|
|
} from "../../api";
|
|
import { login } from "../../helpers";
|
|
import { beforeCoderTest } from "../../hooks";
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
beforeCoderTest(page);
|
|
await login(page);
|
|
await setupApiCalls(page);
|
|
});
|
|
|
|
test("enabled security settings", async ({ page }) => {
|
|
const config = await API.getDeploymentConfig();
|
|
|
|
await page.goto("/deployment/security", { waitUntil: "domcontentloaded" });
|
|
|
|
await verifyConfigFlagString(page, config, "ssh-keygen-algorithm");
|
|
await verifyConfigFlagBoolean(page, config, "secure-auth-cookie");
|
|
await verifyConfigFlagBoolean(page, config, "disable-owner-workspace-access");
|
|
|
|
await verifyConfigFlagBoolean(page, config, "tls-redirect-http-to-https");
|
|
await verifyStrictTransportSecurity(page, config);
|
|
await verifyConfigFlagString(page, config, "tls-address");
|
|
await verifyConfigFlagBoolean(page, config, "tls-allow-insecure-ciphers");
|
|
await verifyConfigFlagString(page, config, "tls-client-auth");
|
|
await verifyConfigFlagBoolean(page, config, "tls-enable");
|
|
await verifyConfigFlagString(page, config, "tls-min-version");
|
|
});
|
|
|
|
async function verifyStrictTransportSecurity(
|
|
page: Page,
|
|
config: DeploymentConfig,
|
|
) {
|
|
const flag = "strict-transport-security";
|
|
const opt = findConfigOption(config, flag);
|
|
if (opt.value !== 0) {
|
|
await verifyConfigFlagNumber(page, config, flag);
|
|
return;
|
|
}
|
|
|
|
const configOption = page.locator(
|
|
`div.options-table .option-${flag} .option-value-string`,
|
|
);
|
|
await expect(configOption).toHaveText("Disabled");
|
|
}
|