Search in sources :

Example 1 with CreateCalendarResourceRequest

use of com.zimbra.soap.admin.message.CreateCalendarResourceRequest 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 2 with CreateCalendarResourceRequest

use of com.zimbra.soap.admin.message.CreateCalendarResourceRequest 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 3 with CreateCalendarResourceRequest

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

the class CreateCalendarResource method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    CreateCalendarResourceRequest req = JaxbUtil.elementToJaxb(request);
    String name = req.getName().toLowerCase();
    checkDomainRightByEmail(zsc, name, Admin.R_createCalendarResource);
    Map<String, Object> attrs = req.getAttrsAsOldMultimap(true);
    checkSetAttrsOnCreate(zsc, TargetType.calresource, name, attrs);
    String password = req.getPassword();
    CalendarResource resource = prov.createCalendarResource(name, password, attrs);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "CreateCalendarResource", "name", name }, attrs));
    Element response = zsc.createElement(AdminConstants.CREATE_CALENDAR_RESOURCE_RESPONSE);
    ToXML.encodeCalendarResource(response, resource, true);
    return response;
}
Also used : ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) CalendarResource(com.zimbra.cs.account.CalendarResource) Provisioning(com.zimbra.cs.account.Provisioning) CreateCalendarResourceRequest(com.zimbra.soap.admin.message.CreateCalendarResourceRequest)

Example 4 with CreateCalendarResourceRequest

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

the class TestDomainAdmin method testGetCalendarResourceInDiffDomain.

