Must not authenticate if old hash is present. Password must be reset to use new (bcrypt) password hash.
(t *testing.T)
| 348 | // Must not authenticate if old hash is present. |
| 349 | // Password must be reset to use new (bcrypt) password hash. |
| 350 | func TestUserAuthenticateWithOldPasswordHash(t *testing.T) { |
| 351 | base.SetUpTestLogging(t, base.LevelDebug, base.KeyAuth) |
| 352 | const ( |
| 353 | username = "alice" |
| 354 | password = "hunter2" |
| 355 | ) |
| 356 | ctx := base.TestCtx(t) |
| 357 | testBucket := base.GetTestBucket(t) |
| 358 | defer testBucket.Close(ctx) |
| 359 | dataStore := testBucket.GetSingleDataStore() |
| 360 | auth := NewTestAuthenticator(t, dataStore, nil, DefaultAuthenticatorOptions(ctx)) |
| 361 | |
| 362 | user, err := auth.NewUser(username, password, base.Set{}) |
| 363 | assert.NoError(t, err) |
| 364 | assert.NotNil(t, user) |
| 365 | |
| 366 | passwordHash := user.(*userImpl).PasswordHash_ |
| 367 | user.(*userImpl).OldPasswordHash_ = passwordHash |
| 368 | assert.False(t, user.Authenticate(password)) |
| 369 | } |
| 370 | |
| 371 | // Must not authenticate with bad password hash |
| 372 | func TestUserAuthenticateWithBadPasswordHash(t *testing.T) { |
nothing calls this directly
no test coverage detected