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
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
97a51b0e31
Коммит
dc54e640c2
@@ -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")
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user