Search in sources :

Example 21 with SoapFaultException

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());
    }
}
Also used : LockoutMailbox(com.zimbra.cs.service.admin.LockoutMailbox) Mailbox(com.zimbra.cs.mailbox.Mailbox) AdminRight(com.zimbra.cs.account.accesscontrol.AdminRight) ArrayList(java.util.ArrayList) AdminDocumentHandler(com.zimbra.cs.service.admin.AdminDocumentHandler) LockoutMailbox(com.zimbra.cs.service.admin.LockoutMailbox) SoapFaultException(com.zimbra.common.soap.SoapFaultException) LockoutMailboxRequest(com.zimbra.soap.admin.message.LockoutMailboxRequest) Test(org.junit.Test)

Example 22 with SoapFaultException

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());
    }
}
Also used : LockoutMailboxResponse(com.zimbra.soap.admin.message.LockoutMailboxResponse) LockoutMailbox(com.zimbra.cs.service.admin.LockoutMailbox) Mailbox(com.zimbra.cs.mailbox.Mailbox) SoapFaultException(com.zimbra.common.soap.SoapFaultException) LockoutMailboxRequest(com.zimbra.soap.admin.message.LockoutMailboxRequest) Test(org.junit.Test)

Example 23 with SoapFaultException

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);
    }
}
Also used : ZMailbox(com.zimbra.client.ZMailbox) HashMap(java.util.HashMap) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 24 with SoapFaultException

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);
    }
}
Also used : ZMessage(com.zimbra.client.ZMessage) ZOutgoingMessage(com.zimbra.client.ZMailbox.ZOutgoingMessage) ZMailbox(com.zimbra.client.ZMailbox) ZEmailAddress(com.zimbra.client.ZEmailAddress) AttachedMessagePart(com.zimbra.client.ZMailbox.ZOutgoingMessage.AttachedMessagePart) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 25 with SoapFaultException

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());
    }
}
Also used : Element(com.zimbra.common.soap.Element) SoapHttpTransport(com.zimbra.common.soap.SoapHttpTransport) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test) SoapTest(com.zimbra.qa.unittest.prov.soap.SoapTest)

Aggregations

SoapFaultException (com.zimbra.common.soap.SoapFaultException)81 Test (org.junit.Test)62 Element (com.zimbra.common.soap.Element)32 Account (com.zimbra.cs.account.Account)23 ServiceException (com.zimbra.common.service.ServiceException)15 SoapTransport (com.zimbra.common.soap.SoapTransport)15 Attr (com.zimbra.soap.admin.type.Attr)15 SoapHttpTransport (com.zimbra.common.soap.SoapHttpTransport)14 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)14 ZMailbox (com.zimbra.client.ZMailbox)12 SoapProtocol (com.zimbra.common.soap.SoapProtocol)11 ArrayList (java.util.ArrayList)11 DeployZimletRequest (com.zimbra.soap.admin.message.DeployZimletRequest)10 CreateSignatureRequest (com.zimbra.soap.account.message.CreateSignatureRequest)9 Signature (com.zimbra.soap.account.type.Signature)9 AttachmentIdAttrib (com.zimbra.soap.admin.type.AttachmentIdAttrib)9 AdminDocumentHandler (com.zimbra.cs.service.admin.AdminDocumentHandler)8 Mailbox (com.zimbra.cs.mailbox.Mailbox)6 Provisioning (com.zimbra.cs.account.Provisioning)5 AdminRight (com.zimbra.cs.account.accesscontrol.AdminRight)5