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

Function TestUserAuthenticateWithNoHashAndBadPassword

auth/user_test.go:394–412  ·  view source on GitHub ↗

Must not authenticate if No hash, but (incorrect) password provided.

(t *testing.T)

Source from the content-addressed store, hash-verified

392
393// Must not authenticate if No hash, but (incorrect) password provided.
394func TestUserAuthenticateWithNoHashAndBadPassword(t *testing.T) {
395 base.SetUpTestLogging(t, base.LevelDebug, base.KeyAuth)
396 const (
397 username = "alice"
398 password = "hunter2"
399 )
400 ctx := base.TestCtx(t)
401 testBucket := base.GetTestBucket(t)
402 defer testBucket.Close(ctx)
403 dataStore := testBucket.GetSingleDataStore()
404 auth := NewTestAuthenticator(t, dataStore, nil, DefaultAuthenticatorOptions(ctx))
405
406 user, err := auth.NewUser(username, password, base.Set{})
407 assert.NoError(t, err)
408 assert.NotNil(t, user)
409
410 user.(*userImpl).OldPasswordHash_ = nil
411 assert.False(t, user.Authenticate("hunter3"))
412}
413
414func TestUserKeysHash(t *testing.T) {
415 for _, metadataDefault := range []bool{false, true} {

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