MCPcopy Index your code
hub / github.com/coder/coder / TestSMTP

Function TestSMTP

coderd/notifications/dispatch/smtp_test.go:31–517  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29}
30
31func TestSMTP(t *testing.T) {
32 t.Parallel()
33
34 const (
35 username = "bob"
36 password = "🤫"
37
38 hello = "localhost"
39
40 identity = "robert"
41 from = "system@coder.com"
42 to = "bob@bob.com"
43
44 subject = "This is the subject"
45 body = "This is the body"
46
47 caFile = "smtptest/fixtures/ca.crt"
48 certFile = "smtptest/fixtures/server.crt"
49 keyFile = "smtptest/fixtures/server.key"
50 )
51
52 logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true, IgnoredErrorIs: []error{}}).Leveled(slog.LevelDebug)
53 tests := []struct {
54 name string
55 cfg codersdk.NotificationsEmailConfig
56 toAddrs []string
57 authMechs []string
58 expectedAuthMeth string
59 expectedErr string
60 retryable bool
61 useTLS bool
62 failOnDataFn func() error
63 }{
64 /**
65 * LOGIN auth mechanism
66 */
67 {
68 name: "LOGIN auth",
69 authMechs: []string{sasl.Login},
70 cfg: codersdk.NotificationsEmailConfig{
71 Hello: hello,
72 From: from,
73
74 Auth: codersdk.NotificationsEmailAuthConfig{
75 Username: username,
76 Password: password,
77 },
78 },
79 toAddrs: []string{to},
80 expectedAuthMeth: sasl.Login,
81 },
82 {
83 name: "invalid LOGIN auth user",
84 authMechs: []string{sasl.Login},
85 cfg: codersdk.NotificationsEmailConfig{
86 Hello: hello,
87 From: from,
88

Callers

nothing calls this directly

Calls 15

DispatcherMethod · 0.95
LastMessageMethod · 0.95
ResetMethod · 0.95
ContextFunction · 0.92
NewBackendFunction · 0.92
CreateMockSMTPServerFunction · 0.92
NewSMTPHandlerFunction · 0.92
PingClientFunction · 0.92
helpersFunction · 0.85
NamedMethod · 0.80
RunMethod · 0.65
CleanupMethod · 0.65

Tested by

no test coverage detected