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

Function TestValidateUserEmail

auth/auth_test.go:105–126  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

103}
104
105func TestValidateUserEmail(t *testing.T) {
106
107 ctx := base.TestCtx(t)
108 bucket := base.GetTestBucket(t)
109 defer bucket.Close(ctx)
110
111 dataStore := bucket.GetSingleDataStore()
112
113 auth := NewTestAuthenticator(t, dataStore, nil, DefaultAuthenticatorOptions(ctx))
114 badEmails := []string{"", "foo", "foo@", "@bar", "foo@bar@buzz"}
115 for _, e := range badEmails {
116 assert.False(t, IsValidEmail(e), "Shouldn't validate as email: %q", e)
117 }
118 goodEmails := []string{"foo@bar", "foo.99@bar.com", "f@bar.exampl-3.com."}
119 for _, e := range goodEmails {
120 assert.True(t, IsValidEmail(e), "Should validate as email: %q", e)
121 }
122 user, err := auth.NewUser("ValidName", "letmein", nil)
123 require.NoError(t, err)
124 require.Error(t, user.SetEmail("foo"))
125 require.NoError(t, user.SetEmail("foo@example.com"))
126}
127
128func TestUserPasswords(t *testing.T) {
129 ctx := base.TestCtx(t)

Callers

nothing calls this directly

Calls 10

SetEmailMethod · 0.95
TestCtxFunction · 0.92
GetTestBucketFunction · 0.92
NewTestAuthenticatorFunction · 0.85
IsValidEmailFunction · 0.85
NewUserMethod · 0.80
CloseMethod · 0.65
GetSingleDataStoreMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected