Search in sources :

Example 6 with Attr

use of com.zimbra.soap.admin.type.Attr 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)

Example 7 with Attr

use of com.zimbra.soap.admin.type.Attr 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 8 with Attr

use of com.zimbra.soap.admin.type.Attr in project zm-mailbox by Zimbra.

the class TestDomainAdmin method createAdminConsoleStyleDomainAdminGroup.

public String createAdminConsoleStyleDomainAdminGroup(String domAdminGrp) throws ServiceException {
    CreateDistributionListResponse cdlResp;
    CreateDistributionListRequest cdlReq = new CreateDistributionListRequest(domAdminGrp);
    cdlReq.addAttr(new Attr(Provisioning.A_zimbraIsAdminGroup, "TRUE"));
    cdlResp = adminSoapProv.invokeJaxb(cdlReq);
    assertNotNull("CreateDistributionListResponse for " + cdlReq.getName() + " as Admin", cdlResp);
    List<Attr> attrs = Lists.newArrayList();
    attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "accountListView"));
    attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "downloadsView"));
    attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "DLListView"));
    attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "aliasListView"));
    attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "resourceListView"));
    attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "saveSearch"));
    ModifyDistributionListResponse mdlResp = adminSoapProv.invokeJaxb(new ModifyDistributionListRequest(cdlResp.getDl().getId(), attrs));
    assertNotNull("ModifyDistributionListResponse for " + cdlReq.getName() + " as Admin", mdlResp);
    grantRight(adminSoapProv, TargetType.domain, ADMINISTERED_DOMAIN, GranteeType.grp, domAdminGrp, RightConsts.RT_domainAdminConsoleRights);
    grantRight(adminSoapProv, TargetType.global, "globalacltarget", GranteeType.grp, domAdminGrp, RightConsts.RT_domainAdminZimletRights);
    grantRight(adminSoapProv, TargetType.global, "globalacltarget", GranteeType.grp, domAdminGrp, RightConsts.RT_adminLoginCalendarResourceAs);
    adminSoapProv.flushCache(CacheEntryType.acl, null);
    return cdlResp.getDl().getId();
}
Also used : CreateDistributionListRequest(com.zimbra.soap.admin.message.CreateDistributionListRequest) ModifyDistributionListRequest(com.zimbra.soap.admin.message.ModifyDistributionListRequest) CreateDistributionListResponse(com.zimbra.soap.admin.message.CreateDistributionListResponse) Attr(com.zimbra.soap.admin.type.Attr) ModifyDistributionListResponse(com.zimbra.soap.admin.message.ModifyDistributionListResponse)

Example 9 with Attr

use of com.zimbra.soap.admin.type.Attr in project zm-mailbox by Zimbra.

the class TestDomainAdmin method testModifyDistributionListInDomAdminDomain.

@Test
public void testModifyDistributionListInDomAdminDomain() 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, "testModifyDistributionListInDomAdminDomain"));
    CreateDistributionListResponse caResp;
    caResp = domAdminSoapProv.invokeJaxb(new CreateDistributionListRequest(TARGET_DL, attrs, false));
    assertNotNull("CreateDistributionListResponse for " + TARGET_DL + " simple as domAdmin", caResp);
    String dlId = caResp.getDl().getId();
    ModifyDistributionListRequest modDlReq;
    ModifyDistributionListResponse modDlResp;
    modDlReq = new ModifyDistributionListRequest(null);
    modDlReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
    try {
        modDlResp = domAdminSoapProv.invokeJaxb(modDlReq);
        fail("ModifyDistributionListRequest succeeded without specifying id!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "invalid request: missing required attribute: id");
    }
    modDlReq = new ModifyDistributionListRequest(dlId);
    modDlReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
    modDlResp = domAdminSoapProv.invokeJaxb(modDlReq);
    assertNotNull("ModifyDistributionListResponse for " + TARGET_DL2 + " simple as domAdmin", modDlResp);
    DeleteDistributionListRequest delDlReq = new DeleteDistributionListRequest(dlId);
    DeleteDistributionListResponse delDlResp = domAdminSoapProv.invokeJaxb(delDlReq);
    assertNotNull("DeleteDistributionListResponse for " + TARGET_DL2 + " as domAdmin", delDlResp);
    try {
        modDlResp = domAdminSoapProv.invokeJaxb(modDlReq);
        fail("ModifyDistributionListRequest 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 distribution list ");
    }
    // as full admin
    try {
        modDlResp = adminSoapProv.invokeJaxb(modDlReq);
        fail("ModifyDistributionListRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        // Full admin gets "no such distribution list: " instead of "permission denied"
        checkSoapReason(sfe, "no such distribution list: ");
    }
}
Also used : CreateDistributionListRequest(com.zimbra.soap.admin.message.CreateDistributionListRequest) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) ModifyDistributionListRequest(com.zimbra.soap.admin.message.ModifyDistributionListRequest) DeleteDistributionListRequest(com.zimbra.soap.admin.message.DeleteDistributionListRequest) CreateDistributionListResponse(com.zimbra.soap.admin.message.CreateDistributionListResponse) DeleteDistributionListResponse(com.zimbra.soap.admin.message.DeleteDistributionListResponse) Attr(com.zimbra.soap.admin.type.Attr) SoapFaultException(com.zimbra.common.soap.SoapFaultException) ModifyDistributionListResponse(com.zimbra.soap.admin.message.ModifyDistributionListResponse) Test(org.junit.Test)

Example 10 with Attr

use of com.zimbra.soap.admin.type.Attr 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)

Aggregations

Attr (com.zimbra.soap.admin.type.Attr)22 Test (org.junit.Test)17 SoapFaultException (com.zimbra.common.soap.SoapFaultException)15 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)10 CreateDistributionListRequest (com.zimbra.soap.admin.message.CreateDistributionListRequest)5 CreateDistributionListResponse (com.zimbra.soap.admin.message.CreateDistributionListResponse)5 ModifyAccountRequest (com.zimbra.soap.admin.message.ModifyAccountRequest)5 ModifyCalendarResourceRequest (com.zimbra.soap.admin.message.ModifyCalendarResourceRequest)5 AdminRight (com.zimbra.cs.account.accesscontrol.AdminRight)4 AdminDocumentHandler (com.zimbra.cs.service.admin.AdminDocumentHandler)4 CreateCalendarResourceRequest (com.zimbra.soap.admin.message.CreateCalendarResourceRequest)4 CreateCalendarResourceResponse (com.zimbra.soap.admin.message.CreateCalendarResourceResponse)4 DeleteCalendarResourceRequest (com.zimbra.soap.admin.message.DeleteCalendarResourceRequest)4 ArrayList (java.util.ArrayList)4 CreateAccountRequest (com.zimbra.soap.admin.message.CreateAccountRequest)3 DeleteCalendarResourceResponse (com.zimbra.soap.admin.message.DeleteCalendarResourceResponse)3 ModifyDistributionListRequest (com.zimbra.soap.admin.message.ModifyDistributionListRequest)3 Element (com.zimbra.common.soap.Element)2 Account (com.zimbra.cs.account.Account)2 ModifyAccount (com.zimbra.cs.service.admin.ModifyAccount)2