@Override public void startSMTP() { super.startSMTP(); smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "250-example.com\n" + "250-SIZE 1000000\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"); }
@Override public void startSMTP() { super.startSMTP(); smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "250 example.com", "MAIL FROM:", "250 2.1.0 Ok", "RCPT TO:", "250 2.1.5 Ok", "RCPT TO:", "501 5.1.3 Bad recipient address syntax", "DATA", "354 End data with <CR><LF>.<CR><LF>", "250 2.0.0 Ok: queued as ABCDDEF0123456789", "QUIT", "221 2.0.0 Bye"); }
@Test public void authLoginStartFailTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "250-example.com\n" + "250 AUTH LOGIN", "AUTH LOGIN", "555 login is not possible due to some error"); testException(mailClientLogin()); }
@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 authJunkTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "250-example.com\n" + "250 AUTH JUNK"); testException(mailClientLogin()); }
@Test public void closeOnConnectTest(TestContext testContext) { this.testContext = testContext; smtpServer.setDialogue(""); smtpServer.setCloseImmediately(true); testException(); }
@Test public void closeAfterBannerTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP"); smtpServer.setCloseImmediately(true); testException(); }
@Test public void authPlainFailTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "250-example.com\n" + "250 AUTH PLAIN", "AUTH PLAIN AHh4eAB5eXk=", "435 4.7.8 Error: authentication failed: bad protocol / cancel"); testException(mailClientLogin()); }
@Test public void authCramMD5StartFailTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "250-example.com\n" + "250 AUTH CRAM-MD5", "AUTH CRAM-MD5", "555 login is not possible due to some error"); testException(mailClientLogin()); }
@Test public void authCramMD5FailTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "250-example.com\n" + "250 AUTH CRAM-MD5", "AUTH CRAM-MD5", "334 PDEyMzQuYWJjZEBleGFtcGxlLmNvbT4=", "eHh4IDE2ZGEzMGQ5NmEwNTY4NWQ0MmQ4YzM5ZDlkMDgxOGIx", "435 4.7.8 Error: authentication failed: bad protocol / cancel"); testException(mailClientLogin()); }
@Test public void authLoginUsernameFailTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "250-example.com\n" + "250 AUTH LOGIN", "AUTH LOGIN", "334 VXNlcm5hbWU6", "eHh4", "555 login is not possible due to some error"); testException(mailClientLogin()); }
@Test public void authLoginFailTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "250-example.com\n" + "250 AUTH LOGIN", "AUTH LOGIN", "334 VXNlcm5hbWU6", "eHh4", "334 UGFzc3dvcmQ6", "eXl5", "435 4.7.8 Error: authentication failed: authentication failure"); testException(mailClientLogin()); }
@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 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 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 we have Login REQUIRED but no login data in the config */ @Test public void authAuthDataMissingTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "250-example.com\n" + "250 AUTH PLAIN"); testException(MailClient.createNonShared(vertx, defaultConfig().setLogin(LoginOption.REQUIRED))); }
@Test public void authSelectMethodsNoneTest(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "250-example.com\n" + "250 AUTH PLAIN LOGIN"); testException(MailClient.createNonShared(vertx, configLogin().setAuthMethods("DIGEST-MD5 CRAM-MD5"))); }
@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 allAddressFailureFailsMail(TestContext testContext) { this.testContext=testContext; smtpServer.setDialogue("220 example.com ESMTP", "EHLO", "250 example.com", "MAIL FROM:", "250 2.1.0 Ok", "RCPT TO:", "501 5.1.3 Bad recipient address syntax", "RCPT TO:", "501 5.1.3 Bad recipient address syntax"); MailMessage mail = exampleMessage() .setTo(Arrays.asList("user@example.com", "fail@example.org")); MailConfig config = configNoSSL() .setAllowRcptErrors(true); MailClient mailClient = MailClient.createNonShared(vertx, config); testException(mailClient, mail); }
@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()); }