Search in sources :

Example 1 with ModifyDistributionListRequest

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

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

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

the class TestDomainAdmin method testModifyDistributionListInDiffDomain.

@Test
public void testModifyDistributionListInDiffDomain() 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, "testGetDistributionListInDiffDomain Room 101"));
    CreateDistributionListResponse caResp;
    caResp = adminSoapProv.invokeJaxb(new CreateDistributionListRequest(DIFF_DL, attrs, false));
    assertNotNull("CreateDistributionListResponse for " + DIFF_DL + " as FULL ADMIN", caResp);
    String dlId = caResp.getDl().getId();
    ModifyDistributionListRequest modAcctReq = new ModifyDistributionListRequest(dlId);
    modAcctReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
    try {
        domAdminSoapProv.invokeJaxb(modAcctReq);
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access distribution list ");
    }
    DeleteDistributionListRequest delAcctReq = new DeleteDistributionListRequest(dlId);
    DeleteDistributionListResponse delAcctResp = adminSoapProv.invokeJaxb(delAcctReq);
    assertNotNull("DeleteDistributionListResponse for " + DIFF_DL + " as ADMIN", delAcctResp);
    try {
        domAdminSoapProv.invokeJaxb(modAcctReq);
        fail("ModifyDistributionListRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        // Get this instead of "no such distribution list" 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 ");
    }
}
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) Test(org.junit.Test)

Example 4 with ModifyDistributionListRequest

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

the class TestDelegatedDL method noHomeServerZimbraAdmin.

/*
     * Verify groups without a home server will get executed for zimbraAdmin
     * SOAP calls.
     */
@Test
@Bug(bug = 66412)
public void noHomeServerZimbraAdmin() throws Exception {
    String groupName = TestUtil.getAddress(genGroupNameLocalPart(), DOMAIN_NAME);
    Group group = provUtil.createGroup(groupName, DYNAMIC);
    String groupId = group.getId();
    // remove zimbraMailHost
    Map<String, Object> attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_zimbraMailHost, null);
    prov.modifyAttrs(group, attrs);
    SoapTransport transport = authAdmin(ADMIN);
    Object req;
    com.zimbra.soap.admin.type.DistributionListInfo dlInfo;
    /*
         * GetDistributionList
         */
    req = new com.zimbra.soap.admin.message.GetDistributionListRequest(com.zimbra.soap.admin.type.DistributionListSelector.fromName(groupName));
    com.zimbra.soap.admin.message.GetDistributionListResponse getDLResp = invokeJaxb(transport, req);
    dlInfo = getDLResp.getDl();
    assertEquals(groupId, dlInfo.getId());
    /*
         * ModifyDistributionList
         */
    req = new ModifyDistributionListRequest(groupId);
    ModifyDistributionListResponse modifyDLResp = invokeJaxb(transport, req);
    dlInfo = modifyDLResp.getDl();
    assertEquals(groupId, dlInfo.getId());
    /*
         * AddDistributionAlias
         */
    req = new AddDistributionListAliasRequest(groupId, TestUtil.getAddress(genGroupNameLocalPart("alias"), DOMAIN_NAME));
    AddDistributionListAliasResponse addDLAliasResp = invokeJaxb(transport, req);
    /*
         * RemoveDistributionAlias
         */
    req = new RemoveDistributionListAliasRequest(groupId, TestUtil.getAddress(genGroupNameLocalPart("alias"), DOMAIN_NAME));
    RemoveDistributionListAliasResponse removeDLAliasResp = invokeJaxb(transport, req);
    /*
         * AddDistributionListMember
         */
    req = new AddDistributionListMemberRequest(groupId, Collections.singleton(TestUtil.getAddress(genAcctNameLocalPart("member"), DOMAIN_NAME)));
    AddDistributionListMemberResponse addDLMemberResp = invokeJaxb(transport, req);
    /*
         * RemoveDistributionListMember
         */
    req = new RemoveDistributionListMemberRequest(groupId, Collections.singleton(TestUtil.getAddress(genAcctNameLocalPart("member"), DOMAIN_NAME)));
    RemoveDistributionListMemberResponse removeDLMemberResp = invokeJaxb(transport, req);
    /*
         * DeleteDistributionList
         */
    req = new DeleteDistributionListRequest(groupId);
    DeleteDistributionListResponse deleteDLResp = invokeJaxb(transport, req);
}
Also used : Group(com.zimbra.cs.account.Group) RemoveDistributionListAliasRequest(com.zimbra.soap.admin.message.RemoveDistributionListAliasRequest) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) AddDistributionListAliasRequest(com.zimbra.soap.admin.message.AddDistributionListAliasRequest) RemoveDistributionListMemberResponse(com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse) RemoveDistributionListAliasResponse(com.zimbra.soap.admin.message.RemoveDistributionListAliasResponse) RemoveDistributionListMemberRequest(com.zimbra.soap.admin.message.RemoveDistributionListMemberRequest) AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) ModifyDistributionListRequest(com.zimbra.soap.admin.message.ModifyDistributionListRequest) DeleteDistributionListRequest(com.zimbra.soap.admin.message.DeleteDistributionListRequest) DeleteDistributionListResponse(com.zimbra.soap.admin.message.DeleteDistributionListResponse) AddDistributionListAliasResponse(com.zimbra.soap.admin.message.AddDistributionListAliasResponse) SoapTransport(com.zimbra.common.soap.SoapTransport) ModifyDistributionListResponse(com.zimbra.soap.admin.message.ModifyDistributionListResponse) Test(org.junit.Test) Bug(com.zimbra.qa.QA.Bug)

