Skip to content

Commit e704a56

Browse files
bug: fix unit tests
1 parent 31b0f7a commit e704a56

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

services/mail/smtp_test.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ import (
2828
)
2929

3030
const (
31-
TestSmtpUser = "admin"
32-
TestSmtpPass = "admin"
33-
Smtp4DevApiUrl = "http://localhost:8080/api"
34-
Smtp4DevHost = "localhost"
35-
Smtp4DevPort = 2525
31+
TestSmtpUser = "admin"
32+
TestSmtpPass = "admin"
33+
Smtp4DevApiUrl = "http://localhost:8080/api"
34+
Smtp4DevHost = "localhost"
35+
Smtp4DevPort = 2525
36+
Smtp4DevTlsPort = 2465
3637
)
3738

3839
type SmtpTestSuite struct {
@@ -89,6 +90,7 @@ func (suite *SmtpTestSuite) TestSMTPSendingService_SendTLS() {
8990
}
9091

9192
cfg := createDefaultSMTPConfig()
93+
cfg.Port = Smtp4DevTlsPort
9294
cfg.TLS = true
9395

9496
sut := NewSMTPSendingService(cfg)
@@ -215,22 +217,22 @@ func (c *Smtp4DevClient) CountMessages() (int, error) {
215217

216218
func (c *Smtp4DevClient) SetNoTls() error {
217219
slog.Info("[smtp4Dev] disabling tls encryption")
218-
err := c.SetConfigValue("tlsMode", "None")
219-
time.Sleep(2 * time.Second)
220+
err := c.SetConfigValue("ServerOptions__TlsMode", "None")
221+
time.Sleep(5 * time.Second)
220222
return err
221223
}
222224

223225
func (c *Smtp4DevClient) SetForcedTls() error {
224226
slog.Info("[smtp4Dev] enabling forced tls encryption")
225-
err := c.SetConfigValue("tlsMode", "ImplicitTls")
226-
time.Sleep(2 * time.Second)
227+
err := c.SetConfigValue("ServerOptions__TlsMode", "ImplicitTls")
228+
time.Sleep(5 * time.Second)
227229
return err
228230
}
229231

230232
func (c *Smtp4DevClient) SetStartTls() error {
231233
slog.Info("[smtp4Dev] enabling tls encryption via starttls")
232-
err := c.SetConfigValue("tlsMode", "StartTls")
233-
time.Sleep(2 * time.Second)
234+
err := c.SetConfigValue("ServerOptions__TlsMode", "StartTls")
235+
time.Sleep(5 * time.Second)
234236
return err
235237
}
236238

testing/run_mail_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trap cleanup EXIT
1111
cleanup
1212

1313
echo "Starting smtp4dev in Docker ..."
14-
docker run -d --rm -p 2525:25 -p 8080:80 --name smtp4dev_wakapi rnwood/smtp4dev
14+
docker run -d --rm -p 2525:25 -p 2465:465 -p 8080:80 --name smtp4dev_wakapi rnwood/smtp4dev
1515

1616
echo "Running tests ..."
1717
script_dir=$(dirname "${BASH_SOURCE[0]}")

0 commit comments

Comments
 (0)