[FEATURE] Notifier Startup Checks (#889)
* implement SMTP notifier startup check
* check dial, starttls, auth, mail from, rcpt to, reset, and quit
* log the error on failure
* implement mock
* misc optimizations, adjustments, and refactoring
* implement validate_skip config option
* fix comments to end with period
* fix suites that used smtp notifier without a smtp container
* add docs
* add file notifier startup check
* move file mode into const.go
* disable gosec linting on insecureskipverify since it's intended, warned, and discouraged
* minor PR commentary adjustment
* apply suggestions from code review
Co-Authored-By: Amir Zarrinkafsh <nightah@me.com>
2020-04-21 04:59:38 +00:00
|
|
|
package notification
|
|
|
|
|
2021-11-30 11:15:21 +00:00
|
|
|
const (
|
|
|
|
fileNotifierMode = 0600
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2022-07-18 00:56:09 +00:00
|
|
|
smtpAUTHMechanismPlain = "PLAIN"
|
|
|
|
smtpAUTHMechanismLogin = "LOGIN"
|
|
|
|
|
|
|
|
smtpPortSUBMISSIONS = 465
|
|
|
|
|
|
|
|
smtpCommandDATA = "DATA"
|
|
|
|
smtpCommandHELLO = "EHLO/HELO"
|
|
|
|
smtpCommandSTARTTLS = "STARTTLS"
|
|
|
|
smtpCommandAUTH = "AUTH"
|
|
|
|
smtpCommandMAIL = "MAIL"
|
|
|
|
smtpCommandRCPT = "RCPT"
|
2022-08-26 21:39:20 +00:00
|
|
|
|
|
|
|
smtpEncodingQuotedPrintable = "quoted-printable"
|
|
|
|
smtpEncoding8bit = "8bit"
|
|
|
|
|
|
|
|
smtpContentTypeTextPlain = "text/plain"
|
|
|
|
smtpContentTypeTextHTML = "text/html"
|
|
|
|
smtpFmtContentType = `%s; charset="UTF-8"`
|
|
|
|
smtpFmtContentDispositionInline = "inline"
|
|
|
|
|
|
|
|
smtpExtSTARTTLS = smtpCommandSTARTTLS
|
|
|
|
smtpExt8BITMIME = "8BITMIME"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
headerContentType = "Content-Type"
|
|
|
|
headerContentDisposition = "Content-Disposition"
|
|
|
|
headerContentTransferEncoding = "Content-Transfer-Encoding"
|
2022-07-18 00:56:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
fmtSMTPGenericError = "error performing %s with the SMTP server: %w"
|
|
|
|
fmtSMTPDialError = "error dialing the SMTP server: %w"
|
2021-11-30 11:15:21 +00:00
|
|
|
)
|
2022-08-26 21:39:20 +00:00
|
|
|
|
|
|
|
var (
|
|
|
|
rfc2822DoubleNewLine = []byte("\r\n\r\n")
|
|
|
|
)
|