1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

smtpsrv: Don't hard-code ports in tests

The smtpsrv tests hard-code ports, but this patch fixes that by making it
use the new testlib.GetFreePort function.
This commit is contained in:
Alberto Bertogli
2019-11-30 11:38:13 +00:00
parent d0f65881c9
commit 933b979220

View File

@@ -19,6 +19,7 @@ import (
"blitiri.com.ar/go/chasquid/internal/aliases" "blitiri.com.ar/go/chasquid/internal/aliases"
"blitiri.com.ar/go/chasquid/internal/courier" "blitiri.com.ar/go/chasquid/internal/courier"
"blitiri.com.ar/go/chasquid/internal/testlib"
"blitiri.com.ar/go/chasquid/internal/userdb" "blitiri.com.ar/go/chasquid/internal/userdb"
) )
@@ -33,12 +34,11 @@ var (
) )
var ( var (
// Server addresses. // Server addresses. Will be filled in at init time.
// We default to internal ones, but may get overridden via flags. // We default to internal ones, but may get overridden via flags.
// TODO: Don't hard-code the default. smtpAddr = ""
smtpAddr = "127.0.0.1:13444" submissionAddr = ""
submissionAddr = "127.0.0.1:13999" submissionTLSAddr = ""
submissionTLSAddr = "127.0.0.1:13777"
// TLS configuration to use in the clients. // TLS configuration to use in the clients.
// Will contain the generated server certificate as root CA. // Will contain the generated server certificate as root CA.
@@ -470,6 +470,10 @@ func realMain(m *testing.M) int {
return 1 return 1
} }
smtpAddr = testlib.GetFreePort()
submissionAddr = testlib.GetFreePort()
submissionTLSAddr = testlib.GetFreePort()
s := NewServer() s := NewServer()
s.Hostname = "localhost" s.Hostname = "localhost"
s.MaxDataSize = 50 * 1024 * 1025 s.MaxDataSize = 50 * 1024 * 1025