(t *testing.T)
| 29 | } |
| 30 | |
| 31 | func 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 |
nothing calls this directly
no test coverage detected