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

Function TestUserAuthenticateDisabled

auth/user_test.go:26–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func 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
61func TestUserAuthenticatePasswordHashUpgrade(t *testing.T) {
62 const (

Callers

nothing calls this directly

Calls 11

DisabledMethod · 0.95
AuthenticateMethod · 0.95
SetDisabledMethod · 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