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

Function TestUserPasswordValidate

coderd/userpassword/userpassword_test.go:16–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestUserPasswordValidate(t *testing.T) {
17 t.Parallel()
18 tests := []struct {
19 name string
20 password string
21 wantErr bool
22 }{
23 {name: "Invalid - Too short password", password: "pass", wantErr: true},
24 {name: "Invalid - Too long password", password: strings.Repeat("a", 65), wantErr: true},
25 {name: "Invalid - easy password", password: "password", wantErr: true},
26 {name: "Ok", password: "PasswordSecured123!", wantErr: false},
27 }
28
29 for _, tt := range tests {
30 t.Run(tt.name, func(t *testing.T) {
31 t.Parallel()
32 err := userpassword.Validate(tt.password)
33 if tt.wantErr {
34 require.Error(t, err)
35 } else {
36 require.NoError(t, err)
37 }
38 })
39 }
40}
41
42func TestUserPasswordCompare(t *testing.T) {
43 t.Parallel()

Callers

nothing calls this directly

Calls 3

ValidateFunction · 0.92
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected