@@ -147,69 +147,5 @@ describe("login", () => {
147
147
expect ( htmlContent ) . toContain ( `欢迎来到 code-server` )
148
148
} )
149
149
150
- it ( "should return custom login title" , async ( ) => {
151
- process . env . PASSWORD = previousEnvPassword
152
- const loginTitle = "Custom Access Portal"
153
- const codeServer = await integration . setup ( [ `--login-title=${ loginTitle } ` ] , "" )
154
- const resp = await codeServer . fetch ( "/login" , { method : "GET" } )
155
-
156
- const htmlContent = await resp . text ( )
157
- expect ( resp . status ) . toBe ( 200 )
158
- expect ( htmlContent ) . toContain ( `<title>${ loginTitle } </title>` )
159
- } )
160
-
161
- it ( "should return custom password placeholder" , async ( ) => {
162
- process . env . PASSWORD = previousEnvPassword
163
- const placeholder = "Enter access code"
164
- const codeServer = await integration . setup ( [ `--password-placeholder=${ placeholder } ` ] , "" )
165
- const resp = await codeServer . fetch ( "/login" , { method : "GET" } )
166
-
167
- const htmlContent = await resp . text ( )
168
- expect ( resp . status ) . toBe ( 200 )
169
- expect ( htmlContent ) . toContain ( `placeholder="${ placeholder } "` )
170
- } )
171
-
172
- it ( "should return custom submit button text" , async ( ) => {
173
- process . env . PASSWORD = previousEnvPassword
174
- const submitText = "ACCESS PORTAL"
175
- const codeServer = await integration . setup ( [ `--submit-text=${ submitText } ` ] , "" )
176
- const resp = await codeServer . fetch ( "/login" , { method : "GET" } )
177
-
178
- const htmlContent = await resp . text ( )
179
- expect ( resp . status ) . toBe ( 200 )
180
- expect ( htmlContent ) . toContain ( `value="${ submitText } "` )
181
- } )
182
-
183
- it ( "should return custom env password message" , async ( ) => {
184
- const envMessage = "Password configured via container environment"
185
- const codeServer = await integration . setup ( [ `--login-env-password-msg=${ envMessage } ` , `--password=test123` ] , "" )
186
- const resp = await codeServer . fetch ( "/login" , { method : "GET" } )
187
-
188
- const htmlContent = await resp . text ( )
189
- expect ( resp . status ) . toBe ( 200 )
190
- expect ( htmlContent ) . toContain ( envMessage )
191
- } )
192
-
193
- it ( "should escape HTML in custom messages" , async ( ) => {
194
- process . env . PASSWORD = previousEnvPassword
195
- const maliciousTitle = "<script>alert('xss')</script>"
196
- const codeServer = await integration . setup ( [ `--login-title=${ maliciousTitle } ` , `--password=test123` ] , "" )
197
- const resp = await codeServer . fetch ( "/login" , { method : "GET" } )
198
-
199
- const htmlContent = await resp . text ( )
200
- expect ( resp . status ) . toBe ( 200 )
201
- expect ( htmlContent ) . toContain ( "<script>alert('xss')</script>" )
202
- expect ( htmlContent ) . not . toContain ( "<script>alert('xss')</script>" )
203
- } )
204
-
205
- it ( "should return custom error messages" , async ( ) => {
206
- const customMissingMsg = "Access code required"
207
- const codeServer = await integration . setup ( [ `--missing-password-msg=${ customMissingMsg } ` , `--password=test123` ] , "" )
208
- const resp = await codeServer . fetch ( "/login" , { method : "POST" } )
209
-
210
- const htmlContent = await resp . text ( )
211
- expect ( resp . status ) . toBe ( 200 )
212
- expect ( htmlContent ) . toContain ( customMissingMsg )
213
- } )
214
150
} )
215
151
} )
0 commit comments