feat: mail service
This commit is contained in:
@@ -69,12 +69,13 @@ func TestInMemoryChallengeStoreCompareAndSwapConflict(t *testing.T) {
|
||||
func challengeFixture() challenge.Challenge {
|
||||
timestamp := time.Unix(20, 0).UTC()
|
||||
return challenge.Challenge{
|
||||
ID: common.ChallengeID("challenge-1"),
|
||||
Email: common.Email("pilot@example.com"),
|
||||
CodeHash: []byte("hash"),
|
||||
Status: challenge.StatusPendingSend,
|
||||
DeliveryState: challenge.DeliveryPending,
|
||||
CreatedAt: timestamp,
|
||||
ExpiresAt: timestamp.Add(10 * time.Minute),
|
||||
ID: common.ChallengeID("challenge-1"),
|
||||
Email: common.Email("pilot@example.com"),
|
||||
CodeHash: []byte("hash"),
|
||||
PreferredLanguage: "en",
|
||||
Status: challenge.StatusPendingSend,
|
||||
DeliveryState: challenge.DeliveryPending,
|
||||
CreatedAt: timestamp,
|
||||
ExpiresAt: timestamp.Add(10 * time.Minute),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ import (
|
||||
)
|
||||
|
||||
// RecordingMailSender is a deterministic MailSender double that records every
|
||||
// delivery request and returns preconfigured outcomes or errors.
|
||||
// delivery request, including the auth challenge-derived idempotency key, and
|
||||
// returns preconfigured outcomes or errors.
|
||||
type RecordingMailSender struct {
|
||||
mu sync.Mutex
|
||||
|
||||
|
||||
@@ -97,8 +97,10 @@ func TestRecordingMailSender(t *testing.T) {
|
||||
}
|
||||
|
||||
result, err := sender.SendLoginCode(context.Background(), ports.SendLoginCodeInput{
|
||||
Email: common.Email("pilot@example.com"),
|
||||
Code: "654321",
|
||||
Email: common.Email("pilot@example.com"),
|
||||
IdempotencyKey: "challenge-1",
|
||||
Code: "654321",
|
||||
Locale: "en",
|
||||
})
|
||||
if err != nil {
|
||||
require.Failf(t, "test failed", "SendLoginCode() returned error: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user