Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
01a24542
Commit
01a24542
authored
Mar 01, 2016
by
Eric Chiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*: fix tests that care about email case sensitivity
parent
2a0cc474
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
12 deletions
+13
-12
user_repo_test.go
functional/repo/user_repo_test.go
+4
-2
email_verification.go
server/email_verification.go
+1
-1
invitation.go
server/invitation.go
+1
-1
password_test.go
server/password_test.go
+2
-2
manager.go
user/manager/manager.go
+4
-6
manager_test.go
user/manager/manager_test.go
+1
-0
No files found.
functional/repo/user_repo_test.go
View file @
01a24542
...
...
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"reflect"
"strings"
"testing"
"time"
...
...
@@ -220,6 +221,7 @@ func TestUpdateUser(t *testing.T) {
t
.
Errorf
(
"case %d: want nil err, got %q"
,
i
,
err
)
}
tt
.
user
.
Email
=
strings
.
ToLower
(
tt
.
user
.
Email
)
if
diff
:=
pretty
.
Compare
(
tt
.
user
,
gotUser
);
diff
!=
""
{
t
.
Errorf
(
"case %d: Compare(want, got) = %v"
,
i
,
diff
)
...
...
@@ -436,12 +438,12 @@ func TestGetByEmail(t *testing.T) {
}{
{
email
:
"Email-1@example.com"
,
wantEmail
:
"
E
mail-1@example.com"
,
wantEmail
:
"
e
mail-1@example.com"
,
wantErr
:
nil
,
},
{
email
:
"EMAIL-1@example.com"
,
// Emails should be case insensitive.
wantEmail
:
"
E
mail-1@example.com"
,
wantEmail
:
"
e
mail-1@example.com"
,
wantErr
:
nil
,
},
{
...
...
server/email_verification.go
View file @
01a24542
...
...
@@ -223,7 +223,7 @@ func handleEmailVerifyFunc(verifiedTpl *template.Template, issuer url.URL, keysF
Error
:
"Invalid Verification Link"
,
Message
:
"Your email link has expired or has already been verified."
,
},
http
.
StatusBadRequest
)
case
manager
.
ErrorEVEmailDoesntMatch
:
case
user
.
ErrorNotFound
:
execTemplateWithStatus
(
w
,
verifiedTpl
,
emailVerifiedTemplateData
{
Error
:
"Invalid Verification Link"
,
Message
:
"Your email link does not match the email address on file. Perhaps you have a more recent verification link?"
,
...
...
server/invitation.go
View file @
01a24542
...
...
@@ -62,7 +62,7 @@ func (h *InvitationHandler) handleGET(w http.ResponseWriter, r *http.Request) {
// never be able to set their passwords.
log
.
Debugf
(
"error attempting to verify email: %v"
,
err
)
switch
err
{
case
manager
.
ErrorEVEmailDoesntMatch
:
case
user
.
ErrorNotFound
:
writeAPIError
(
w
,
http
.
StatusBadRequest
,
newAPIError
(
errorInvalidRequest
,
"Your email does not match the email address on file"
))
return
...
...
server/password_test.go
View file @
01a24542
...
...
@@ -100,7 +100,7 @@ func TestSendResetPasswordEmailHandler(t *testing.T) {
wantCode
:
http
.
StatusOK
,
wantEmailer
:
&
testEmailer
{
to
:
str
(
"
E
mail-1@example.com"
),
to
:
str
(
"
e
mail-1@example.com"
),
from
:
"noreply@example.com"
,
subject
:
"Reset Your Password"
,
},
...
...
@@ -136,7 +136,7 @@ func TestSendResetPasswordEmailHandler(t *testing.T) {
wantCode
:
http
.
StatusOK
,
wantEmailer
:
&
testEmailer
{
to
:
str
(
"
E
mail-1@example.com"
),
to
:
str
(
"
e
mail-1@example.com"
),
from
:
"noreply@example.com"
,
subject
:
"Reset Your Password"
,
},
...
...
user/manager/manager.go
View file @
01a24542
...
...
@@ -13,9 +13,7 @@ import (
)
var
(
ErrorEVEmailDoesntMatch
=
errors
.
New
(
"email in EV doesn't match user email"
)
ErrorEmailAlreadyVerified
=
errors
.
New
(
"email already verified"
)
ErrorEmailAlreadyVerified
=
errors
.
New
(
"email already verified"
)
ErrorPasswordAlreadyChanged
=
errors
.
New
(
"password has already been changed"
)
)
...
...
@@ -228,15 +226,15 @@ func (m *UserManager) VerifyEmail(ev EmailVerifiable) (*url.URL, error) {
return
nil
,
err
}
usr
,
err
:=
m
.
userRepo
.
Get
(
tx
,
ev
.
UserID
())
usr
,
err
:=
m
.
userRepo
.
Get
ByEmail
(
tx
,
ev
.
Email
())
if
err
!=
nil
{
rollback
(
tx
)
return
nil
,
err
}
if
usr
.
Email
!=
ev
.
Email
()
{
if
usr
.
ID
!=
ev
.
UserID
()
{
rollback
(
tx
)
return
nil
,
ErrorEVEmailDoesntMatch
return
nil
,
user
.
ErrorNotFound
}
if
usr
.
EmailVerified
{
...
...
user/manager/manager_test.go
View file @
01a24542
...
...
@@ -311,6 +311,7 @@ func TestVerifyEmail(t *testing.T) {
if
err
!=
nil
{
t
.
Errorf
(
"case %d: want err=nil got=%q"
,
i
,
err
)
continue
}
if
cb
.
String
()
!=
tt
.
evClaims
[
user
.
ClaimEmailVerificationCallback
]
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment