Skip to content

Commit 8156910

Browse files
committed
WIP
1 parent 1daff36 commit 8156910

File tree

4 files changed

+56
-18
lines changed

4 files changed

+56
-18
lines changed

site/e2e/playwright.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default defineConfig({
3232
timeout: 50_000,
3333
},
3434
],
35-
reporter: [["./reporter.ts"]],
35+
//reporter: [["./reporter.ts"]],
3636
use: {
3737
baseURL: `http://localhost:${coderPort}`,
3838
video: "retain-on-failure",
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { expect, test, type Page } from "@playwright/test";
2+
import * as API from "api/api";
3+
import { setupApiCalls } from "../../api";
4+
5+
test("enabled security settings", async ({ page }) => {
6+
await setupApiCalls(page);
7+
8+
await page.goto("/deployment/security", { waitUntil: "domcontentloaded" });
9+
10+
// Load deployment settings
11+
const config = await API.getDeploymentConfig();
12+
13+
// Check flags
14+
await expectConfigOption(page, config, "ssh-keygen-algorithm")
15+
await expectConfigOption(page, config, "secure-auth-cookie")
16+
await expectConfigOption(page, config, "disable-owner-workspace-access")
17+
18+
await expectConfigOption(page, config, "tls-redirect-http-to-https")
19+
await expectConfigOption(page, config, "strict-transport-security")
20+
await expectConfigOption(page, config, "tls-address")
21+
await expectConfigOption(page, config, "tls-allow-insecure-ciphers")
22+
});
23+
24+
const expectConfigOption = async(page :Page, config: API.DeploymentConfig, flag: string) => {
25+
let value = config.options.find(option => option.flag === flag)?.value;
26+
if (value === undefined) {
27+
throw new Error(`Option with env ${flag} has undefined value.`);
28+
}
29+
30+
let type = "";
31+
if (typeof value === "boolean") {
32+
type = value ? "option-enabled" : "option-disabled";
33+
value = value ? "Enabled" : "Disabled";
34+
} else if (typeof value === "number") {
35+
type = "option-value-number";
36+
value = String(value);
37+
} else if (!value || value.length === 0) {
38+
type = "option-value-empty";
39+
} else if (typeof value === "string") {
40+
type = "option-value-string";
41+
} else if (typeof value === "object") {
42+
type = "object-array";
43+
} else {
44+
type = "option-value-json";
45+
}
46+
47+
const configOption = page.locator(`div.options-table .option-${flag} .${type}`);
48+
await expect(configOption).toHaveText(String(value));
49+
}

site/e2e/tests/deployment/security.ts

-15
This file was deleted.

site/src/pages/DeploySettingsPage/Option.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ export const OptionValue: FC<OptionValueProps> = (props) => {
3434
const theme = useTheme();
3535

3636
if (typeof value === "boolean") {
37-
return value ? <EnabledBadge /> : <DisabledBadge />;
37+
return (
38+
<div className="option-value-boolean">
39+
{value ? <EnabledBadge /> : <DisabledBadge />}
40+
</div>
41+
);
3842
}
3943

4044
if (typeof value === "number") {
@@ -106,7 +110,7 @@ export const OptionValue: FC<OptionValueProps> = (props) => {
106110

107111
if (Array.isArray(value)) {
108112
return (
109-
<ul css={{ listStylePosition: "inside" }}>
113+
<ul css={{ listStylePosition: "inside" }} className="option-array">
110114
{value.map((item) => (
111115
<li key={item} css={styles.option}>
112116
{item}

0 commit comments

Comments
 (0)