(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestUserAuthenticateDisabled(t *testing.T) { |
| 27 | const ( |
| 28 | username = "alice" |
| 29 | oldPassword = "hunter2" |
| 30 | ) |
| 31 | |
| 32 | base.SetUpTestLogging(t, base.LevelDebug, base.KeyAuth) |
| 33 | |
| 34 | ctx := base.TestCtx(t) |
| 35 | bucket := base.GetTestBucket(t) |
| 36 | defer bucket.Close(ctx) |
| 37 | dataStore := bucket.GetSingleDataStore() |
| 38 | // Create user |
| 39 | auth := NewTestAuthenticator(t, dataStore, nil, DefaultAuthenticatorOptions(ctx)) |
| 40 | u, err := auth.NewUser(username, oldPassword, base.Set{}) |
| 41 | assert.NoError(t, err) |
| 42 | assert.NotNil(t, u) |
| 43 | |
| 44 | assert.False(t, u.Disabled()) |
| 45 | // Correct password, activated account |
| 46 | assert.True(t, u.Authenticate(oldPassword)) |
| 47 | // Incorrect password, activated account |
| 48 | assert.False(t, u.Authenticate("test")) |
| 49 | |
| 50 | // Disable account |
| 51 | u.SetDisabled(true) |
| 52 | |
| 53 | assert.True(t, u.Disabled()) |
| 54 | // Correct password, disabled account |
| 55 | assert.False(t, u.Authenticate(oldPassword)) |
| 56 | // Incorrect password, disabled account |
| 57 | assert.False(t, u.Authenticate("test")) |
| 58 | |
| 59 | } |
| 60 | |
| 61 | func TestUserAuthenticatePasswordHashUpgrade(t *testing.T) { |
| 62 | const ( |
nothing calls this directly
no test coverage detected