MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestUserAuthenticateWithDisabledUserAccount

Function TestUserAuthenticateWithDisabledUserAccount

auth/user_test.go:327–346  ·  view source on GitHub ↗

Must not authenticate if the user account is disabled.

(t *testing.T)

Source from the content-addressed store, hash-verified

325
326// Must not authenticate if the user account is disabled.
327func 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.

Callers

nothing calls this directly

Calls 11

SetDisabledMethod · 0.95
DisabledMethod · 0.95
AuthenticateMethod · 0.95
SetUpTestLoggingFunction · 0.92
TestCtxFunction · 0.92
GetTestBucketFunction · 0.92
NewTestAuthenticatorFunction · 0.85
NewUserMethod · 0.80
CloseMethod · 0.65
GetSingleDataStoreMethod · 0.45

Tested by

no test coverage detected