use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestMaxMessageSize method testMaxMessageSizeSaveDraft.
/**
* Confirms that
* @throws Exception
*/
@Test
public void testMaxMessageSizeSaveDraft() throws Exception {
setMaxMessageSize(TEST_MAX_MESSAGE_SIZE);
// Upload attachment whose size is 50% of the threshold. If this number
// gets incremented twice, it would exceed the threshold.
Map<String, byte[]> attachments = new HashMap<String, byte[]>();
attachments.put("file1.exe", new byte[(int) (TEST_MAX_MESSAGE_SIZE * 0.5)]);
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String aid = mbox.uploadAttachments(attachments, 5000);
// Save draft
ZOutgoingMessage outgoing = new ZOutgoingMessage();
List<ZEmailAddress> addresses = new ArrayList<ZEmailAddress>();
addresses.add(new ZEmailAddress(TestUtil.getAddress(USER_NAME), null, null, ZEmailAddress.EMAIL_TYPE_TO));
outgoing.setAddresses(addresses);
outgoing.setAttachmentUploadId(aid);
String subject = NAME_PREFIX + "testMaxMessageSizeSaveDraft";
outgoing.setSubject(subject);
ZMessage draft = mbox.saveDraft(outgoing, null, null);
// Send the draft
outgoing.setAttachmentUploadId(null);
List<AttachedMessagePart> attachedParts = new ArrayList<AttachedMessagePart>();
attachedParts.add(new AttachedMessagePart(draft.getId(), "1", null));
outgoing.setMessagePartsToAttach(attachedParts);
mbox.sendMessage(outgoing, null, false);
TestUtil.waitForMessage(mbox, "in:inbox subject:\"" + subject + "\"");
// Reduce max message size and confirm that the send fails.
setMaxMessageSize((int) (TEST_MAX_MESSAGE_SIZE * 0.6));
try {
mbox.sendMessage(outgoing, null, false);
Assert.fail("Message send should not have succeeded.");
} catch (SoapFaultException e) {
// Message send was not allowed, as expected.
validateMessageTooBigFault(e);
}
}
use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestMessageIntercept method testIntercept.
public void testIntercept() throws Exception {
// Turn on legal intercept for recipient account
String interceptorAddress = TestUtil.getAddress(INTERCEPTOR1_NAME);
String senderAddress = TestUtil.getAddress(SENDER_NAME);
TestUtil.setAccountAttr(RECIPIENT_NAME, Provisioning.A_zimbraInterceptAddress, interceptorAddress);
TestUtil.setAccountAttr(RECIPIENT_NAME, Provisioning.A_zimbraInterceptSendHeadersOnly, LdapConstants.LDAP_FALSE);
// Send message to recipient account and make sure it's intercepted
ZMailbox interceptorMbox = TestUtil.getZMailbox(INTERCEPTOR1_NAME);
ZMailbox tappedMbox = TestUtil.getZMailbox(RECIPIENT_NAME);
String tappedAddress = TestUtil.getAddress(RECIPIENT_NAME);
String subject = NAME_PREFIX + " testIntercept-receive";
TestUtil.addMessageLmtp(subject, tappedAddress, senderAddress);
ZMessage tappedMsg = TestUtil.getMessage(tappedMbox, "subject:\"" + subject + "\"");
ZMessage interceptMsg = TestUtil.waitForMessage(interceptorMbox, "subject:\"" + subject + "\"");
verifyInterceptMessage(interceptMsg, "add message", "Inbox", Integer.toString(Mailbox.ID_FOLDER_INBOX));
compareContent(tappedMbox, tappedMsg, interceptorMbox, interceptMsg);
// Confirm that saving a draft is intercepted. The first draft calls Mailbox.addMessage().
ZOutgoingMessage outgoing = new ZOutgoingMessage();
List<ZEmailAddress> addresses = new ArrayList<ZEmailAddress>();
addresses.add(new ZEmailAddress(TestUtil.getAddress(INTERCEPTOR1_NAME), null, null, ZEmailAddress.EMAIL_TYPE_TO));
outgoing.setAddresses(addresses);
subject = NAME_PREFIX + " testIntercept-draft-1";
outgoing.setSubject(subject);
outgoing.setMessagePart(new MessagePart("text/plain", "I always feel like somebody's watching me."));
tappedMbox.saveDraft(outgoing, null, Integer.toString(Mailbox.ID_FOLDER_DRAFTS));
tappedMsg = TestUtil.getMessage(tappedMbox, "in:drafts subject:\"" + subject + "\"");
interceptMsg = TestUtil.waitForMessage(interceptorMbox, "subject:\"" + subject + "\"");
verifyInterceptMessage(interceptMsg, "add message", "Drafts", Integer.toString(Mailbox.ID_FOLDER_DRAFTS));
compareContent(tappedMbox, tappedMsg, interceptorMbox, interceptMsg);
// Save draft again. This time Mailbox.saveDraft() gets called.
ZMessage draft = TestUtil.getMessage(tappedMbox, "in:drafts subject:\"" + subject + "\"");
subject = NAME_PREFIX + " testIntercept-draft-2";
outgoing.setSubject(subject);
tappedMbox.saveDraft(outgoing, draft.getId(), null);
tappedMsg = TestUtil.getMessage(tappedMbox, "in:drafts subject:\"" + subject + "\"");
interceptMsg = TestUtil.waitForMessage(interceptorMbox, "subject:\"" + subject + "\"");
verifyInterceptMessage(interceptMsg, "save draft", "Drafts", Integer.toString(Mailbox.ID_FOLDER_DRAFTS));
compareContent(tappedMbox, tappedMsg, interceptorMbox, interceptMsg);
// Send message with save-to-sent turned on.
TestUtil.setAccountAttr(RECIPIENT_NAME, Provisioning.A_zimbraPrefSaveToSent, LdapConstants.LDAP_TRUE);
subject = NAME_PREFIX + " testIntercept-send-1";
TestUtil.sendMessage(tappedMbox, INTERCEPTOR1_NAME, subject);
tappedMsg = TestUtil.waitForMessage(tappedMbox, "in:sent subject:\"" + subject + "\"");
interceptMsg = TestUtil.waitForMessage(interceptorMbox, "subject:intercepted subject:\"" + subject + "\"");
verifyInterceptMessage(interceptMsg, "add message", "Sent", Integer.toString(Mailbox.ID_FOLDER_SENT));
compareContent(tappedMbox, tappedMsg, interceptorMbox, interceptMsg);
// Send message with save-to-sent turned off.
TestUtil.setAccountAttr(RECIPIENT_NAME, Provisioning.A_zimbraPrefSaveToSent, LdapConstants.LDAP_FALSE);
subject = NAME_PREFIX + " testIntercept-send-2";
TestUtil.sendMessage(tappedMbox, INTERCEPTOR1_NAME, subject);
interceptMsg = TestUtil.waitForMessage(interceptorMbox, "subject:intercepted subject:\"" + subject + "\"");
verifyInterceptMessage(interceptMsg, "send message", "none", "none");
// Check intercepting headers only.
TestUtil.setAccountAttr(RECIPIENT_NAME, Provisioning.A_zimbraInterceptSendHeadersOnly, LdapConstants.LDAP_TRUE);
subject = NAME_PREFIX + " testIntercept-headers-only";
TestUtil.sendMessage(interceptorMbox, RECIPIENT_NAME, subject);
tappedMsg = TestUtil.waitForMessage(tappedMbox, "in:inbox subject:\"" + subject + "\"");
interceptMsg = TestUtil.waitForMessage(interceptorMbox, "subject:intercepted subject:\"" + subject + "\"");
verifyInterceptMessage(interceptMsg, "add message", "Inbox", Integer.toString(Mailbox.ID_FOLDER_INBOX));
compareContent(tappedMbox, tappedMsg, interceptorMbox, interceptMsg);
}
use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestMessageIntercept method testInterceptMultiValue.
/**
* Confirms that legal intercept works with multiple interceptor addresses (bug 30961).
*/
public void testInterceptMultiValue() throws Exception {
// Turn on legal intercept for recipient account.
String interceptor1Address = TestUtil.getAddress(INTERCEPTOR1_NAME);
String interceptor2Address = TestUtil.getAddress(INTERCEPTOR2_NAME);
String senderAddress = TestUtil.getAddress(SENDER_NAME);
String[] interceptorAddresses = new String[] { interceptor1Address, interceptor2Address };
TestUtil.setAccountAttr(RECIPIENT_NAME, Provisioning.A_zimbraInterceptAddress, interceptorAddresses);
TestUtil.setAccountAttr(RECIPIENT_NAME, Provisioning.A_zimbraInterceptSendHeadersOnly, LdapConstants.LDAP_FALSE);
// Send message to recipient account.
ZMailbox tappedMbox = TestUtil.getZMailbox(RECIPIENT_NAME);
String tappedAddress = TestUtil.getAddress(RECIPIENT_NAME);
String subject = NAME_PREFIX + " testIntercept-receive";
TestUtil.addMessageLmtp(subject, tappedAddress, senderAddress);
// Make sure both interceptor accounts intercepted it.
ZMailbox interceptor1Mbox = TestUtil.getZMailbox(INTERCEPTOR1_NAME);
ZMailbox interceptor2Mbox = TestUtil.getZMailbox(INTERCEPTOR2_NAME);
ZMessage tappedMsg = TestUtil.getMessage(tappedMbox, "subject:\"" + subject + "\"");
ZMessage interceptMsg1 = TestUtil.waitForMessage(interceptor1Mbox, "subject:\"" + subject + "\"");
ZMessage interceptMsg2 = TestUtil.waitForMessage(interceptor2Mbox, "subject:\"" + subject + "\"");
verifyInterceptMessage(interceptMsg1, "add message", "Inbox", Integer.toString(Mailbox.ID_FOLDER_INBOX));
verifyInterceptMessage(interceptMsg2, "add message", "Inbox", Integer.toString(Mailbox.ID_FOLDER_INBOX));
compareContent(tappedMbox, tappedMsg, interceptor1Mbox, interceptMsg1);
compareContent(tappedMbox, tappedMsg, interceptor2Mbox, interceptMsg2);
}
use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestJaxb method acceptInvite.
private ZMessage acceptInvite(ZMailbox attendeeBox, ZMailbox organizerBox, ZMessage inviteMsg, String subject) throws Exception {
SendInviteReplyRequest sirReq = new SendInviteReplyRequest(inviteMsg.getId(), 0, /* componentNum */
"ACCEPT");
sirReq.setIdentityId(attendeeBox.getAccountInfo(false).getId());
// ZWC 8.6 and earlier used to set this to false. Now sets it to true.
sirReq.setUpdateOrganizer(true);
MimePartInfo mimePart = MimePartInfo.createForContentType("multipart/alternative");
mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/plain", "Accepting"));
mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/html", "<html><body><p><b>Accepting</b></p></body></html>"));
Msg msg = new Msg();
msg.setReplyType("r");
msg.setIdentityId(attendeeBox.getAccountInfo(false).getId());
EmailAddrInfo orgAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(organizerBox.getName(), organizerBox.getName(), "t");
EmailAddrInfo attendeeAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(attendeeBox.getName(), getCN(attendeeBox), "f");
msg.addEmailAddress(orgAddr);
msg.addEmailAddress(attendeeAddr);
String acceptSubject = "Accept: " + subject;
msg.setSubject(acceptSubject);
msg.setMimePart(mimePart);
sirReq.setMsg(msg);
SendInviteReplyResponse sirResp = attendeeBox.invokeJaxb(sirReq);
Assert.assertNotNull("JAXB SendInviteReplyResponse object", sirResp);
ZMessage inboxMsg = TestUtil.waitForMessage(organizerBox, String.format("subject:\"%s\"", acceptSubject));
Assert.assertNotNull("ZMessage for accept", inboxMsg);
return inboxMsg;
}
use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestIndex method checkQuery.
private void checkQuery(String query, String msgId) throws Exception {
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
List<ZMessage> messages = TestUtil.search(mbox, query);
if (msgId == null) {
Assert.assertEquals(0, messages.size());
} else {
Assert.assertEquals(1, messages.size());
Assert.assertEquals(msgId, messages.get(0).getId());
}
}
Aggregations