Must not authenticate with bad password hash
(t *testing.T)
| 370 | |
| 371 | // Must not authenticate with bad password hash |
| 372 | func TestUserAuthenticateWithBadPasswordHash(t *testing.T) { |
| 373 | base.SetUpTestLogging(t, base.LevelDebug, base.KeyAuth) |
| 374 | const ( |
| 375 | username = "alice" |
| 376 | password = "hunter2" |
| 377 | ) |
| 378 | ctx := base.TestCtx(t) |
| 379 | testBucket := base.GetTestBucket(t) |
| 380 | defer testBucket.Close(ctx) |
| 381 | dataStore := testBucket.GetSingleDataStore() |
| 382 | auth := NewTestAuthenticator(t, dataStore, nil, DefaultAuthenticatorOptions(ctx)) |
| 383 | |
| 384 | user, err := auth.NewUser(username, password, base.Set{}) |
| 385 | assert.NoError(t, err) |
| 386 | assert.NotNil(t, user) |
| 387 | |
| 388 | err = user.SetPassword("hunter3") |
| 389 | require.NoError(t, err) |
| 390 | assert.False(t, user.Authenticate(password)) |
| 391 | } |
| 392 | |
| 393 | // Must not authenticate if No hash, but (incorrect) password provided. |
| 394 | func TestUserAuthenticateWithNoHashAndBadPassword(t *testing.T) { |
nothing calls this directly
no test coverage detected