Merge pull request #6360 from thundernest/fix_SmtpResponseParser_logging
Clear log buffer before reading EHLO response
This commit is contained in:
commit
2f1b59235d
2 changed files with 26 additions and 0 deletions
|
@ -33,6 +33,8 @@ internal class SmtpResponseParser(
|
|||
}
|
||||
|
||||
fun readHelloResponse(): SmtpHelloResponse {
|
||||
logBuffer.clear()
|
||||
|
||||
val replyCode = readReplyCode()
|
||||
|
||||
if (replyCode != 250) {
|
||||
|
|
|
@ -219,6 +219,30 @@ class SmtpResponseParserTest {
|
|||
.isEqualTo("Ignoring EHLO keyword line: KEYWORD para${"\t"}meter")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `error in EHLO response after successfully reading greeting`() {
|
||||
val input = """
|
||||
220 Greeting
|
||||
INVALID
|
||||
""".toPeekableInputStream()
|
||||
val parser = SmtpResponseParser(logger, input)
|
||||
parser.readGreeting()
|
||||
|
||||
assertFailsWithMessage("Unexpected character: I (73)") {
|
||||
parser.readHelloResponse()
|
||||
}
|
||||
|
||||
assertThat(logger.logEntries).containsExactly(
|
||||
LogEntry(
|
||||
throwable = null,
|
||||
message = """
|
||||
SMTP response data on parser error:
|
||||
I
|
||||
""".trimIndent()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `positive response`() {
|
||||
val input = "200 OK".toPeekableInputStream()
|
||||
|
|
Loading…
Reference in a new issue