-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
36 lines (31 loc) · 817 Bytes
/
Copy pathmain_test.go
File metadata and controls
36 lines (31 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"strings"
"testing"
)
func TestIsInsecureInitialAdminPassword(t *testing.T) {
cases := []struct {
pw string
insecure bool
}{
// Banned defaults — regardless of length.
{"changeme", true},
{"admin", true},
{"password", true},
// Too short.
{"", true},
{"short", true},
{strings.Repeat("a", minInitialAdminPasswordLen-1), true},
// Long enough and not a banned default.
{strings.Repeat("a", minInitialAdminPasswordLen), false},
{"correct-horse-battery-staple", false},
{"a-Reasonable-Pass-123", false},
}
for _, tc := range cases {
t.Run(tc.pw, func(t *testing.T) {
if got := isInsecureInitialAdminPassword(tc.pw); got != tc.insecure {
t.Errorf("isInsecureInitialAdminPassword(%q) = %v, want %v", tc.pw, got, tc.insecure)
}
})
}
}