Search in sources :

Example 1 with ModifyCalendarResourceRequest

use of com.zimbra.soap.admin.message.ModifyCalendarResourceRequest in project zm-mailbox by Zimbra.

the class TestServerEnumeration method testModifyCalresSufficientPermissions.

@Test
public void testModifyCalresSufficientPermissions() throws Exception {
    List<AdminRight> relatedRights = new ArrayList<AdminRight>();
    List<String> notes = new ArrayList<String>();
    AdminDocumentHandler handler = new ModifyCalendarResource();
    handler.docRights(relatedRights, notes);
    createDelegatedAdmin(relatedRights);
    grantRightToAdmin(adminSoapProv, com.zimbra.soap.type.TargetType.fromString(com.zimbra.cs.account.accesscontrol.TargetType.calresource.toString()), MY_CALRES, DELEGATED_ADMIN_NAME, Admin.R_modifyCalendarResource.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);
    ModifyCalendarResourceRequest req = new ModifyCalendarResourceRequest(myCalRes.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 : ModifyCalendarResourceRequest(com.zimbra.soap.admin.message.ModifyCalendarResourceRequest) AdminRight(com.zimbra.cs.account.accesscontrol.AdminRight) ModifyCalendarResource(com.zimbra.cs.service.admin.ModifyCalendarResource) 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 ModifyCalendarResourceRequest

use of com.zimbra.soap.admin.message.ModifyCalendarResourceRequest in project zm-mailbox by Zimbra.

the class ModifyCalendarResource method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    ModifyCalendarResourceRequest req = JaxbUtil.elementToJaxb(request);
    String id = req.getId();
    if (null == id) {
        throw ServiceException.INVALID_REQUEST("missing required attribute: " + AdminConstants.E_ID, null);
    }
    Map<String, Object> attrs = req.getAttrsAsOldMultimap();
    CalendarResource resource = prov.get(CalendarResourceBy.id, id);
    defendAgainstCalResourceHarvesting(resource, CalendarResourceBy.id, id, zsc, attrs);
    String newServer = ModifyAccount.getStringAttrNewValue(Provisioning.A_zimbraMailHost, attrs);
    if (newServer != null) {
        defendAgainstServerNameHarvesting(Provisioning.getInstance().getServerByName(newServer), Key.ServerBy.name, newServer, zsc, Admin.R_listServer);
    }
    // pass in true to checkImmutable
    prov.modifyAttrs(resource, attrs, true);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "ModifyCalendarResource", "name", resource.getName() }, attrs));
    Element response = zsc.createElement(AdminConstants.MODIFY_CALENDAR_RESOURCE_RESPONSE);
    ToXML.encodeCalendarResource(response, resource, true);
    return response;
}
Also used : ModifyCalendarResourceRequest(com.zimbra.soap.admin.message.ModifyCalendarResourceRequest) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) CalendarResource(com.zimbra.cs.account.CalendarResource) Provisioning(com.zimbra.cs.account.Provisioning)

Example 3 with ModifyCalendarResourceRequest

use of com.zimbra.soap.admin.message.ModifyCalendarResourceRequest in project zm-mailbox by Zimbra.

the class TestDomainAdmin method testModifyCalendarResourceInDiffDomain.

