chore: add smtp config to live system
This commit is contained in:
parent
5b141459fa
commit
4818cf15d2
5 changed files with 20 additions and 6 deletions
5
main.go
5
main.go
|
@ -57,7 +57,10 @@ func setupRouter(cfg gloableConfig) *gin.Engine {
|
|||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("cant init userstore")
|
||||
}
|
||||
ma := miniauth.NewMiniauth(us)
|
||||
|
||||
sc := smtpclient.NewSMTPClient(cfg.SMTPConfig)
|
||||
|
||||
ma := miniauth.NewMiniauth(us, sc)
|
||||
|
||||
webServer := web.NewWeb(cfg.WebConfig, ma)
|
||||
webServer.RegisterRoutes(routesWeb)
|
||||
|
|
|
@ -18,9 +18,10 @@ type Miniauth struct {
|
|||
smtp smtpclient.SMTPClient
|
||||
}
|
||||
|
||||
func NewMiniauth(us userstore.Store) Miniauth {
|
||||
func NewMiniauth(us userstore.Store, sm smtpclient.SMTPClient) Miniauth {
|
||||
m := Miniauth{}
|
||||
m.store = us
|
||||
m.smtp = sm
|
||||
return m
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,8 @@ func TestInvalideUsernames(t *testing.T) {
|
|||
func getMiniAuth(t *testing.T) Miniauth {
|
||||
us, err := userstore.NewDummyStore()
|
||||
assert.Nil(t, err, "[setup] should be abel to creat dummy store")
|
||||
m := NewMiniauth(us)
|
||||
m.smtp = smtpclient.NewDummySMTPClient()
|
||||
|
||||
sc := smtpclient.NewDummySMTPClient()
|
||||
m := NewMiniauth(us, sc)
|
||||
return m
|
||||
}
|
||||
|
|
|
@ -60,6 +60,12 @@ func (s SMTPClient) SendMail(templateName string, to string, data any) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func NewSMTPClient(c SMTPConfig) SMTPClient {
|
||||
client := SMTPClient{}
|
||||
client.config = c
|
||||
return client
|
||||
}
|
||||
|
||||
func NewDummySMTPClient() SMTPClient {
|
||||
s := SMTPClient{}
|
||||
s.config.Server = "test"
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"git.keks.cloud/kekskurse/miniauth/pkg/miniauth"
|
||||
"git.keks.cloud/kekskurse/miniauth/pkg/smtpclient"
|
||||
"git.keks.cloud/kekskurse/miniauth/pkg/userstore"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -18,7 +19,8 @@ func TestRegistrationDisabled(t *testing.T) {
|
|||
|
||||
us, err := userstore.NewDummyStore()
|
||||
assert.Nil(t, err, "[setup] should be abel to create userstore")
|
||||
web := NewWeb(webConfig, miniauth.NewMiniauth(us))
|
||||
sc := smtpclient.NewDummySMTPClient()
|
||||
web := NewWeb(webConfig, miniauth.NewMiniauth(us, sc))
|
||||
|
||||
router := gin.New()
|
||||
loadTemplates(router)
|
||||
|
@ -40,7 +42,8 @@ func TestRegistrationDisabledOnPost(t *testing.T) {
|
|||
|
||||
us, err := userstore.NewDummyStore()
|
||||
assert.Nil(t, err, "[setup] should be abel to create userstore")
|
||||
web := NewWeb(webConfig, miniauth.NewMiniauth(us))
|
||||
sc := smtpclient.NewDummySMTPClient()
|
||||
web := NewWeb(webConfig, miniauth.NewMiniauth(us, sc))
|
||||
|
||||
router := gin.New()
|
||||
loadTemplates(router)
|
||||
|
|
Loading…
Add table
Reference in a new issue