MCPcopy Index your code
hub / github.com/coder/coder / TestValidateWorkspaceHostnamePrefix

Function TestValidateWorkspaceHostnamePrefix

codersdk/deployment_test.go:277–309  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

275}
276
277func TestValidateWorkspaceHostnamePrefix(t *testing.T) {
278 t.Parallel()
279
280 testCases := []struct {
281 name string
282 prefix string
283 wantErr bool
284 }{
285 {name: "Default", prefix: "coder."},
286 {name: "NoDot", prefix: "coder"},
287 {name: "Empty", prefix: ""},
288 {name: "LeadingDot", prefix: ".coder"},
289 {name: "Newline", prefix: "coder.\nHost *\n\tProxyCommand evil", wantErr: true},
290 {name: "CarriageReturn", prefix: "coder.\r\nHost *", wantErr: true},
291 {name: "Space", prefix: "coder. Host *", wantErr: true},
292 {name: "Tab", prefix: "coder.\t*", wantErr: true},
293 {name: "NUL", prefix: "coder.\x00", wantErr: true},
294 {name: "NonBreakingSpace", prefix: "coder.\u00A0x", wantErr: true},
295 }
296
297 for _, tt := range testCases {
298 t.Run(tt.name, func(t *testing.T) {
299 t.Parallel()
300
301 err := codersdk.ValidateWorkspaceHostnamePrefix(tt.prefix)
302 if tt.wantErr {
303 require.Error(t, err)
304 return
305 }
306 require.NoError(t, err)
307 })
308 }
309}
310
311func TestValidateSSHConfigOptions(t *testing.T) {
312 t.Parallel()

Callers

nothing calls this directly

Calls 3

RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected