@Test public void mailNoEhloTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com", "HELO", "250 example.com", "MAIL FROM", "250 2.1.0 Ok", "RCPT TO", "250 2.1.5 Ok", "DATA", "354 End data with <CR><LF>.<CR><LF>", "250 2.0.0 Ok: queued as ABCDDEF0123456789", "QUIT", "221 2.0.0 Bye"); smtpServer.setCloseImmediately(false); MailConfig mailConfig = defaultConfig(); mailConfig.setDisableEsmtp(true); testSuccess(MailClient.createNonShared(vertx, mailConfig), exampleMessage()); }
@Test public void stlsMissingTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP multiline", "EHLO", "250-example.com\n" + "250-SIZE 48000000\n" + "250 PIPELINING", "MAIL FROM", "250 2.1.0 Ok", "RCPT TO", "250 2.1.5 Ok", "DATA", "354 End data with <CR><LF>.<CR><LF>", "250 2.0.0 Ok: queued as ABCDDEF0123456789", "QUIT", "221 2.0.0 Bye"); smtpServer.setCloseImmediately(false); testException(mailClientTLS()); }
@Test public void esmtpCheckTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com Esmtp", "EHLO", "250 example.com", "MAIL FROM", "250 2.1.0 Ok", "RCPT TO", "250 2.1.5 Ok", "DATA", "354 End data with <CR><LF>.<CR><LF>", "250 2.0.0 Ok: queued as ABCDDEF0123456789", "QUIT", "221 2.0.0 Bye"); smtpServer.setCloseImmediately(false); testSuccess(); }
@Test public void serverUnavailableTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("400 cannot talk to you right now"); smtpServer.setCloseImmediately(true); testException(); }
@Test public void mailEhloMissingTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "402 4.5.2 Error: command not recognized", "HELO", "250 example.com", "MAIL FROM", "250 2.1.0 Ok", "RCPT TO", "250 2.1.5 Ok", "DATA", "354 End data with <CR><LF>.<CR><LF>", "250 2.0.0 Ok: queued as ABCDDEF0123456789", "QUIT", "221 2.0.0 Bye"); smtpServer.setCloseImmediately(false); testSuccess(); }
@Test public void connectionRefusedTest(TestContext testContext) { this.testContext=testContext; testException(MailClient.createNonShared(vertx, new MailConfig("localhost", 1588))); }
@Test public void mailNoEsmtpTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com", "EHLO ", "502 EHLO command not understood", "HELO ", "250 example.com", "MAIL FROM", "250 2.1.0 Ok", "RCPT TO", "250 2.1.5 Ok", "DATA", "354 End data with <CR><LF>.<CR><LF>", "250 2.0.0 Ok: queued as ABCDDEF0123456789", "QUIT", "221 2.0.0 Bye"); smtpServer.setCloseImmediately(false); testSuccess(); }
@Test public void closeOnConnectTest(TestContext testContext) { this.testContext = testContext; smtpServer.setDialogue(""); smtpServer.setCloseImmediately(true); testException(); }
@Test public void mailMultilineWelcomeTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220-example.com ESMTP multiline\n" + "220-this server uses a multi-line welcome message\n" + "220 this is supposed to confuse spammers", "EHLO", "250-example.com\n" + "250-SIZE 48000000\n" + "250 PIPELINING", "MAIL FROM", "250 2.1.0 Ok", "RCPT TO", "250 2.1.5 Ok", "DATA", "354 End data with <CR><LF>.<CR><LF>", "250 2.0.0 Ok: queued as ABCDDEF0123456789", "QUIT", "221 2.0.0 Bye"); smtpServer.setCloseImmediately(false); testSuccess(); }
@Test public void closeAfterBannerTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP"); smtpServer.setCloseImmediately(true); testException(); }
@Test public void replyAfterQuitTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "250-example.com\n" + "250-SIZE 48000000\n" + "250 PIPELINING", "MAIL FROM", "250 2.1.0 Ok", "RCPT TO", "250 2.1.5 Ok", "DATA", "354 End data with <CR><LF>.<CR><LF>", // message data "250 2.0.0 Ok: queued as ABCDDEF0123456789", "QUIT", "221 2.0.0 Bye", "", // this should not happen: "this is unexpected" ); smtpServer.setCloseImmediately(false); testSuccess(); }