MCPcopy Index your code
hub / github.com/prest/prest / TestAuthHandler_basicPasswordCheck_bcrypt

Function TestAuthHandler_basicPasswordCheck_bcrypt

controllers/auth_test.go:303–329  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

301}
302
303func TestAuthHandler_basicPasswordCheck_bcrypt(t *testing.T) {
304 ctrl := gomock.NewController(t)
305 defer ctrl.Finish()
306
307 hash, err := HashPassword("pw")
308 require.NoError(t, err)
309
310 executor := mockgen.NewMockQueryExecutor(ctrl)
311 sc := mockgen.NewMockScanner(ctrl)
312 cfg := testAuthConfig()
313 cfg.Encrypt = "bcrypt"
314 h := NewAuthHandler(executor, cfg)
315
316 executor.EXPECT().
317 Query(h.selectQueryByUsername(), "carol").
318 Return(sc)
319 sc.EXPECT().Err().Return(nil)
320 sc.EXPECT().Scan(gomock.Any()).DoAndReturn(func(dest interface{}) (int, error) {
321 row := dest.(*loginRow)
322 *row = loginRow{ID: 3, Username: "carol", Password: hash}
323 return 1, nil
324 })
325
326 user, err := h.basicPasswordCheck("carol", "pw")
327 require.NoError(t, err)
328 require.Equal(t, "carol", user.Username)
329}
330
331func TestAuthHandler_basicPasswordCheck_bcryptWrongPassword(t *testing.T) {
332 ctrl := gomock.NewController(t)

Callers

nothing calls this directly

Calls 12

EXPECTMethod · 0.95
selectQueryByUsernameMethod · 0.95
EXPECTMethod · 0.95
basicPasswordCheckMethod · 0.95
NewMockQueryExecutorFunction · 0.92
NewMockScannerFunction · 0.92
HashPasswordFunction · 0.85
testAuthConfigFunction · 0.85
NewAuthHandlerFunction · 0.85
QueryMethod · 0.65
ErrMethod · 0.65
ScanMethod · 0.65

Tested by

no test coverage detected