@Test
public void testGetCalendarResourceInDiffDomain() 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, "testGetCalendarResourceInDiffDomain 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;
    try {
        caResp = domAdminSoapProv.invokeJaxb(new CreateCalendarResourceRequest(DIFF_CALRES, TestUtil.DEFAULT_PASSWORD, attrs));
        fail("CreateCalendarResourceRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: need right: createCalendarResource for domain");
    }
    caResp = adminSoapProv.invokeJaxb(new CreateCalendarResourceRequest(DIFF_CALRES, TestUtil.DEFAULT_PASSWORD, attrs));
    assertNotNull("CreateCalendarResourceResponse for " + DIFF_CALRES + " simple as domAdmin", caResp);
    String acctId = caResp.getCalResource().getId();
    GetCalendarResourceRequest getAcctReq = new GetCalendarResourceRequest(CalendarResourceSelector.fromName(DIFF_CALRES), true);
    try {
        domAdminSoapProv.invokeJaxb(getAcctReq);
        fail("GetCalendarResourceRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
    try {
        domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
        fail("GetCalendarResourceRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
    // try non-existent
    getAcctReq = new GetCalendarResourceRequest(CalendarResourceSelector.fromName(DIFF_CALRES2), true);
    try {
        domAdminSoapProv.invokeJaxb(getAcctReq);
        fail("GetCalendarResourceRequest succeeded for non-existent account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
    try {
        domAdminSoapProv.invokeJaxb(new RenameCalendarResourceRequest(acctId, TARGET_CALRES_RENAMED));
        fail("RenameCalendarResourceRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
    try {
        domAdminSoapProv.invokeJaxb(new DeleteCalendarResourceRequest(acctId));
        fail("DeleteCalendarResourceRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
}
Also used : DeleteCalendarResourceRequest(com.zimbra.soap.admin.message.DeleteCalendarResourceRequest) GetCalendarResourceRequest(com.zimbra.soap.admin.message.GetCalendarResourceRequest) RenameCalendarResourceRequest(com.zimbra.soap.admin.message.RenameCalendarResourceRequest) 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 5 with CreateCalendarResourceRequest

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

the class TestDomainAdmin method testGetCalendarResourceInDomAdminDomain.

@Test
public void testGetCalendarResourceInDomAdminDomain() 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, "testGetCalendarResourceInDomAdminDomain 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();
    GetCalendarResourceResponse getAcctResp = domAdminSoapProv.invokeJaxb(new GetCalendarResourceRequest(CalendarResourceSelector.fromName(TARGET_CALRES), true));
    assertNotNull("GetCalendarResourceResponse for " + TARGET_CALRES + " simple as domAdmin", getAcctResp);
    getAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(new GetCalendarResourceRequest(CalendarResourceSelector.fromName(TARGET_CALRES), true), acctId);
    assertNotNull("GetCalendarResourceResponse for " + TARGET_CALRES + " as domAdmin specifying target acct", getAcctResp);
    RenameCalendarResourceResponse renAResp;
    renAResp = domAdminSoapProv.invokeJaxb(new RenameCalendarResourceRequest(acctId, TARGET_CALRES_RENAMED));
    assertNotNull("RenameCalendarResourceResponse for " + TARGET_CALRES + " simple as domAdmin", renAResp);
    renAResp = domAdminSoapProv.invokeJaxb(new RenameCalendarResourceRequest(acctId, TARGET_CALRES));
    assertNotNull("RenameCalendarResourceResponse for " + TARGET_CALRES + " as domAdmin specifying target acct", renAResp);
    DeleteCalendarResourceRequest delAcctReq;
    DeleteCalendarResourceResponse delAcctResp;
    delAcctReq = new DeleteCalendarResourceRequest(null);
    try {
        domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
        fail("DeleteCalendarResouceRequest succeeded in spite of having no 'id' specified!!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "invalid request: missing required attribute: id");
    }
    delAcctReq = new DeleteCalendarResourceRequest(acctId);
    delAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
    assertNotNull("DeleteCalendarResourceResponse for " + TARGET_CALRES + " as domAdmin specifying target acct", delAcctResp);
    try {
        getAcctResp = domAdminSoapProv.invokeJaxb(new GetCalendarResourceRequest(CalendarResourceSelector.fromName(TARGET_CALRES), true));
        fail("GetCalendarResourceRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "no such calendar resource: ");
    }
    try {
        getAcctResp = domAdminSoapProv.invokeJaxb(new GetCalendarResourceRequest(CalendarResourceSelector.fromId(acctId), true));
        fail("GetCalendarResourceRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        // because by id not name
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
    try {
        getAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(new GetCalendarResourceRequest(CalendarResourceSelector.fromName(TARGET_CALRES), true), acctId);
        fail("GetCalendarResourceRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access account ");
    }
}
Also used : GetCalendarResourceRequest(com.zimbra.soap.admin.message.GetCalendarResourceRequest) RenameCalendarResourceResponse(com.zimbra.soap.admin.message.RenameCalendarResourceResponse) Attr(com.zimbra.soap.admin.type.Attr) SoapFaultException(com.zimbra.common.soap.SoapFaultException) DeleteCalendarResourceRequest(com.zimbra.soap.admin.message.DeleteCalendarResourceRequest) GetCalendarResourceResponse(com.zimbra.soap.admin.message.GetCalendarResourceResponse) DeleteCalendarResourceResponse(com.zimbra.soap.admin.message.DeleteCalendarResourceResponse) RenameCalendarResourceRequest(com.zimbra.soap.admin.message.RenameCalendarResourceRequest) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) CreateCalendarResourceResponse(com.zimbra.soap.admin.message.CreateCalendarResourceResponse) CreateCalendarResourceRequest(com.zimbra.soap.admin.message.CreateCalendarResourceRequest) Test(org.junit.Test)

Aggregations

CreateCalendarResourceRequest (com.zimbra.soap.admin.message.CreateCalendarResourceRequest)5 SoapFaultException (com.zimbra.common.soap.SoapFaultException)4 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)4 CreateCalendarResourceResponse (com.zimbra.soap.admin.message.CreateCalendarResourceResponse)4 DeleteCalendarResourceRequest (com.zimbra.soap.admin.message.DeleteCalendarResourceRequest)4 Attr (com.zimbra.soap.admin.type.Attr)4 Test (org.junit.Test)4 DeleteCalendarResourceResponse (com.zimbra.soap.admin.message.DeleteCalendarResourceResponse)3 GetCalendarResourceRequest (com.zimbra.soap.admin.message.GetCalendarResourceRequest)2 ModifyCalendarResourceRequest (com.zimbra.soap.admin.message.ModifyCalendarResourceRequest)2 RenameCalendarResourceRequest (com.zimbra.soap.admin.message.RenameCalendarResourceRequest)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 GetCalendarResourceResponse (com.zimbra.soap.admin.message.GetCalendarResourceResponse)1 ModifyCalendarResourceResponse (com.zimbra.soap.admin.message.ModifyCalendarResourceResponse)1 RenameCalendarResourceResponse (com.zimbra.soap.admin.message.RenameCalendarResourceResponse)1