(t *testing.T)
| 46 | } |
| 47 | |
| 48 | func TestSendRecordPasswordReset(t *testing.T) { |
| 49 | t.Parallel() |
| 50 | |
| 51 | testApp, _ := tests.NewTestApp() |
| 52 | defer testApp.Cleanup() |
| 53 | |
| 54 | user, _ := testApp.FindFirstRecordByData("users", "email", "test@example.com") |
| 55 | |
| 56 | // to test that it is escaped |
| 57 | user.Set("name", "<p>"+user.GetString("name")+"</p>") |
| 58 | |
| 59 | err := mails.SendRecordPasswordReset(testApp, user) |
| 60 | if err != nil { |
| 61 | t.Fatal(err) |
| 62 | } |
| 63 | |
| 64 | if testApp.TestMailer.TotalSend() != 1 { |
| 65 | t.Fatalf("Expected one email to be sent, got %d", testApp.TestMailer.TotalSend()) |
| 66 | } |
| 67 | |
| 68 | expectedParts := []string{ |
| 69 | html.EscapeString(user.GetString("name")) + "{RECORD:tokenKey}", // the record name as {RECORD:name} |
| 70 | "http://localhost:8090/_/#/auth/confirm-password-reset/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.", |
| 71 | } |
| 72 | for _, part := range expectedParts { |
| 73 | if !strings.Contains(testApp.TestMailer.LastMessage().HTML, part) { |
| 74 | t.Fatalf("Couldn't find %s \nin\n %s", part, testApp.TestMailer.LastMessage().HTML) |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | func TestSendRecordVerification(t *testing.T) { |
| 80 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…