Example 5 with ModifyDistributionListRequest

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

the class ModifyDistributionList method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    ModifyDistributionListRequest req = JaxbUtil.elementToJaxb(request);
    String id = req.getId();
    Group group = getGroupFromContext(context);
    Map<String, Object> attrs = req.getAttrsAsOldMultimap();
    defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, attrs, attrs);
    // pass in true to checkImmutable
    prov.modifyAttrs(group, attrs, true);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "ModifyDistributionList", "name", group.getName() }, attrs));
    Element response = zsc.createElement(AdminConstants.MODIFY_DISTRIBUTION_LIST_RESPONSE);
    GetDistributionList.encodeDistributionList(response, group);
    return response;
}
Also used : Group(com.zimbra.cs.account.Group) ModifyDistributionListRequest(com.zimbra.soap.admin.message.ModifyDistributionListRequest) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Aggregations

ModifyDistributionListRequest (com.zimbra.soap.admin.message.ModifyDistributionListRequest)5 CreateDistributionListRequest (com.zimbra.soap.admin.message.CreateDistributionListRequest)3 CreateDistributionListResponse (com.zimbra.soap.admin.message.CreateDistributionListResponse)3 DeleteDistributionListRequest (com.zimbra.soap.admin.message.DeleteDistributionListRequest)3 DeleteDistributionListResponse (com.zimbra.soap.admin.message.DeleteDistributionListResponse)3 ModifyDistributionListResponse (com.zimbra.soap.admin.message.ModifyDistributionListResponse)3 Attr (com.zimbra.soap.admin.type.Attr)3 Test (org.junit.Test)3 SoapFaultException (com.zimbra.common.soap.SoapFaultException)2 Group (com.zimbra.cs.account.Group)2 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)2 Element (com.zimbra.common.soap.Element)1 SoapTransport (com.zimbra.common.soap.SoapTransport)1 Provisioning (com.zimbra.cs.account.Provisioning)1 Bug (com.zimbra.qa.QA.Bug)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 AddDistributionListAliasRequest (com.zimbra.soap.admin.message.AddDistributionListAliasRequest)1 AddDistributionListAliasResponse (com.zimbra.soap.admin.message.AddDistributionListAliasResponse)1 AddDistributionListMemberRequest (com.zimbra.soap.admin.message.AddDistributionListMemberRequest)1 AddDistributionListMemberResponse (com.zimbra.soap.admin.message.AddDistributionListMemberResponse)1