@Test
public void testModifyCalendarResourceInDiffDomain() throws Exception {
    String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
    SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
    List<Attr> attrs = Lists.newArrayList();
    attrs.add(new Attr(Provisioning.A_displayName, "testModifyCalendarResourceInDiffDomain Room 101"));
    attrs.add(new Attr(Provisioning.A_description, "Room 101 for 50 seats"));
    attrs.add(new Attr(Provisioning.A_zimbraCalResType, "Location"));
    attrs.add(new Attr(Provisioning.A_zimbraCalResAutoAcceptDecline, "TRUE"));
    attrs.add(new Attr(Provisioning.A_zimbraCalResAutoDeclineIfBusy, "TRUE"));
    CreateCalendarResourceResponse caResp;
    caResp = adminSoapProv.invokeJaxb(new CreateCalendarResourceRequest(DIFF_CALRES, TestUtil.DEFAULT_PASSWORD, attrs));
    assertNotNull("CreateCalendarResourceResponse for " + DIFF_CALRES + " as FULL ADMIN", caResp);
    String acctId = caResp.getCalResource().getId();
    ModifyCalendarResourceRequest modAcctReq = new ModifyCalendarResourceRequest(acctId);
    modAcctReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
    try {
        domAdminSoapProv.invokeJaxb(modAcctReq);
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
    try {
        domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
    DeleteCalendarResourceRequest delAcctReq = new DeleteCalendarResourceRequest(acctId);
    DeleteCalendarResourceResponse delAcctResp = adminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
    assertNotNull("DeleteCalendarResourceResponse for " + DIFF_CALRES + " as ADMIN specifying target acct", delAcctResp);
    try {
        domAdminSoapProv.invokeJaxb(modAcctReq);
        fail("ModifyCalendarResourceRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        // Get this instead of "no such account: " because modify by ID (not name) and for domain admin
        // cannot know whether that ID was for a domain we administered or not.
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
    try {
        domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
        fail("ModifyCalendarResourceRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
}
Also used : ModifyCalendarResourceRequest(com.zimbra.soap.admin.message.ModifyCalendarResourceRequest) DeleteCalendarResourceRequest(com.zimbra.soap.admin.message.DeleteCalendarResourceRequest) DeleteCalendarResourceResponse(com.zimbra.soap.admin.message.DeleteCalendarResourceResponse) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) CreateCalendarResourceResponse(com.zimbra.soap.admin.message.CreateCalendarResourceResponse) Attr(com.zimbra.soap.admin.type.Attr) CreateCalendarResourceRequest(com.zimbra.soap.admin.message.CreateCalendarResourceRequest) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 4 with ModifyCalendarResourceRequest

use of com.zimbra.soap.admin.message.ModifyCalendarResourceRequest in project zm-mailbox by Zimbra.

the class TestDomainAdmin method testModifyCalendarResourceInDomAdminDomain.

@Test
public void testModifyCalendarResourceInDomAdminDomain() throws Exception {
    String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
    SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
    List<Attr> attrs = Lists.newArrayList();
    attrs.add(new Attr(Provisioning.A_displayName, "testModifyCalendarResourceInDomAdminDomain Room 101"));
    attrs.add(new Attr(Provisioning.A_description, "Room 101 for 50 seats"));
    attrs.add(new Attr(Provisioning.A_zimbraCalResType, "Location"));
    attrs.add(new Attr(Provisioning.A_zimbraCalResAutoAcceptDecline, "TRUE"));
    attrs.add(new Attr(Provisioning.A_zimbraCalResAutoDeclineIfBusy, "TRUE"));
    CreateCalendarResourceResponse caResp;
    caResp = domAdminSoapProv.invokeJaxb(new CreateCalendarResourceRequest(TARGET_CALRES, TestUtil.DEFAULT_PASSWORD, attrs));
    assertNotNull("CreateCalendarResourceResponse for " + TARGET_CALRES + " simple as domAdmin", caResp);
    String acctId = caResp.getCalResource().getId();
    ModifyCalendarResourceRequest modAcctReq;
    ModifyCalendarResourceResponse modAcctResp;
    modAcctReq = new ModifyCalendarResourceRequest(null);
    modAcctReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
    try {
        modAcctResp = domAdminSoapProv.invokeJaxb(modAcctReq);
        fail("ModifyCalendarResourceRequest succeeded without 'id'!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "invalid request: missing required attribute: id");
    }
    modAcctReq = new ModifyCalendarResourceRequest(acctId);
    modAcctReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
    modAcctResp = domAdminSoapProv.invokeJaxb(modAcctReq);
    assertNotNull("ModifyCalendarResourceResponse for " + TARGET_CALRES2 + " simple as domAdmin", modAcctResp);
    modAcctReq = new ModifyCalendarResourceRequest(acctId);
    modAcctReq.addAttr(new Attr(Provisioning.A_description, "another dummy description"));
    modAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
    assertNotNull("ModifyCalendarResourceResponse for " + TARGET_CALRES2 + " as domAdmin specifying target acct", modAcctResp);
    DeleteCalendarResourceRequest delAcctReq = new DeleteCalendarResourceRequest(acctId);
    DeleteCalendarResourceResponse delAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
    assertNotNull("DeleteCalendarResourceResponse for " + TARGET_CALRES2 + " as domAdmin specifying target acct", delAcctResp);
    try {
        modAcctResp = domAdminSoapProv.invokeJaxb(modAcctReq);
        fail("ModifyCalendarResourceRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        // Get this instead of "no such calendar resource: " because modify by ID (not name) and for domain admin
        // cannot know whether that ID was for a domain we administered or not.
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
    try {
        modAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
        fail("ModifyCalendarResourceRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account");
    }
    // as full admin
    try {
        modAcctResp = adminSoapProv.invokeJaxb(modAcctReq);
        fail("ModifyCalendarResourceRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        // Full admin gets "no such calendar resource: " instead of "permission denied"
        checkSoapReason(sfe, "no such calendar resource: ");
    }
}
Also used : ModifyCalendarResourceRequest(com.zimbra.soap.admin.message.ModifyCalendarResourceRequest) DeleteCalendarResourceRequest(com.zimbra.soap.admin.message.DeleteCalendarResourceRequest) DeleteCalendarResourceResponse(com.zimbra.soap.admin.message.DeleteCalendarResourceResponse) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) CreateCalendarResourceResponse(com.zimbra.soap.admin.message.CreateCalendarResourceResponse) ModifyCalendarResourceResponse(com.zimbra.soap.admin.message.ModifyCalendarResourceResponse) Attr(com.zimbra.soap.admin.type.Attr) CreateCalendarResourceRequest(com.zimbra.soap.admin.message.CreateCalendarResourceRequest) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 5 with ModifyCalendarResourceRequest

use of com.zimbra.soap.admin.message.ModifyCalendarResourceRequest in project zm-mailbox by Zimbra.

the class TestServerEnumeration method testModifyCalres.

@Test
public void testModifyCalres() throws Exception {
    List<AdminRight> relatedRights = new ArrayList<AdminRight>();
    List<String> notes = new ArrayList<String>();
    AdminDocumentHandler handler = new ModifyCalendarResource();
    handler.docRights(relatedRights, notes);
    createDelegatedAdmin(relatedRights);
    grantRightToAdmin(adminSoapProv, com.zimbra.soap.type.TargetType.fromString(com.zimbra.cs.account.accesscontrol.TargetType.calresource.toString()), MY_CALRES, DELEGATED_ADMIN_NAME, Admin.R_modifyCalendarResource.getName());
    adminSoapProv.flushCache(CacheEntryType.acl, null);
    ModifyCalendarResourceRequest req = new ModifyCalendarResourceRequest(myCalRes.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 : ModifyCalendarResourceRequest(com.zimbra.soap.admin.message.ModifyCalendarResourceRequest) AdminRight(com.zimbra.cs.account.accesscontrol.AdminRight) ModifyCalendarResource(com.zimbra.cs.service.admin.ModifyCalendarResource) 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

ModifyCalendarResourceRequest (com.zimbra.soap.admin.message.ModifyCalendarResourceRequest)6 SoapFaultException (com.zimbra.common.soap.SoapFaultException)5 Attr (com.zimbra.soap.admin.type.Attr)5 Test (org.junit.Test)5 AdminRight (com.zimbra.cs.account.accesscontrol.AdminRight)2 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)2 AdminDocumentHandler (com.zimbra.cs.service.admin.AdminDocumentHandler)2 ModifyCalendarResource (com.zimbra.cs.service.admin.ModifyCalendarResource)2 CreateCalendarResourceRequest (com.zimbra.soap.admin.message.CreateCalendarResourceRequest)2 CreateCalendarResourceResponse (com.zimbra.soap.admin.message.CreateCalendarResourceResponse)2 DeleteCalendarResourceRequest (com.zimbra.soap.admin.message.DeleteCalendarResourceRequest)2 DeleteCalendarResourceResponse (com.zimbra.soap.admin.message.DeleteCalendarResourceResponse)2 ArrayList (java.util.ArrayList)2 Element (com.zimbra.common.soap.Element)1 CalendarResource (com.zimbra.cs.account.CalendarResource)1 Provisioning (com.zimbra.cs.account.Provisioning)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 ModifyCalendarResourceResponse (com.zimbra.soap.admin.message.ModifyCalendarResourceResponse)1