Must not authenticate if the user account is disabled.
(t *testing.T)
| 325 | |
| 326 | // Must not authenticate if the user account is disabled. |
| 327 | func TestUserAuthenticateWithDisabledUserAccount(t *testing.T) { |
| 328 | base.SetUpTestLogging(t, base.LevelDebug, base.KeyAuth) |
| 329 | const ( |
| 330 | username = "alice" |
| 331 | password = "hunter2" |
| 332 | ) |
| 333 | ctx := base.TestCtx(t) |
| 334 | testBucket := base.GetTestBucket(t) |
| 335 | defer testBucket.Close(ctx) |
| 336 | dataStore := testBucket.GetSingleDataStore() |
| 337 | auth := NewTestAuthenticator(t, dataStore, nil, DefaultAuthenticatorOptions(ctx)) |
| 338 | |
| 339 | user, err := auth.NewUser(username, password, base.Set{}) |
| 340 | assert.NoError(t, err) |
| 341 | assert.NotNil(t, user) |
| 342 | |
| 343 | user.SetDisabled(true) |
| 344 | assert.True(t, user.Disabled()) |
| 345 | assert.False(t, user.Authenticate(password)) |
| 346 | } |
| 347 | |
| 348 | // Must not authenticate if old hash is present. |
| 349 | // Password must be reset to use new (bcrypt) password hash. |
nothing calls this directly
no test coverage detected