use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestJaxb method testBrowseRequestDomainsBadRegex.
/**
* BrowseRequest should fail as regex is too complex
*/
@Test
public void testBrowseRequestDomainsBadRegex() throws Exception {
TestUtil.createAccount(USER_NAME);
ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
// If there are no messages to match at all, the browse will pass because the regex doesn't get
// used. Need some messages containing email addresses with domains in to match against
TestUtil.addMessage(zmbox, NAME_PREFIX);
forceIndexing(USER_NAME);
BrowseRequest browseRequest = new BrowseRequest("domains", /* browseBy */
BAD_REGEX, /* regex */
10);
Element envelope = doBadBrowseRequest(browseRequest);
Assert.assertNotNull("Envelope", envelope);
Assert.assertTrue("Error contained in SOAP response", envelope.toString().contains("regular expression match involved more than 100000 accesses for pattern"));
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestJaxb method doBrowseRequest.
public BrowseResponse doBrowseRequest(BrowseRequest browseRequest) throws Exception {
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String authToken = mbox.getAuthToken().getValue();
DocumentResult dr = new DocumentResult();
marshaller.marshal(browseRequest, dr);
Document doc = dr.getDocument();
ZimbraLog.test.debug(doc.getRootElement().asXML());
return (BrowseResponse) sendReq(envelope(authToken, doc.getRootElement().asXML()), "BrowseRequest");
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestJaxb method testBrowseRequestAttachmentsBadRegex.
/**
* BrowseRequest should fail as regex is too complex
*/
@Test
public void testBrowseRequestAttachmentsBadRegex() throws Exception {
TestUtil.createAccount(USER_NAME);
ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
MessageBuilder mb = new MessageBuilder();
String raw = mb.withSubject(NAME_PREFIX).withBody(bodyWithObject).withContentType(MimeConstants.CT_APPLICATION_PDF).create();
TestUtil.addRawMessage(zmbox, raw);
forceIndexing(USER_NAME);
BrowseRequest browseRequest = new BrowseRequest("attachments", /* browseBy */
BAD_REGEX, /* regex */
10);
Element envelope = doBadBrowseRequest(browseRequest);
Assert.assertNotNull("Envelope", envelope);
Assert.assertTrue("Error contained in SOAP response", envelope.toString().contains("regular expression match involved more than 100000 accesses for pattern"));
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestFilterRFCCompliantNotify method cleanUp.
private void cleanUp() throws Exception {
TestUtil.deleteTestData(USER_NAME, NAME_PREFIX);
TestUtil.deleteTestData(REMOTE_USER_NAME, NAME_PREFIX);
// Clean up messages created by testBase64Subject()
// bug 36705 for (ZMessage msg : TestUtil.search(mMbox, "villanueva")) {
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
for (ZMessage msg : TestUtil.search(mbox, "cortes de luz")) {
mbox.deleteMessage(msg.getId());
}
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestFilterRFCCompliantNotify method testNotifyAction.
public void testNotifyAction() throws Exception {
if (!mAvailableRFCCompliantNotify) {
fail("Unable to test because 'zimbraSieveNotifyActionRFCCompliant' is set to FALSE");
return;
}
List<ZFilterRule> rules = new ArrayList<ZFilterRule>();
List<ZFilterCondition> conditions = new ArrayList<ZFilterCondition>();
List<ZFilterAction> actions = new ArrayList<ZFilterAction>();
conditions.add(new ZFilterCondition.ZTrueCondition());
String notifyMsg = "This is the notification email alert";
StringBuilder mailto = new StringBuilder("mailto:").append(TestUtil.getAddress(REMOTE_USER_NAME)).append("?body=").append(notifyMsg).append("&Importance=High&X-Priority=1");
String subject = NAME_PREFIX + " testRFCCompliantNotifyAction";
// add an action to notify user2
actions.add(new ZFilterAction.ZRFCCompliantNotifyAction(TestUtil.getAddress(USER_NAME), subject, mailto.toString()));
rules.add(new ZFilterRule("testRFCCompliantNotifyAction", true, false, conditions, actions));
saveIncomingRules(mMbox, new ZFilterRules(rules));
String body = "Hi, How are you today?";
String msg = new MessageBuilder().withFrom(REMOTE_USER_NAME).withSubject(subject).withBody(body).create();
// send msg to user1
TestUtil.addMessageLmtp(new String[] { USER_NAME }, REMOTE_USER_NAME, msg);
// check msg got filed into user1's mailbox
TestUtil.getMessage(mMbox, "in:inbox subject:\"" + subject + "\"");
// check notification msg from user1 in user2's mailbox, it should have the same subject
ZMailbox zMailbox = TestUtil.getZMailbox(REMOTE_USER_NAME);
List<ZMessage> msgs = TestUtil.waitForMessages(zMailbox, "in:inbox subject:\"" + subject + "\"", 1, 120000);
ZMessage zMessage = msgs.get(0);
// ZMessage zMessage = TestUtil.waitForMessage(zMailbox, "in:inbox subject:\"" + subject + "\"");
ZMessage.ZMimePart mimeStructure = zMessage.getMimeStructure();
String bodyContent = mimeStructure.getContent();
// check body text of the notification msg
assertTrue(bodyContent.contains(notifyMsg));
// check headers of the notification msg
String content = TestUtil.getContent(zMailbox, zMessage.getId());
assertTrue(content.contains("From: " + USER_NAME));
assertTrue(content.contains("To: " + REMOTE_USER_NAME));
assertTrue(content.contains("Subject: " + subject));
assertTrue(content.contains("Auto-Submitted: auto-notified;"));
assertTrue(content.contains("X-Zimbra-Forwarded: " + USER_NAME));
}
Aggregations