use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestLockoutMailbox method testLockAccountEnumeration.
@Test
public void testLockAccountEnumeration() throws Exception {
Mailbox mbox = TestUtil.getMailbox(MY_USER);
TestUtil.addMessage(mbox, "test");
TestUtil.waitForMessage(TestUtil.getZMailbox(MY_USER), "test");
List<AdminRight> relatedRights = new ArrayList<AdminRight>();
List<String> notes = new ArrayList<String>();
AdminDocumentHandler handler = new LockoutMailbox();
handler.docRights(relatedRights, notes);
createDelegatedAdmin(relatedRights);
LockoutMailboxRequest req = LockoutMailboxRequest.create(AccountNameSelector.fromName(OFFLIMITS_NON_EXISTING_USER));
req.setOperation(AdminConstants.A_START);
try {
delegatedSoapProv.invokeJaxb(req);
fail("should have caught an exception");
} catch (SoapFaultException e) {
assertEquals("should be getting 'Permission Denied' response", ServiceException.PERM_DENIED, e.getCode());
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestLockoutMailbox method testLockoutAsGlobalAdmin.
@Test
public void testLockoutAsGlobalAdmin() throws Exception {
Mailbox mbox = TestUtil.getMailbox(MY_USER);
TestUtil.addMessage(mbox, "test");
TestUtil.waitForMessage(TestUtil.getZMailbox(MY_USER), "test");
LockoutMailboxRequest req = LockoutMailboxRequest.create(AccountNameSelector.fromName(MY_USER));
req.setOperation(AdminConstants.A_START);
try {
LockoutMailboxResponse resp = adminSoapProv.invokeJaxb(req);
assertNotNull("LockoutMailboxResponse should not be null", resp);
} catch (SoapFaultException e) {
fail("should not be getting an exception");
}
req = LockoutMailboxRequest.create(AccountNameSelector.fromName(OFFLIMITS_NON_EXISTING_USER));
req.setOperation(AdminConstants.A_START);
try {
adminSoapProv.invokeJaxb(req);
fail("should have caught an exception");
} catch (SoapFaultException e) {
assertEquals("should be getting 'no such account' response", AccountServiceException.NO_SUCH_ACCOUNT, e.getCode());
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestMaxMessageSize method testMaxMessageSizeAboveThreshold.
@Test
public void testMaxMessageSizeAboveThreshold() throws Exception {
setMaxMessageSize(TEST_MAX_MESSAGE_SIZE);
Map<String, byte[]> attachments = new HashMap<String, byte[]>();
attachments.put("file1.exe", new byte[800]);
attachments.put("file2.exe", new byte[700]);
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String aid = mbox.uploadAttachments(attachments, 5000);
try {
TestUtil.sendMessage(mbox, USER_NAME, NAME_PREFIX, "Message size above threshold", aid);
Assert.fail("sendMessage() should not have succeeded");
} catch (SoapFaultException e) {
// Message send was not allowed, as expected.
validateMessageTooBigFault(e);
}
}
use of com.zimbra.common.soap.SoapFaultException 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.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestSoap method testAccountGetInfoRequest.
/**
* Tests the AccountService version of GetInfoRequest (see bug 30010).
*/
@Test
public void testAccountGetInfoRequest() throws Exception {
SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getSoapUrl());
Element request = Element.create(transport.getRequestProtocol(), AccountConstants.GET_VERSION_INFO_REQUEST);
// Test with version exposed
TestUtil.setServerAttr(Provisioning.A_zimbraSoapExposeVersion, LdapConstants.LDAP_TRUE);
Element response = transport.invoke(request);
validateSoapVersionResponse(response);
// Test with version not exposed
TestUtil.setServerAttr(Provisioning.A_zimbraSoapExposeVersion, LdapConstants.LDAP_FALSE);
request = Element.create(transport.getRequestProtocol(), AccountConstants.GET_VERSION_INFO_REQUEST);
try {
response = transport.invoke(request);
Assert.fail("GetInfoRequest should have failed");
} catch (SoapFaultException e) {
Assert.assertEquals(ServiceException.PERM_DENIED, e.getCode());
}
}
Aggregations