-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_reset_success_test.go
More file actions
47 lines (36 loc) · 1.26 KB
/
Copy pathpassword_reset_success_test.go
File metadata and controls
47 lines (36 loc) · 1.26 KB
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
// Copyright (c) Kopexa GmbH
// SPDX-License-Identifier: BUSL-1.1
package comms
import (
"context"
"testing"
"github.com/kopexa-grc/comms/v2/driver/mock"
"github.com/stretchr/testify/require"
)
func TestComms_SendPasswordResetSuccessEmail(t *testing.T) {
recipient := Recipient{
Email: "test@example.com",
FirstName: "Max",
LastName: "Mustermann",
}
comms := New(WithDriver(mock.NewDriver()))
err := comms.SendPasswordResetSuccessEmail(context.Background(), recipient)
require.NoError(t, err)
msg, ok := comms.config.Driver.(*mock.Driver).LastMessage()
require.True(t, ok)
require.NotNil(t, msg)
require.Equal(t, "Your password has been successfully reset", msg.Subject)
require.Equal(t, []string{recipient.String()}, msg.To)
require.NotEmpty(t, msg.Text)
require.Contains(t, msg.Text, recipient.Name())
require.NotEmpty(t, msg.HTML)
require.Contains(t, msg.HTML, recipient.Name())
require.Contains(t, msg.HTML, "<!DOCTYPE html PUBLIC")
}
func TestComms_SendPasswordResetSuccessEmail_InvalidRecipient(t *testing.T) {
recipient := Recipient{Email: ""}
comms := New(WithDriver(mock.NewDriver()))
err := comms.SendPasswordResetSuccessEmail(context.Background(), recipient)
require.Error(t, err)
require.Contains(t, err.Error(), "invalid recipient")
}