75f3dd141c
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CI and Release / lint-frontend (push) Has been cancelled
CI and Release / dockerfile-scan (push) Has been cancelled
CI and Release / test-frontend (push) Has been cancelled
CI and Release / lint-verification-agent (push) Has been cancelled
CI and Release / test-verification-agent (push) Has been cancelled
CI and Release / e2e-verification-agent (push) Has been cancelled
CI and Release / test-backend (push) Has been cancelled
CI and Release / build-dev-image (push) Has been cancelled
CI and Release / push-dev-image (push) Has been cancelled
CI and Release / build-image (push) Has been cancelled
CI and Release / build-verification-image (push) Has been cancelled
CI and Release / determine-version (push) Has been cancelled
CI and Release / push-image (push) Has been cancelled
CI and Release / push-verification-image (12) (push) Has been cancelled
CI and Release / lint-backend (push) Has been cancelled
CI and Release / push-verification-image (17) (push) Has been cancelled
CI and Release / push-verification-image (18) (push) Has been cancelled
CI and Release / release (push) Has been cancelled
CI and Release / publish-helm-chart (push) Has been cancelled
CI and Release / push-verification-image (13) (push) Has been cancelled
CI and Release / push-verification-image (14) (push) Has been cancelled
CI and Release / push-verification-image (15) (push) Has been cancelled
CI and Release / push-verification-image (16) (push) Has been cancelled
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package containers
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/testcontainers/testcontainers-go"
|
|
"github.com/testcontainers/testcontainers-go/wait"
|
|
)
|
|
|
|
const (
|
|
mailpitSmtpPort = "1025/tcp"
|
|
mailpitHttpPort = "8025/tcp"
|
|
)
|
|
|
|
// MailpitEndpoint exposes both of Mailpit's ports: SMTP to submit mail and HTTP to assert via its
|
|
// message API what actually arrived.
|
|
type MailpitEndpoint struct {
|
|
SMTP Endpoint
|
|
HTTP Endpoint
|
|
}
|
|
|
|
// StartMailpit boots a Mailpit SMTP sink that accepts any auth over an insecure connection, so a
|
|
// test notifier can submit without TLS and real credentials.
|
|
func StartMailpit(t *testing.T) MailpitEndpoint {
|
|
t.Helper()
|
|
|
|
req := testcontainers.ContainerRequest{
|
|
Image: "axllent/mailpit:v1.20.5",
|
|
ExposedPorts: []string{mailpitSmtpPort, mailpitHttpPort},
|
|
Env: map[string]string{
|
|
"MP_SMTP_AUTH_ACCEPT_ANY": "true",
|
|
"MP_SMTP_AUTH_ALLOW_INSECURE": "true",
|
|
},
|
|
WaitingFor: wait.ForListeningPort(mailpitSmtpPort).WithStartupTimeout(120 * time.Second),
|
|
}
|
|
|
|
handle := startContainer(t, req, mailpitSmtpPort)
|
|
|
|
return MailpitEndpoint{
|
|
SMTP: handle.Endpoint,
|
|
HTTP: endpointOf(t, handle.Container, mailpitHttpPort),
|
|
}
|
|
}
|