Search in sources :

Example 1 with LockoutMailbox

use of com.zimbra.cs.service.admin.LockoutMailbox 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 2 with LockoutMailbox

use of com.zimbra.cs.service.admin.LockoutMailbox in project zm-mailbox by Zimbra.

the class TestLockoutMailbox method testLockoutSufficientPermissions.

@Test
public void testLockoutSufficientPermissions() 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(MY_USER));
    req.setOperation(AdminConstants.A_START);
    try {
        LockoutMailboxResponse resp = delegatedSoapProv.invokeJaxb(req);
        assertNotNull("LockoutMailboxResponse should not be null", resp);
    } catch (SoapFaultException e) {
        fail("should not be getting an exception");
    }
    req = LockoutMailboxRequest.create(AccountNameSelector.fromName(MY_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 '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) 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 3 with LockoutMailbox

use of com.zimbra.cs.service.admin.LockoutMailbox in project zm-mailbox by Zimbra.

the class TestLockoutMailbox method testUnlock.

@Test
public void testUnlock() throws Exception {
    Mailbox mbox = TestUtil.getMailbox(MY_USER);
    TestUtil.addMessage(mbox, "test");
    TestUtil.waitForMessage(TestUtil.getZMailbox(MY_USER), "test");
    assertFalse("mailbox should not be locked yet", MailboxManager.getInstance().isMailboxLockedOut(mbox.getAccountId()));
    MailboxManager.getInstance().lockoutMailbox(mbox.getAccountId());
    assertTrue("mailbox should be locked now", MailboxManager.getInstance().isMailboxLockedOut(mbox.getAccountId()));
    LockoutMailboxRequest req = LockoutMailboxRequest.create(AccountNameSelector.fromName(MY_USER));
    req.setOperation(AdminConstants.A_END);
    LockoutMailboxResponse resp = adminSoapProv.invokeJaxb(req);
    assertNotNull("LockoutMailboxRequest return null response", resp);
    assertFalse("mailbox should not be locked any more", MailboxManager.getInstance().isMailboxLockedOut(mbox.getAccountId()));
}
Also used : LockoutMailboxResponse(com.zimbra.soap.admin.message.LockoutMailboxResponse) LockoutMailbox(com.zimbra.cs.service.admin.LockoutMailbox) Mailbox(com.zimbra.cs.mailbox.Mailbox) LockoutMailboxRequest(com.zimbra.soap.admin.message.LockoutMailboxRequest) Test(org.junit.Test)

Aggregations

Mailbox (com.zimbra.cs.mailbox.Mailbox)3 LockoutMailbox (com.zimbra.cs.service.admin.LockoutMailbox)3 LockoutMailboxRequest (com.zimbra.soap.admin.message.LockoutMailboxRequest)3 Test (org.junit.Test)3 SoapFaultException (com.zimbra.common.soap.SoapFaultException)2 AdminRight (com.zimbra.cs.account.accesscontrol.AdminRight)2 AdminDocumentHandler (com.zimbra.cs.service.admin.AdminDocumentHandler)2 LockoutMailboxResponse (com.zimbra.soap.admin.message.LockoutMailboxResponse)2 ArrayList (java.util.ArrayList)2