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

Function TestSanitizeCredentialHint

coderd/database/db2sdk/db2sdk_internal_test.go:310–334  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

308}
309
310func TestSanitizeCredentialHint(t *testing.T) {
311 t.Parallel()
312
313 tests := []struct {
314 name string
315 input string
316 expected string
317 }{
318 {"valid_short", "s...t", "s...t"},
319 {"valid_long", "sk-a...efgh", "sk-a...efgh"},
320 {"valid_only_dots", "...", "..."},
321 {"empty", "", ""},
322 {"short_unmasked_secret", "abc12", "..."},
323 {"missing_dots", "sk-abcdefgh", "..."},
324 {"too_long", "sk-a...efghijklmn", "..."},
325 {"raw_secret", "sk-proj-abc123xyz789", "..."},
326 }
327
328 for _, tc := range tests {
329 t.Run(tc.name, func(t *testing.T) {
330 t.Parallel()
331 require.Equal(t, tc.expected, sanitizeCredentialHint(tc.input))
332 })
333 }
334}

Callers

nothing calls this directly

Calls 3

sanitizeCredentialHintFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected