use of com.zimbra.common.lmtp.LmtpClient in project zm-mailbox by Zimbra.
the class TestLmtp method testLhloNotSendByClientAfterStartTLS.
@Test
public void testLhloNotSendByClientAfterStartTLS() throws Exception {
String[] commands = new String[] { NOOP, RSET, VRFY + " " + USER_NAME, "MAIL FROM:<" + TestUtil.addDomainIfNecessary(USER_NAME) + ">" };
LmtpClient lmtpClient;
Provisioning prov = Provisioning.getInstance();
boolean lhloRequired = prov.getLocalServer().getBooleanAttr(Provisioning.A_zimbraLmtpLHLORequired, true);
boolean replyOk;
for (String command : commands) {
lmtpClient = new LmtpClient("localhost", Provisioning.getInstance().getLocalServer().getIntAttr(Provisioning.A_zimbraLmtpBindPort, 7025));
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
lmtpClient.sendLine("LHLO " + LC.zimbra_server_hostname.value());
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
if (lmtpClient.getResponse().contains("STARTTLS")) {
lmtpClient.startTLS();
lmtpClient.sendLine(command);
replyOk = lmtpClient.replyOk();
Assert.assertTrue("Response :" + lmtpClient.getResponse() + " for command :" + command, lhloRequired ? !replyOk : replyOk);
}
lmtpClient.abruptClose();
}
}
use of com.zimbra.common.lmtp.LmtpClient in project zm-mailbox by Zimbra.
the class TestLmtp method testSizeHint.
/**
* Confirms that a message gets delivered regardless of what the size hint is set to.
*/
@Test
public void testSizeHint() throws Exception {
// Send the same message 5 times with different size hints
String address = TestUtil.getAddress(USER_NAME);
String subject = NAME_PREFIX + " testIncorrectSizeHint";
String messageString = TestUtil.getTestMessage(subject, address, address, null);
String[] recipients = new String[] { address };
LmtpClient lmtp = new LmtpClient("localhost", 7025);
byte[] data = messageString.getBytes();
lmtp.sendMessage(new ByteArrayInputStream(data), recipients, address, "TestLmtp", null);
lmtp.sendMessage(new ByteArrayInputStream(data), recipients, address, "TestLmtp", 0L);
lmtp.sendMessage(new ByteArrayInputStream(data), recipients, address, "TestLmtp", 10L);
lmtp.sendMessage(new ByteArrayInputStream(data), recipients, address, "TestLmtp", (long) data.length);
lmtp.sendMessage(new ByteArrayInputStream(data), recipients, address, "TestLmtp", (long) Integer.MAX_VALUE);
lmtp.close();
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
List<ZMessage> messages = TestUtil.search(mbox, subject);
Assert.assertEquals(5, messages.size());
// Check message bodies
ZGetMessageParams params = new ZGetMessageParams();
params.setRawContent(true);
for (ZMessage msg : messages) {
String content = TestUtil.getContent(mbox, msg.getId());
TestUtil.assertMessageContains(content, messageString);
}
}
use of com.zimbra.common.lmtp.LmtpClient in project zm-mailbox by Zimbra.
the class TestLmtp method testFinalDotNotSent.
// bug 53058
@Test
public void testFinalDotNotSent() throws Exception {
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
LmtpClient lmtpClient = new LmtpClient("localhost", Provisioning.getInstance().getLocalServer().getIntAttr(Provisioning.A_zimbraLmtpBindPort, 7025));
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
lmtpClient.sendLine("LHLO " + LC.zimbra_server_hostname.value());
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
if (lmtpClient.getResponse().contains(STARTTLS)) {
lmtpClient.startTLS();
lmtpClient.sendLine("LHLO " + LC.zimbra_server_hostname.value());
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
}
lmtpClient.sendLine("MAIL FROM:<" + TestUtil.addDomainIfNecessary(USER_NAME) + ">");
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
lmtpClient.sendLine("RCPT TO:<" + TestUtil.addDomainIfNecessary(USER_NAME) + ">");
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
lmtpClient.sendLine("DATA");
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
String subject = NAME_PREFIX + " testFinalDotNotSent";
lmtpClient.sendLine("Subject: " + subject);
lmtpClient.abruptClose();
// wait for some time
Thread.sleep(1000);
List<ZMessage> msgs = TestUtil.search(mbox, "in:inbox " + subject);
Assert.assertTrue("msg got delivered via LMTP even though <CRLF>.<CRLF> was not received", msgs.isEmpty());
}
use of com.zimbra.common.lmtp.LmtpClient in project zm-mailbox by Zimbra.
the class TestLmtp method testServeShouldNotPublishStartTlsOnSecondLlhoCommand.
@Test
public void testServeShouldNotPublishStartTlsOnSecondLlhoCommand() throws Exception {
LmtpClient lmtpClient = new LmtpClient("localhost", Provisioning.getInstance().getLocalServer().getIntAttr(Provisioning.A_zimbraLmtpBindPort, 7025));
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
lmtpClient.sendLine("LHLO " + LC.zimbra_server_hostname.value());
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
if (lmtpClient.getResponse().contains("STARTTLS")) {
lmtpClient.startTLS();
lmtpClient.sendLine("LHLO " + LC.zimbra_server_hostname.value());
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
Assert.assertTrue(lmtpClient.getResponse(), !lmtpClient.getResponse().contains(STARTTLS));
}
lmtpClient.abruptClose();
}
Aggregations