use of com.zimbra.soap.mail.message.BrowseRequest in project zm-mailbox by Zimbra.
the class TestJaxb method testBrowseRequestObjectsBadRegex.
/** BrowseRequest should fail as regex is too complex */
@Test
public void testBrowseRequestObjectsBadRegex() 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_TEXT_PLAIN).create();
TestUtil.addRawMessage(zmbox, raw);
forceIndexing(USER_NAME);
BrowseRequest browseRequest = new BrowseRequest("objects", /* browseBy */
"", /* regex */
10);
BrowseResponse browseResponse = doBrowseRequest(browseRequest);
Assert.assertTrue("BrowseDatas size should be greater than 1", browseResponse.getBrowseDatas().size() >= 1);
browseRequest = new BrowseRequest("objects", /* 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.soap.mail.message.BrowseRequest 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.soap.mail.message.BrowseRequest in project zm-mailbox by Zimbra.
the class TestJaxb method testBrowseRequestAttachments.
@Test
public void testBrowseRequestAttachments() 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 */
"", /* regex */
10);
BrowseResponse browseResponse = doBrowseRequest(browseRequest);
Assert.assertNotNull("JAXB BrowseResponse object", browseResponse);
List<BrowseData> datas = browseResponse.getBrowseDatas();
Assert.assertNotNull("JAXB BrowseResponse datas", datas);
Assert.assertTrue("JAXB BrowseResponse datas", datas.size() >= 1);
}
use of com.zimbra.soap.mail.message.BrowseRequest in project zm-mailbox by Zimbra.
the class TestJaxb method testBrowseRequestObjects.
@Test
public void testBrowseRequestObjects() 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_TEXT_PLAIN).create();
TestUtil.addRawMessage(zmbox, raw);
forceIndexing(USER_NAME);
BrowseRequest browseRequest = new BrowseRequest("objects", /* browseBy */
"", /* regex */
10);
BrowseResponse browseResponse = doBrowseRequest(browseRequest);
Assert.assertNotNull("JAXB BrowseResponse object", browseResponse);
List<BrowseData> datas = browseResponse.getBrowseDatas();
Assert.assertNotNull("JAXB BrowseResponse datas", datas);
Assert.assertTrue("BrowseDatas size should be greater than 0", datas.size() >= 1);
}
use of com.zimbra.soap.mail.message.BrowseRequest 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"));
}
Aggregations