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

Function TestValidateWorkspaceHostnameSuffix

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

Source from the content-addressed store, hash-verified

237}
238
239func TestValidateWorkspaceHostnameSuffix(t *testing.T) {
240 t.Parallel()
241
242 testCases := []struct {
243 name string
244 suffix string
245 wantErr bool
246 }{
247 {name: "Coder", suffix: "coder"},
248 {name: "Example", suffix: "example"},
249 {name: "Dotted", suffix: "coder.example.com"},
250 {name: "Empty", suffix: ""},
251 {name: "LeadingDot", suffix: ".coder", wantErr: true},
252 {name: "Newline", suffix: "coder\nHost *\n\tProxyCommand evil", wantErr: true},
253 {name: "CarriageReturn", suffix: "coder\r\nHost *", wantErr: true},
254 {name: "Space", suffix: "coder Host *", wantErr: true},
255 {name: "Tab", suffix: "coder\t*", wantErr: true},
256 {name: "NUL", suffix: "coder\x00", wantErr: true},
257 {name: "NonBreakingSpace", suffix: "coder\u00A0suffix", wantErr: true},
258 {name: "Glob", suffix: "*", wantErr: true},
259 {name: "GlobPrefix", suffix: "*.*", wantErr: true},
260 {name: "QuestionMark", suffix: "code?", wantErr: true},
261 }
262
263 for _, tt := range testCases {
264 t.Run(tt.name, func(t *testing.T) {
265 t.Parallel()
266
267 err := codersdk.ValidateWorkspaceHostnameSuffix(tt.suffix)
268 if tt.wantErr {
269 require.Error(t, err)
270 return
271 }
272 require.NoError(t, err)
273 })
274 }
275}
276
277func TestValidateWorkspaceHostnamePrefix(t *testing.T) {
278 t.Parallel()

Callers

nothing calls this directly

Calls 3

RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected