-
-
Notifications
You must be signed in to change notification settings - Fork 763
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1164 from bishtawi/bishtawi/smtp-auth
Support SMTP Auth Plain for event publishing
- Loading branch information
Showing
2 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1386,6 +1386,28 @@ what's up | |
writeAndReadUntilLine(t, email, c, scanner, "250 2.0.0 OK: queued") | ||
} | ||
|
||
func TestSmtpBackend_PlaintextWithPlainAuth(t *testing.T) { | ||
email := `EHLO example.com | ||
AUTH PLAIN dGVzdAB0ZXN0ADEyMzQ= | ||
MAIL FROM: [email protected] | ||
RCPT TO: [email protected] | ||
DATA | ||
Subject: Very short mail | ||
what's up | ||
. | ||
` | ||
s, c, _, scanner := newTestSMTPServer(t, func(w http.ResponseWriter, r *http.Request) { | ||
require.Equal(t, "/mytopic", r.URL.Path) | ||
require.Equal(t, "Very short mail", r.Header.Get("Title")) | ||
require.Equal(t, "Basic dGVzdDoxMjM0", r.Header.Get("Authorization")) | ||
require.Equal(t, "what's up", readAll(t, r.Body)) | ||
}) | ||
defer s.Close() | ||
defer c.Close() | ||
writeAndReadUntilLine(t, email, c, scanner, "250 2.0.0 OK: queued") | ||
} | ||
|
||
type smtpHandlerFunc func(http.ResponseWriter, *http.Request) | ||
|
||
func newTestSMTPServer(t *testing.T, handler smtpHandlerFunc) (s *smtp.Server, c net.Conn, conf *Config, scanner *bufio.Scanner) { | ||
|