MCPcopy Create free account
hub / github.com/gogs/gogs / TestValidatePassword

Function TestValidatePassword

internal/userutil/userutil_test.go:145–179  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

143}
144
145func TestValidatePassword(t *testing.T) {
146 want := EncodePassword("123456", "rands")
147 tests := []struct {
148 name string
149 password string
150 rands string
151 wantEqual bool
152 }{
153 {
154 name: "correct",
155 password: "123456",
156 rands: "rands",
157 wantEqual: true,
158 },
159
160 {
161 name: "wrong password",
162 password: "111333",
163 rands: "rands",
164 wantEqual: false,
165 },
166 {
167 name: "wrong salt",
168 password: "111333",
169 rands: "salt",
170 wantEqual: false,
171 },
172 }
173 for _, test := range tests {
174 t.Run(test.name, func(t *testing.T) {
175 got := ValidatePassword(want, test.rands, test.password)
176 assert.Equal(t, test.wantEqual, got)
177 })
178 }
179}
180
181func TestMailResendCacheKey(t *testing.T) {
182 got := MailResendCacheKey(1)

Callers

nothing calls this directly

Calls 2

EncodePasswordFunction · 0.85
ValidatePasswordFunction · 0.85

Tested by

no test coverage detected