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

Function TestUserAuthenticateWithBadPasswordHash

auth/user_test.go:372–391  ·  view source on GitHub ↗

Must not authenticate with bad password hash

(t *testing.T)

Source from the content-addressed store, hash-verified

370
371// Must not authenticate with bad password hash
372func TestUserAuthenticateWithBadPasswordHash(t *testing.T) {
373 base.SetUpTestLogging(t, base.LevelDebug, base.KeyAuth)
374 const (
375 username = "alice"
376 password = "hunter2"
377 )
378 ctx := base.TestCtx(t)
379 testBucket := base.GetTestBucket(t)
380 defer testBucket.Close(ctx)
381 dataStore := testBucket.GetSingleDataStore()
382 auth := NewTestAuthenticator(t, dataStore, nil, DefaultAuthenticatorOptions(ctx))
383
384 user, err := auth.NewUser(username, password, base.Set{})
385 assert.NoError(t, err)
386 assert.NotNil(t, user)
387
388 err = user.SetPassword("hunter3")
389 require.NoError(t, err)
390 assert.False(t, user.Authenticate(password))
391}
392
393// Must not authenticate if No hash, but (incorrect) password provided.
394func TestUserAuthenticateWithNoHashAndBadPassword(t *testing.T) {

Callers

nothing calls this directly

Calls 10

SetPasswordMethod · 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