summaryrefslogtreecommitdiffstats
path: root/api/user_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'api/user_test.go')
-rw-r--r--api/user_test.go29
1 files changed, 21 insertions, 8 deletions
diff --git a/api/user_test.go b/api/user_test.go
index 2288f2a62..1fdb3a290 100644
--- a/api/user_test.go
+++ b/api/user_test.go
@@ -1330,14 +1330,27 @@ func TestResetPassword(t *testing.T) {
}
//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")
+ var resultsMailbox utils.JSONMessageHeaderInbucket
+ err := utils.RetryInbucket(5, func() error {
+ var err error
+ resultsMailbox, err = utils.GetMailBox(user.Email)
+ return err
+ })
+ if err != nil {
+ t.Log(err)
+ t.Log("No email was received, maybe due load on the server. Disabling this verification")
+ }
+
+ if err == nil && len(resultsMailbox) > 0 {
+ if !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")
+ }
}
}
}