diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2017-01-17 15:01:41 +0100 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-01-17 09:01:41 -0500 |
commit | dc54e640c296d50c51858fa50256b3aed9e0a46c (patch) | |
tree | b5b9dc2b044535570cb885307de366136c2b3419 /api/user_test.go | |
parent | 97a51b0e31692b7f86a9971ad36d62b04100fffb (diff) | |
download | chat-dc54e640c296d50c51858fa50256b3aed9e0a46c.tar.gz chat-dc54e640c296d50c51858fa50256b3aed9e0a46c.tar.bz2 chat-dc54e640c296d50c51858fa50256b3aed9e0a46c.zip |
Add inbucket docker image to allow local and automated testing of emails (#4901)
* add docker container for inbucket
* Add way to get the emails using inbucket and add a test for reset password
* add config setting to send emails
* update TestEmailTest
update
* add another test and fix wrong assert
* update per review
fix lint
change senders email
* Revert config.json to default values for EmailSettings section
* update test
* add setup to make the test run
Diffstat (limited to 'api/user_test.go')
-rw-r--r-- | api/user_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/api/user_test.go b/api/user_test.go index 3163de078..56064232b 100644 --- a/api/user_test.go +++ b/api/user_test.go @@ -1284,6 +1284,9 @@ func TestResetPassword(t *testing.T) { LinkUserToTeam(user, team) store.Must(app.Srv.Store.User().VerifyEmail(user.Id)) + //Delete all the messages before check the reset password + utils.DeleteMailBox(user.Email) + Client.Must(Client.SendPasswordReset(user.Email)) var recovery *model.PasswordRecovery @@ -1293,6 +1296,19 @@ func TestResetPassword(t *testing.T) { recovery = result.Data.(*model.PasswordRecovery) } + //Check if the email was send to the rigth email address and the recovery key match + if resultsMailbox, err := utils.GetMailBox(user.Email); err != nil && !strings.ContainsAny(resultsMailbox[0].To[0], user.Email) { + t.Fatal("Wrong To recipient") + } else { + if resultsEmail, err := utils.GetMessageFromMailbox(user.Email, resultsMailbox[0].ID); err == nil { + if !strings.Contains(resultsEmail.Body.Text, recovery.Code) { + t.Log(resultsEmail.Body.Text) + t.Log(recovery.Code) + t.Fatal("Received wrong recovery code") + } + } + } + if _, err := Client.ResetPassword(recovery.Code, ""); err == nil { t.Fatal("Should have errored - no password") } |