Search in sources :

Example 1 with ModifyAccount

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

the class TestServerEnumeration method testModifyAccount.

@Test
public void testModifyAccount() throws Exception {
    List<AdminRight> relatedRights = new ArrayList<AdminRight>();
    List<String> notes = new ArrayList<String>();
    AdminDocumentHandler handler = new ModifyAccount();
    handler.docRights(relatedRights, notes);
    createDelegatedAdmin(relatedRights);
    grantRightToAdmin(adminSoapProv, com.zimbra.soap.type.TargetType.fromString(com.zimbra.cs.account.accesscontrol.TargetType.account.toString()), MY_USER, DELEGATED_ADMIN_NAME, Admin.R_modifyAccount.getName());
    adminSoapProv.flushCache(CacheEntryType.acl, null);
    ModifyAccountRequest req = new ModifyAccountRequest(myUser.getId());
    req.addAttr(new Attr(Provisioning.A_zimbraMailHost, NON_EXISTING_SERVER));
    req.addAttr(new Attr(Provisioning.A_description, "test description"));
    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 : ModifyAccount(com.zimbra.cs.service.admin.ModifyAccount) AdminRight(com.zimbra.cs.account.accesscontrol.AdminRight) ModifyAccountRequest(com.zimbra.soap.admin.message.ModifyAccountRequest) ArrayList(java.util.ArrayList) AdminDocumentHandler(com.zimbra.cs.service.admin.AdminDocumentHandler) Attr(com.zimbra.soap.admin.type.Attr) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 2 with ModifyAccount

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

the class TestServerEnumeration method testModifyAccountSufficientPermissions.

@Test
public void testModifyAccountSufficientPermissions() throws Exception {
    List<AdminRight> relatedRights = new ArrayList<AdminRight>();
    List<String> notes = new ArrayList<String>();
    AdminDocumentHandler handler = new ModifyAccount();
    handler.docRights(relatedRights, notes);
    createDelegatedAdmin(relatedRights);
    grantRightToAdmin(adminSoapProv, com.zimbra.soap.type.TargetType.fromString(com.zimbra.cs.account.accesscontrol.TargetType.account.toString()), MY_USER, DELEGATED_ADMIN_NAME, Admin.R_modifyAccount.getName());
    grantRightToAdmin(adminSoapProv, com.zimbra.soap.type.TargetType.fromString(com.zimbra.cs.account.accesscontrol.TargetType.global.toString()), null, DELEGATED_ADMIN_NAME, Admin.R_listServer.getName());
    adminSoapProv.flushCache(CacheEntryType.acl, null);
    ModifyAccountRequest req = new ModifyAccountRequest(myUser.getId());
    req.addAttr(new Attr(Provisioning.A_zimbraMailHost, NON_EXISTING_SERVER));
    req.addAttr(new Attr(Provisioning.A_description, "test description"));
    try {
        delegatedSoapProv.invokeJaxb(req);
        fail("should have caught an exception");
    } catch (SoapFaultException e) {
        assertEquals("should be getting 'no such server' response", AccountServiceException.NO_SUCH_SERVER, e.getCode());
    }
}
Also used : ModifyAccount(com.zimbra.cs.service.admin.ModifyAccount) AdminRight(com.zimbra.cs.account.accesscontrol.AdminRight) ModifyAccountRequest(com.zimbra.soap.admin.message.ModifyAccountRequest) ArrayList(java.util.ArrayList) AdminDocumentHandler(com.zimbra.cs.service.admin.AdminDocumentHandler) Attr(com.zimbra.soap.admin.type.Attr) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Aggregations

SoapFaultException (com.zimbra.common.soap.SoapFaultException)2 AdminRight (com.zimbra.cs.account.accesscontrol.AdminRight)2 AdminDocumentHandler (com.zimbra.cs.service.admin.AdminDocumentHandler)2 ModifyAccount (com.zimbra.cs.service.admin.ModifyAccount)2 ModifyAccountRequest (com.zimbra.soap.admin.message.ModifyAccountRequest)2 Attr (com.zimbra.soap.admin.type.Attr)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2