Search in sources :

Example 66 with SoapFaultException

use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.

the class TestCountObjects method testOnlyRelated.

@Test
public void testOnlyRelated() throws Exception {
    try {
        SoapTransport transport = SoapTest.authAdmin(DELEGATED_ADMIN_USER_EMAIL, PASSWORD);
        // count only related domains
        try {
            CountObjectsRequest req = new CountObjectsRequest(CountObjectsType.domain);
            req.setOnlyRelated(true);
            CountObjectsResponse resp = SoapTest.invokeJaxb(transport, req);
            assertTrue("should have exactly one account", resp.getNum() == 1);
            assertEquals("object type in response should be 'domain'", "domain", resp.getType());
        } catch (SoapFaultException e) {
            fail("should not be fail");
        }
        // count domain without necessary right
        try {
            CountObjectsRequest req = new CountObjectsRequest(CountObjectsType.domain);
            CountObjectsResponse resp = SoapTest.invokeJaxb(transport, req);
            fail("should not be able to count domains");
        } catch (SoapFaultException e) {
            assertEquals(ServiceException.PERM_DENIED, e.getCode());
        }
        // count domain with countDomain right
        try {
            mProv.grantRight(TargetType.global.getCode(), null, null, com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), GranteeBy.name, DELEGATED_ADMIN_USER_EMAIL, null, RightConsts.RT_countDomain, null);
            CountObjectsRequest req = new CountObjectsRequest(CountObjectsType.domain);
            CountObjectsResponse resp = SoapTest.invokeJaxb(transport, req);
            assertTrue("should have at least 2 domain", resp.getNum() > 1);
            assertEquals("object type in response should be 'domain'", "domain", resp.getType());
        } catch (SoapFaultException e) {
            fail("should not be fail");
        }
    } catch (Exception e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : CountObjectsRequest(com.zimbra.soap.admin.message.CountObjectsRequest) SoapTransport(com.zimbra.common.soap.SoapTransport) SoapFaultException(com.zimbra.common.soap.SoapFaultException) SoapFaultException(com.zimbra.common.soap.SoapFaultException) ServiceException(com.zimbra.common.service.ServiceException) CountObjectsResponse(com.zimbra.soap.admin.message.CountObjectsResponse) Test(org.junit.Test) SoapTest(com.zimbra.qa.unittest.prov.soap.SoapTest)

Example 67 with SoapFaultException

use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.

the class TestAuthentication method testAccessInactiveAccount.

/**
 * Attempts to access a deleted account and confirms that the attempt
 * fails with an auth error.
 */
public void testAccessInactiveAccount() throws Exception {
    // Log in and check the inbox
    LmcSession session = TestUtil.getSoapSession(USER_NAME);
    LmcSearchRequest req = new LmcSearchRequest();
    req.setQuery("in:inbox");
    req.setSession(session);
    req.invoke(TestUtil.getSoapUrl());
    // Deactivate the account
    Account account = getAccount();
    mProv.modifyAccountStatus(account, Provisioning.ACCOUNT_STATUS_MAINTENANCE);
    // Submit another request and make sure it fails with an auth error
    try {
        req.invoke(TestUtil.getSoapUrl());
    } catch (SoapFaultException ex) {
        String substring = "auth credentials have expired";
        String msg = String.format("Error message '%s' does not contain '%s'", ex.getMessage(), substring);
        assertTrue(msg, ex.getMessage().contains(substring));
    }
}
Also used : LmcSearchRequest(com.zimbra.cs.client.soap.LmcSearchRequest) Account(com.zimbra.cs.account.Account) LmcSession(com.zimbra.cs.client.LmcSession) SoapFaultException(com.zimbra.common.soap.SoapFaultException)

Example 68 with SoapFaultException

use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.

the class TestAuthentication method testAccessDeletedAccount.

/**
 * Attempts to access a deleted account and confirms that the attempt
 * fails with an auth error.
 */
public void testAccessDeletedAccount() throws Exception {
    // Log in and check the inbox
    LmcSession session = TestUtil.getSoapSession(USER_NAME);
    LmcSearchRequest req = new LmcSearchRequest();
    req.setQuery("in:inbox");
    req.setSession(session);
    req.invoke(TestUtil.getSoapUrl());
    // Delete the account
    Account account = getAccount();
    assertNotNull("Account does not exist", account);
    mProv.deleteAccount(account.getId());
    // Submit another request and make sure it fails with an auth error
    try {
        req.invoke(TestUtil.getSoapUrl());
    } catch (SoapFaultException ex) {
        assertTrue("Unexpected error: " + ex.getMessage(), ex.getMessage().indexOf("auth credentials have expired") >= 0);
    }
}
Also used : LmcSearchRequest(com.zimbra.cs.client.soap.LmcSearchRequest) Account(com.zimbra.cs.account.Account) LmcSession(com.zimbra.cs.client.LmcSession) SoapFaultException(com.zimbra.common.soap.SoapFaultException)

Example 69 with SoapFaultException

use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.

the class TestSendAndReceive method testDomainSmtpSettings.

/**
 * Confirms that domain SMTP settings override server settings (bug 28442).
 */
@Test
public void testDomainSmtpSettings() throws Exception {
    TestUtil.createAccount(USER_NAME);
    // Send a message using the user's default SMTP settings.
    ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
    String subject = NAME_PREFIX + " testDomainSmtpSettings 1";
    TestUtil.sendMessage(mbox, USER_NAME, subject);
    TestUtil.waitForMessage(mbox, "in:inbox subject:\"" + subject + "\"");
    // Set domain SMTP port to a bogus value and confirm that the send fails.
    TestUtil.setDomainAttr(USER_NAME, Provisioning.A_zimbraSmtpPort, "35");
    subject = NAME_PREFIX + " testDomainSmtpSettings 2";
    boolean sendFailed = false;
    try {
        TestUtil.sendMessage(mbox, USER_NAME, subject);
    } catch (SoapFaultException e) {
        Assert.assertEquals(MailServiceException.TRY_AGAIN, e.getCode());
        sendFailed = true;
    }
    Assert.assertTrue("Message send should have failed", sendFailed);
}
Also used : ZMailbox(com.zimbra.client.ZMailbox) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 70 with SoapFaultException

use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.

the class TestSoap method testSoapRequestMaxSize.

@Test
public void testSoapRequestMaxSize() throws Exception {
    StringBuilder messageBody = new StringBuilder();
    for (int i = 1; i <= 100; i++) {
        messageBody.append("Morey Amsterdam was a great man.  Morey Amsterdam was not a sandwich.\r\n");
    }
    setSoapRequestMaxSize(100000);
    ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
    TestUtil.sendMessage(mbox, USER_NAME, NAME_PREFIX + " 1", messageBody.toString());
    setSoapRequestMaxSize(1000);
    try {
        TestUtil.sendMessage(mbox, USER_NAME, NAME_PREFIX + " 2", messageBody.toString());
        Assert.fail("SOAP request should not have succeeded.");
    } catch (SoapFaultException e) {
        Assert.assertTrue("Unexpected error: " + e.toString(), e.toString().contains("bytes set for zimbraSoapRequestMaxSize"));
    }
}
Also used : ZMailbox(com.zimbra.client.ZMailbox) 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