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

Function TestUserPasswordCompare

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

Source from the content-addressed store, hash-verified

40}
41
42func TestUserPasswordCompare(t *testing.T) {
43 t.Parallel()
44 tests := []struct {
45 name string
46 passwordToValidate string
47 password string
48 shouldHash bool
49 wantErr bool
50 wantEqual bool
51 }{
52 {
53 name: "Legacy",
54 passwordToValidate: "$pbkdf2-sha256$65535$z8c1p1C2ru9EImBP1I+ZNA$pNjE3Yk0oG0PmJ0Je+y7ENOVlSkn/b0BEqqdKsq6Y97wQBq0xT+lD5bWJpyIKJqQICuPZcEaGDKrXJn8+SIHRg",
55 password: "tomato",
56 shouldHash: false,
57 wantErr: false,
58 wantEqual: true,
59 },
60 {
61 name: "Same",
62 passwordToValidate: "password",
63 password: "password",
64 shouldHash: true,
65 wantErr: false,
66 wantEqual: true,
67 },
68 {
69 name: "Different",
70 passwordToValidate: "password",
71 password: "notpassword",
72 shouldHash: true,
73 wantErr: false,
74 wantEqual: false,
75 },
76 {
77 name: "Invalid",
78 passwordToValidate: "invalidhash",
79 password: "password",
80 shouldHash: false,
81 wantErr: true,
82 wantEqual: false,
83 },
84 {
85 name: "InvalidParts",
86 passwordToValidate: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
87 password: "test",
88 shouldHash: false,
89 wantErr: true,
90 wantEqual: false,
91 },
92 {
93 name: "EmptyHashHunter2",
94 passwordToValidate: "",
95 password: "hunter2",
96 shouldHash: false,
97 wantErr: false,
98 wantEqual: false,
99 },

Callers

nothing calls this directly

Calls 5

HashFunction · 0.92
CompareFunction · 0.92
RunMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected