summaryrefslogtreecommitdiffstats
path: root/app/email_test.go
blob: 3f57c54f98ac11b992bca2a75b58022a4753ca69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

package app

import (
	"strings"
	"testing"

	"github.com/mattermost/platform/model"
	"github.com/mattermost/platform/utils"
)

func TestSendChangeUsernameEmail(t *testing.T) {
	Setup()

	var emailTo string = "test@example.com"
	var oldUsername string = "myoldusername"
	var newUsername string = "fancyusername"
	var locale string = "en"
	var siteURL string = ""
	var expectedPartialMessage string = "Your username for " + utils.Cfg.TeamSettings.SiteName + " has been changed to " + newUsername + "."
	var expectedSubject string = "[" + utils.Cfg.TeamSettings.SiteName + "] Your username has changed"

	//Delete all the messages before check the sample email
	utils.DeleteMailBox(emailTo)

	if err := SendChangeUsernameEmail(oldUsername, newUsername, emailTo, locale, siteURL); err != nil {
		t.Log(err)
		t.Fatal("Should send change username email")
	} else {
		//Check if the email was send to the rigth email address
		var resultsMailbox utils.JSONMessageHeaderInbucket
		err := utils.RetryInbucket(5, func() error {
			var err error
			resultsMailbox, err = utils.GetMailBox(emailTo)
			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], emailTo) {
				t.Fatal("Wrong To recipient")
			} else {
				if resultsEmail, err := utils.GetMessageFromMailbox(emailTo, resultsMailbox[0].ID); err == nil {
					if resultsEmail.Subject != expectedSubject {
						t.Log(resultsEmail.Subject)
						t.Fatal("Wrong Subject")
					}
					if !strings.Contains(resultsEmail.Body.Text, expectedPartialMessage) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong Body message")
					}
				}
			}
		}
	}
}

func TestSendEmailChangeVerifyEmail(t *testing.T) {
	Setup()

	var userId string = "5349853498543jdfvndf9834"
	var newUserEmail string = "newtest@example.com"
	var locale string = "en"
	var siteURL string = ""
	var expectedPartialMessage string = "You updated your email"
	var expectedSubject string = "[" + utils.Cfg.TeamSettings.SiteName + "] Verify new email address"

	//Delete all the messages before check the sample email
	utils.DeleteMailBox(newUserEmail)

	if err := SendEmailChangeVerifyEmail(userId, newUserEmail, locale, siteURL); err != nil {
		t.Log(err)
		t.Fatal("Should send change username email")
	} else {
		//Check if the email was send to the rigth email address
		var resultsMailbox utils.JSONMessageHeaderInbucket
		err := utils.RetryInbucket(5, func() error {
			var err error
			resultsMailbox, err = utils.GetMailBox(newUserEmail)
			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], newUserEmail) {
				t.Fatal("Wrong To recipient")
			} else {
				if resultsEmail, err := utils.GetMessageFromMailbox(newUserEmail, resultsMailbox[0].ID); err == nil {
					if resultsEmail.Subject != expectedSubject {
						t.Log(resultsEmail.Subject)
						t.Fatal("Wrong Subject")
					}
					if !strings.Contains(resultsEmail.Body.Text, expectedPartialMessage) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong Body message")
					}
					if !strings.Contains(resultsEmail.Body.Text, utils.UrlEncode(newUserEmail)) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong new email in the message")
					}
				}
			}
		}
	}
}

func TestSendEmailChangeEmail(t *testing.T) {
	Setup()

	var oldEmail string = "test@example.com"
	var newUserEmail string = "newtest@example.com"
	var locale string = "en"
	var siteURL string = ""
	var expectedPartialMessage string = "Your email address for Mattermost has been changed to " + newUserEmail
	var expectedSubject string = "[" + utils.Cfg.TeamSettings.SiteName + "] Your email address has changed"

	//Delete all the messages before check the sample email
	utils.DeleteMailBox(oldEmail)

	if err := SendEmailChangeEmail(oldEmail, newUserEmail, locale, siteURL); err != nil {
		t.Log(err)
		t.Fatal("Should send change username email")
	} else {
		//Check if the email was send to the rigth email address
		var resultsMailbox utils.JSONMessageHeaderInbucket
		err := utils.RetryInbucket(5, func() error {
			var err error
			resultsMailbox, err = utils.GetMailBox(oldEmail)
			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], oldEmail) {
				t.Fatal("Wrong To recipient")
			} else {
				if resultsEmail, err := utils.GetMessageFromMailbox(oldEmail, resultsMailbox[0].ID); err == nil {
					if resultsEmail.Subject != expectedSubject {
						t.Log(resultsEmail.Subject)
						t.Fatal("Wrong Subject")
					}
					if !strings.Contains(resultsEmail.Body.Text, expectedPartialMessage) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong Body message")
					}
				}
			}
		}
	}
}

func TestSendVerifyEmail(t *testing.T) {
	Setup()

	var userId string = "5349853498543jdfvndf9834"
	var userEmail string = "test@example.com"
	var locale string = "en"
	var siteURL string = ""
	var expectedPartialMessage string = "Please verify your email address by clicking below"
	var expectedSubject string = "[" + utils.Cfg.TeamSettings.SiteName + "] Email Verification"

	//Delete all the messages before check the sample email
	utils.DeleteMailBox(userEmail)

	if err := SendVerifyEmail(userId, userEmail, locale, siteURL); err != nil {
		t.Log(err)
		t.Fatal("Should send change username email")
	} else {
		//Check if the email was send to the rigth email address
		var resultsMailbox utils.JSONMessageHeaderInbucket
		err := utils.RetryInbucket(5, func() error {
			var err error
			resultsMailbox, err = utils.GetMailBox(userEmail)
			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], userEmail) {
				t.Fatal("Wrong To recipient")
			} else {
				if resultsEmail, err := utils.GetMessageFromMailbox(userEmail, resultsMailbox[0].ID); err == nil {
					if resultsEmail.Subject != expectedSubject {
						t.Log(resultsEmail.Subject)
						t.Fatal("Wrong Subject")
					}
					if !strings.Contains(resultsEmail.Body.Text, expectedPartialMessage) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong Body message")
					}
					if !strings.Contains(resultsEmail.Body.Text, utils.UrlEncode(userEmail)) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong new email in the message")
					}
				}
			}
		}
	}
}

func TestSendSignInChangeEmail(t *testing.T) {
	Setup()

	var email string = "test@example.com"
	var locale string = "en"
	var siteURL string = ""
	var method string = "AD/LDAP"
	var expectedPartialMessage string = "You updated your sign-in method on Mattermost to " + method + "."
	var expectedSubject string = "[" + utils.Cfg.TeamSettings.SiteName + "] You updated your sign-in method on " + utils.Cfg.TeamSettings.SiteName

	//Delete all the messages before check the sample email
	utils.DeleteMailBox(email)

	if err := SendSignInChangeEmail(email, method, locale, siteURL); err != nil {
		t.Log(err)
		t.Fatal("Should send change username email")
	} else {
		//Check if the email was send to the rigth email address
		var resultsMailbox utils.JSONMessageHeaderInbucket
		err := utils.RetryInbucket(5, func() error {
			var err error
			resultsMailbox, err = utils.GetMailBox(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], email) {
				t.Fatal("Wrong To recipient")
			} else {
				if resultsEmail, err := utils.GetMessageFromMailbox(email, resultsMailbox[0].ID); err == nil {
					if resultsEmail.Subject != expectedSubject {
						t.Log(resultsEmail.Subject)
						t.Fatal("Wrong Subject")
					}
					if !strings.Contains(resultsEmail.Body.Text, expectedPartialMessage) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong Body message")
					}
				}
			}
		}
	}
}

func TestSendWelcomeEmail(t *testing.T) {
	Setup()

	var userId string = "32432nkjnijn432uj32"
	var email string = "test@example.com"
	var locale string = "en"
	var siteURL string = "http://test.mattermost.io"
	var verified bool = true
	var expectedPartialMessage string = "Mattermost lets you share messages and files from your PC or phone, with instant search and archiving"
	var expectedSubject string = "[" + utils.Cfg.TeamSettings.SiteName + "] You joined test.mattermost.io"

	//Delete all the messages before check the sample email
	utils.DeleteMailBox(email)

	if err := SendWelcomeEmail(userId, email, verified, locale, siteURL); err != nil {
		t.Log(err)
		t.Fatal("Should send change username email")
	} else {
		//Check if the email was send to the rigth email address
		var resultsMailbox utils.JSONMessageHeaderInbucket
		err := utils.RetryInbucket(5, func() error {
			var err error
			resultsMailbox, err = utils.GetMailBox(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], email) {
				t.Fatal("Wrong To recipient")
			} else {
				if resultsEmail, err := utils.GetMessageFromMailbox(email, resultsMailbox[0].ID); err == nil {
					if resultsEmail.Subject != expectedSubject {
						t.Log(resultsEmail.Subject)
						t.Fatal("Wrong Subject")
					}
					if !strings.Contains(resultsEmail.Body.Text, expectedPartialMessage) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong Body message")
					}
				}
			}
		}
	}

	utils.DeleteMailBox(email)
	verified = false
	var expectedVerifyEmail string = "Please verify your email address by clicking below."

	if err := SendWelcomeEmail(userId, email, verified, locale, siteURL); err != nil {
		t.Log(err)
		t.Fatal("Should send change username email")
	} else {
		//Check if the email was send to the rigth email address
		var resultsMailbox utils.JSONMessageHeaderInbucket
		err := utils.RetryInbucket(5, func() error {
			var err error
			resultsMailbox, err = utils.GetMailBox(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], email) {
				t.Fatal("Wrong To recipient")
			} else {
				if resultsEmail, err := utils.GetMessageFromMailbox(email, resultsMailbox[0].ID); err == nil {
					if !strings.Contains(resultsEmail.Subject, expectedSubject) {
						t.Log(resultsEmail.Subject)
						t.Fatal("Wrong Subject")
					}
					if !strings.Contains(resultsEmail.Body.Text, expectedPartialMessage) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong Body message")
					}
					if !strings.Contains(resultsEmail.Body.Text, expectedVerifyEmail) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong Body message")
					}
					if !strings.Contains(resultsEmail.Body.Text, utils.UrlEncode(email)) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong email in the message")
					}
				}
			}
		}
	}
}

func TestSendPasswordChangeEmail(t *testing.T) {
	Setup()

	var email string = "test@example.com"
	var locale string = "en"
	var siteURL string = "http://test.mattermost.io"
	var method string = "using a reset password link"
	var expectedPartialMessage string = "Your password has been updated for " + utils.Cfg.TeamSettings.SiteName + " on " + siteURL + " by " + method
	var expectedSubject string = "[" + utils.Cfg.TeamSettings.SiteName + "] Your password has been updated"

	//Delete all the messages before check the sample email
	utils.DeleteMailBox(email)

	if err := SendPasswordChangeEmail(email, method, locale, siteURL); err != nil {
		t.Log(err)
		t.Fatal("Should send change username email")
	} else {
		//Check if the email was send to the rigth email address
		var resultsMailbox utils.JSONMessageHeaderInbucket
		err := utils.RetryInbucket(5, func() error {
			var err error
			resultsMailbox, err = utils.GetMailBox(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], email) {
				t.Fatal("Wrong To recipient")
			} else {
				if resultsEmail, err := utils.GetMessageFromMailbox(email, resultsMailbox[0].ID); err == nil {
					if resultsEmail.Subject != expectedSubject {
						t.Log(resultsEmail.Subject)
						t.Fatal("Wrong Subject")
					}
					if !strings.Contains(resultsEmail.Body.Text, expectedPartialMessage) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong Body message")
					}
				}
			}
		}
	}
}

func TestSendMfaChangeEmail(t *testing.T) {
	Setup()

	var email string = "test@example.com"
	var locale string = "en"
	var siteURL string = "http://test.mattermost.io"
	var activated bool = true
	var expectedPartialMessage string = "Multi-factor authentication has been added to your account on " + siteURL + "."
	var expectedSubject string = "[" + utils.Cfg.TeamSettings.SiteName + "] Your MFA has been updated"

	//Delete all the messages before check the sample email
	utils.DeleteMailBox(email)

	if err := SendMfaChangeEmail(email, activated, locale, siteURL); err != nil {
		t.Log(err)
		t.Fatal("Should send change username email")
	} else {
		//Check if the email was send to the rigth email address
		var resultsMailbox utils.JSONMessageHeaderInbucket
		err := utils.RetryInbucket(5, func() error {
			var err error
			resultsMailbox, err = utils.GetMailBox(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], email) {
				t.Fatal("Wrong To recipient")
			} else {
				if resultsEmail, err := utils.GetMessageFromMailbox(email, resultsMailbox[0].ID); err == nil {
					if resultsEmail.Subject != expectedSubject {
						t.Log(resultsEmail.Subject)
						t.Fatal("Wrong Subject")
					}
					if !strings.Contains(resultsEmail.Body.Text, expectedPartialMessage) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong Body message")
					}
				}
			}
		}
	}

	activated = false
	expectedPartialMessage = "Multi-factor authentication has been removed from your account on " + siteURL + "."
	utils.DeleteMailBox(email)

	if err := SendMfaChangeEmail(email, activated, locale, siteURL); err != nil {
		t.Log(err)
		t.Fatal("Should send change username email")
	} else {
		//Check if the email was send to the rigth email address
		var resultsMailbox utils.JSONMessageHeaderInbucket
		err := utils.RetryInbucket(5, func() error {
			var err error
			resultsMailbox, err = utils.GetMailBox(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], email) {
				t.Fatal("Wrong To recipient")
			} else {
				if resultsEmail, err := utils.GetMessageFromMailbox(email, resultsMailbox[0].ID); err == nil {
					if !strings.Contains(resultsEmail.Subject, expectedSubject) {
						t.Log(resultsEmail.Subject)
						t.Fatal("Wrong Subject")
					}
					if !strings.Contains(resultsEmail.Body.Text, expectedPartialMessage) {
						t.Log(resultsEmail.Body.Text)
						t.Fatal("Wrong Body message")
					}
				}
			}
		}
	}
}

