Must not authenticate if No hash, but (incorrect) password provided.
(t *testing.T)
| 392 | |
| 393 | // Must not authenticate if No hash, but (incorrect) password provided. |
| 394 | func TestUserAuthenticateWithNoHashAndBadPassword(t *testing.T) { |
| 395 | base.SetUpTestLogging(t, base.LevelDebug, base.KeyAuth) |
| 396 | const ( |
| 397 | username = "alice" |
| 398 | password = "hunter2" |
| 399 | ) |
| 400 | ctx := base.TestCtx(t) |
| 401 | testBucket := base.GetTestBucket(t) |
| 402 | defer testBucket.Close(ctx) |
| 403 | dataStore := testBucket.GetSingleDataStore() |
| 404 | auth := NewTestAuthenticator(t, dataStore, nil, DefaultAuthenticatorOptions(ctx)) |
| 405 | |
| 406 | user, err := auth.NewUser(username, password, base.Set{}) |
| 407 | assert.NoError(t, err) |
| 408 | assert.NotNil(t, user) |
| 409 | |
| 410 | user.(*userImpl).OldPasswordHash_ = nil |
| 411 | assert.False(t, user.Authenticate("hunter3")) |
| 412 | } |
| 413 | |
| 414 | func TestUserKeysHash(t *testing.T) { |
| 415 | for _, metadataDefault := range []bool{false, true} { |
nothing calls this directly
no test coverage detected