use of com.zimbra.soap.admin.message.LockoutMailboxRequest 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());
}
}
use of com.zimbra.soap.admin.message.LockoutMailboxRequest 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.soap.admin.message.LockoutMailboxRequest in project zm-mailbox by Zimbra.
the class TestLockoutMailbox method testLockout.
@Test
public void testLockout() 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()));
LockoutMailboxRequest req = LockoutMailboxRequest.create(AccountNameSelector.fromName(MY_USER));
req.setOperation(AdminConstants.A_START);
LockoutMailboxResponse resp = adminSoapProv.invokeJaxb(req);
assertNotNull("LockoutMailboxRequest return null response", resp);
assertTrue("mailbox should be locked now", MailboxManager.getInstance().isMailboxLockedOut(mbox.getAccountId()));
}
use of com.zimbra.soap.admin.message.LockoutMailboxRequest 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.soap.admin.message.LockoutMailboxRequest in project zm-mailbox by Zimbra.
the class ProvUtil method sendMailboxLockoutRequest.
private void sendMailboxLockoutRequest(String acctName, String server, String operation) throws ServiceException, IOException, HttpException {
LockoutMailboxRequest req = LockoutMailboxRequest.create(AccountNameSelector.fromName(acctName));
req.setOperation(operation);
String url = URLUtil.getAdminURL(server);
ZAuthToken token = ((SoapProvisioning) prov).getAuthToken();
SoapHttpTransport transport = new SoapHttpTransport(url);
transport.setAuthToken(token);
transport.invokeWithoutSession(JaxbUtil.jaxbToElement(req));
}
Aggregations