func TestSendInviteEmails(t *testing.T) {
	th := Setup().InitBasic()

	var email1 string = "test1@example.com"
	var email2 string = "test2@example.com"
	var senderName string = "TheBoss"
	var siteURL string = "http://test.mattermost.io"
	invites := []string{email1, email2}
	var expectedPartialMessage string = "The team member *" + senderName + "* , has invited you to join *" + th.BasicTeam.DisplayName + "*"
	var expectedSubject string = "[" + utils.Cfg.TeamSettings.SiteName + "] " + senderName + " invited you to join " + th.BasicTeam.DisplayName + " Team"

	//Delete all the messages before check the sample email
	utils.DeleteMailBox(email1)
	utils.DeleteMailBox(email2)

	SendInviteEmails(th.BasicTeam, senderName, invites, siteURL)

	//Check if the email was send to the rigth email address to email1
	var resultsMailbox utils.JSONMessageHeaderInbucket
	err := utils.RetryInbucket(5, func() error {
		var err error
		resultsMailbox, err = utils.GetMailBox(email1)
		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], email1) {
			t.Fatal("Wrong To recipient")
		} else {
			if resultsEmail, err := utils.GetMessageFromMailbox(email1, resultsMailbox[0].ID); err == nil {
				if resultsEmail.Subject != expectedSubject {
					t.Log(resultsEmail.Subject)
					t.Log(expectedSubject)
					t.Fatal("Wrong Subject")
				}
				if !strings.Contains(resultsEmail.Body.Text, expectedPartialMessage) {
					t.Log(resultsEmail.Body.Text)
					t.Fatal("Wrong Body message")
				}
			}
		}
	}

	//Check if the email was send to the rigth email address to email2
	err = utils.RetryInbucket(5, func() error {
		var err error
		resultsMailbox, err = utils.GetMailBox(email2)
		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], email2) {
			t.Fatal("Wrong To recipient")
		} else {
			if resultsEmail, err := utils.GetMessageFromMailbox(email2, resultsMailbox[0].ID); err == nil {
				if !strings.Contains(resultsEmail.Subject, expectedSubject) {
					t.Log(resultsEmail.Subject)
					t.Log(expectedSubject)
					t.Fatal("Wrong Subject")
				}
				if !strings.Contains(resultsEmail.Body.Text, expectedPartialMessage) {
					t.Log(resultsEmail.Body.Text)
					t.Fatal("Wrong Body message")
				}
			}
		}
	}
}

func TestSendPasswordReset(t *testing.T) {
	th := Setup().InitBasic()

	var siteURL string = "http://test.mattermost.io"
	// var locale string = "en"
	var expectedPartialMessage string = "To change your password"
	var expectedSubject string = "[" + utils.Cfg.TeamSettings.SiteName + "] Reset your password"

	//Delete all the messages before check the sample email
	utils.DeleteMailBox(th.BasicUser.Email)

	if _, err := SendPasswordReset(th.BasicUser.Email, siteURL); err != nil {
		t.Log(err)
		t.Fatal("Should send change username email")
	} else {
		//Check if the email was send to the rigth email address
		if resultsMailbox, err := utils.GetMailBox(th.BasicUser.Email); err != nil && !strings.ContainsAny(resultsMailbox[0].To[0], th.BasicUser.Email) {
			t.Fatal("Wrong To recipient")
		} else {
			if resultsEmail, err := utils.GetMessageFromMailbox(th.BasicUser.Email, resultsMailbox[0].ID); err == nil {
				if resultsEmail.Subject != expectedSubject {
					t.Log(resultsEmail.Subject)
					t.Fatal("Wrong Subject")
				}
				if !strings.Contains(resultsEmail.Body.Text, expectedPartialMessage) {
					t.Log(resultsEmail.Body.Text)
					t.Fatal("Wrong Body message")
				}
				var recoveryKey *model.PasswordRecovery
				if result := <-Srv.Store.PasswordRecovery().Get(th.BasicUser.Id); result.Err != nil {
					t.Fatal(result.Err)
				} else {
					recoveryKey = result.Data.(*model.PasswordRecovery)
					if !strings.Contains(resultsEmail.Body.Text, recoveryKey.Code) {
						t.Log(resultsEmail.Body.Text)
						t.Log(recoveryKey.Code)
						t.Fatal("Received wrong recovery code")
					}
				}
			}
		}
	}
}