2026-05-20 07:01:08 +00:00
|
|
|
package usecase
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
notifconfig "gateway/internal/model/notification/config"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestBuildEmailChain_MockByDefault(t *testing.T) {
|
|
|
|
|
chain, err := buildEmailChain(notifconfig.Config{
|
|
|
|
|
Email: notifconfig.EmailConfig{Provider: notifconfig.ProviderMock},
|
2026-05-26 06:05:33 +00:00
|
|
|
}, nil)
|
2026-05-20 07:01:08 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.NotNil(t, chain)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBuildEmailChain_SMTPAndSES(t *testing.T) {
|
|
|
|
|
chain, err := buildEmailChain(notifconfig.Config{
|
|
|
|
|
Email: notifconfig.EmailConfig{
|
|
|
|
|
SMTP: notifconfig.SMTPProviderSettings{
|
|
|
|
|
Enable: true,
|
|
|
|
|
Sort: 1,
|
|
|
|
|
Host: "smtp.example.com",
|
|
|
|
|
Port: 587,
|
|
|
|
|
},
|
|
|
|
|
SES: notifconfig.SESProviderSettings{
|
|
|
|
|
Enable: true,
|
|
|
|
|
Sort: 2,
|
|
|
|
|
Region: "ap-northeast-1",
|
|
|
|
|
AccessKey: "key",
|
|
|
|
|
SecretKey: "secret",
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-05-26 06:05:33 +00:00
|
|
|
}, nil)
|
2026-05-20 07:01:08 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.NotNil(t, chain)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBuildEmailChain_SESRequiresCredentials(t *testing.T) {
|
|
|
|
|
_, err := buildEmailChain(notifconfig.Config{
|
|
|
|
|
Email: notifconfig.EmailConfig{
|
|
|
|
|
SES: notifconfig.SESProviderSettings{Enable: true, Region: "ap-northeast-1"},
|
|
|
|
|
},
|
2026-05-26 06:05:33 +00:00
|
|
|
}, nil)
|
2026-05-20 07:01:08 +00:00
|
|
|
assert.Error(t, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBuildSMSChain_Mitake(t *testing.T) {
|
|
|
|
|
chain, err := buildSMSChain(notifconfig.Config{
|
|
|
|
|
SMS: notifconfig.SMSConfig{
|
|
|
|
|
Mitake: notifconfig.MitakeProviderSettings{
|
|
|
|
|
Enable: true,
|
|
|
|
|
Sort: 1,
|
|
|
|
|
User: "user",
|
|
|
|
|
Password: "pass",
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-05-26 06:05:33 +00:00
|
|
|
}, nil)
|
2026-05-20 07:01:08 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.NotNil(t, chain)
|
|
|
|
|
}
|