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

Function TestUserAuthenticateWithOldPasswordHash

auth/user_test.go:350–369  ·  view source on GitHub ↗

Must not authenticate if old hash is present. Password must be reset to use new (bcrypt) password hash.

(t *testing.T)

Source from the content-addressed store, hash-verified

348// Must not authenticate if old hash is present.
349// Password must be reset to use new (bcrypt) password hash.
350func 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
372func TestUserAuthenticateWithBadPasswordHash(t *testing.T) {

Callers

nothing calls this directly

Calls 9

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