Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4968916

Browse files
authored
test(site): add e2e tests for security (#12961)
1 parent9a4703a commit4968916

File tree

3 files changed

+103
-7
lines changed

3 files changed

+103
-7
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import{expect,test,typePage}from"@playwright/test";
2+
import*asAPIfrom"api/api";
3+
import{setupApiCalls}from"../../api";
4+
5+
test("enabled security settings",async({ page})=>{
6+
awaitsetupApiCalls(page);
7+
8+
constconfig=awaitAPI.getDeploymentConfig();
9+
10+
awaitpage.goto("/deployment/security",{waitUntil:"domcontentloaded"});
11+
12+
constflags=[
13+
"ssh-keygen-algorithm",
14+
"secure-auth-cookie",
15+
"disable-owner-workspace-access",
16+
17+
"tls-redirect-http-to-https",
18+
"strict-transport-security",
19+
"tls-address",
20+
"tls-allow-insecure-ciphers",
21+
"tls-client-auth",
22+
"tls-enable",
23+
"tls-min-version",
24+
];
25+
26+
for(constflagofflags){
27+
awaitverifyConfigFlag(page,config,flag);
28+
}
29+
});
30+
31+
constverifyConfigFlag=async(
32+
page:Page,
33+
config:API.DeploymentConfig,
34+
flag:string,
35+
)=>{
36+
constopt=config.options.find((option)=>option.flag===flag);
37+
if(opt===undefined){
38+
thrownewError(`Option with env${flag} has undefined value.`);
39+
}
40+
41+
// Map option type to test class name.
42+
lettype="",
43+
value=opt.value;
44+
if(typeofvalue==="boolean"){
45+
// Boolean options map to string (Enabled/Disabled).
46+
type=value ?"option-enabled" :"option-disabled";
47+
value=value ?"Enabled" :"Disabled";
48+
}elseif(typeofvalue==="number"){
49+
type="option-value-number";
50+
value=String(value);
51+
}elseif(!value||value.length===0){
52+
type="option-value-empty";
53+
}elseif(typeofvalue==="string"){
54+
type="option-value-string";
55+
}elseif(typeofvalue==="object"){
56+
type="object-array";
57+
}else{
58+
type="option-value-json";
59+
}
60+
61+
// Special cases
62+
if(opt.flag==="strict-transport-security"&&opt.value===0){
63+
type="option-value-string";
64+
value="Disabled";// Display "Disabled" instead of zero seconds.
65+
}
66+
67+
constconfigOption=page.locator(
68+
`div.options-table .option-${flag} .${type}`,
69+
);
70+
awaitexpect(configOption).toHaveText(String(value));
71+
};

‎site/src/components/Badges/Badges.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ const styles = {
4141
}satisfiesRecord<string,Interpolation<Theme>>;
4242

4343
exportconstEnabledBadge:FC=()=>{
44-
return<spancss={[styles.badge,styles.enabledBadge]}>Enabled</span>;
44+
return(
45+
<spancss={[styles.badge,styles.enabledBadge]}className="option-enabled">
46+
Enabled
47+
</span>
48+
);
4549
};
4650

4751
exportconstEntitledBadge:FC=()=>{
@@ -95,6 +99,7 @@ export const DisabledBadge: FC = forwardRef<
9599
color:theme.experimental.l1.text,
96100
}),
97101
]}
102+
className="option-disabled"
98103
>
99104
Disabled
100105
</span>

‎site/src/pages/DeploySettingsPage/Option.tsx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,35 @@ export const OptionValue: FC<OptionValueProps> = (props) => {
3434
consttheme=useTheme();
3535

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

4044
if(typeofvalue==="number"){
41-
return<spancss={styles.option}>{value}</span>;
45+
return(
46+
<spancss={styles.option}className="option-value-number">
47+
{value}
48+
</span>
49+
);
4250
}
4351

4452
if(!value||value.length===0){
45-
return<spancss={styles.option}>Not set</span>;
53+
return(
54+
<spancss={styles.option}className="option-value-empty">
55+
Not set
56+
</span>
57+
);
4658
}
4759

4860
if(typeofvalue==="string"){
49-
return<spancss={styles.option}>{value}</span>;
61+
return(
62+
<spancss={styles.option}className="option-value-string">
63+
{value}
64+
</span>
65+
);
5066
}
5167

5268
if(typeofvalue==="object"&&!Array.isArray(value)){
@@ -94,7 +110,7 @@ export const OptionValue: FC<OptionValueProps> = (props) => {
94110

95111
if(Array.isArray(value)){
96112
return(
97-
<ulcss={{listStylePosition:"inside"}}>
113+
<ulcss={{listStylePosition:"inside"}}className="option-array">
98114
{value.map((item)=>(
99115
<likey={item}css={styles.option}>
100116
{item}
@@ -104,7 +120,11 @@ export const OptionValue: FC<OptionValueProps> = (props) => {
104120
);
105121
}
106122

107-
return<spancss={styles.option}>{JSON.stringify(value)}</span>;
123+
return(
124+
<spancss={styles.option}className="option-value-json">
125+
{JSON.stringify(value)}
126+
</span>
127+
);
108128
};
109129

110130
typeOptionConfigProps=HTMLAttributes<HTMLDivElement>&{isSource:boolean};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp