-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix:fixing special character issue on email addresses
- Loading branch information
1 parent
e6f5f3d
commit 18b70eb
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,6 +136,38 @@ func TestSend(t *testing.T) { | |
testhelpers.Contains(tt, string(m.Bodies[0].Content), "http://127.0.0.1:8080/auth/validate") | ||
}) | ||
|
||
t.Run("User found email encoded", func(tt *testing.T) { | ||
email := "[email protected]" | ||
finder := func(token string) (maildoor.Emailable, error) { | ||
return testUser(email), nil | ||
} | ||
var m maildoor.Message | ||
sender := func(message *maildoor.Message) error { | ||
m = *message | ||
return nil | ||
} | ||
|
||
h, err := maildoor.NewWithOptions("secret", maildoor.UseFinder(finder), maildoor.UseSender(sender)) | ||
testhelpers.NoError(t, err) | ||
|
||
token, err := maildoor.GenerateJWT(time.Second*10, []byte("secret")) | ||
testhelpers.NoError(t, err) | ||
|
||
req := httptest.NewRequest(http.MethodPost, "/auth/send/", nil) | ||
req.Form = url.Values{ | ||
"CSRFToken": []string{token}, | ||
"email": []string{email}, | ||
} | ||
|
||
w := httptest.NewRecorder() | ||
|
||
h.ServeHTTP(w, req) | ||
testhelpers.Equals(tt, http.StatusOK, w.Code) | ||
testhelpers.Equals(tt, "[email protected]", m.To) | ||
testhelpers.Contains(tt, string(m.Bodies[0].Content), "http://127.0.0.1:8080/auth/validate") | ||
testhelpers.Contains(tt, string(m.Bodies[0].Content), fmt.Sprintf("email=%v", url.QueryEscape(email))) | ||
}) | ||
|
||
t.Run("User found error sending", func(tt *testing.T) { | ||
finder := func(token string) (maildoor.Emailable, error) { | ||
return testUser("[email protected]"), nil | ||
|