Search in sources :

Example 1 with LmcSearchRequest

use of com.zimbra.cs.client.soap.LmcSearchRequest 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 2 with LmcSearchRequest

use of com.zimbra.cs.client.soap.LmcSearchRequest 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)

Aggregations

SoapFaultException (com.zimbra.common.soap.SoapFaultException)2 Account (com.zimbra.cs.account.Account)2 LmcSession (com.zimbra.cs.client.LmcSession)2 LmcSearchRequest (com.zimbra.cs.client.soap.LmcSearchRequest)2