Search in sources :

Example 46 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class TestLdapProvDistributionList method renameDistributionList.

@Test
public void renameDistributionList() throws Exception {
    String DL_NAME_LOCALPART = Names.makeDLNameLocalPart(genGroupNameLocalPart());
    String DL_NEW_NAME_LOCALPART = Names.makeDLNameLocalPart(genGroupNameLocalPart("new"));
    String DL_NEW_NAME = TestUtil.getAddress(DL_NEW_NAME_LOCALPART, domain.getName()).toLowerCase();
    DistributionList dl = createDistributionList(DL_NAME_LOCALPART);
    String DL_ID = dl.getId();
    // set zimbraPrefAllowAddressForDelegatedSender
    Map<String, Object> attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_zimbraPrefAllowAddressForDelegatedSender, dl.getName());
    prov.modifyAttrs(dl, attrs);
    prov.renameDistributionList(DL_ID, DL_NEW_NAME);
    prov.flushCache(CacheEntryType.group, null);
    getDistributionListById(DL_ID);
    getDistributionListByName(DL_NEW_NAME);
    // make sure zimbraPrefAllowAddressForDelegatedSender is updated
    DistributionList renamedDl = prov.get(DistributionListBy.name, DL_NEW_NAME);
    Set<String> addrsForDelegatedSender = renamedDl.getMultiAttrSet(Provisioning.A_zimbraPrefAllowAddressForDelegatedSender);
    assertEquals(1, addrsForDelegatedSender.size());
    assertTrue(addrsForDelegatedSender.contains(DL_NEW_NAME));
    deleteDistributionList(dl);
}
Also used : DistributionList(com.zimbra.cs.account.DistributionList)

Example 47 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class TestLdapProvDistributionList method testCircular1.

@Test
public void testCircular1() throws Exception {
    Domain domain = provUtil.createDomain(genDomainSegmentName() + "." + BASE_DOMAIN_NAME);
    DistributionList group1 = provUtil.createDistributionList("group1", domain);
    DistributionList group2 = provUtil.createDistributionList("group2", domain);
    Account acct1 = provUtil.createAccount("acct1", domain);
    Account acct2 = provUtil.createAccount("acct2", domain);
    String acct1Id = acct1.getId();
    String acct2Id = acct2.getId();
    group1.addMembers(new String[] { group2.getName(), acct1.getName(), acct2.getName() });
    group2.addMembers(new String[] { group1.getName(), acct1.getName(), acct2.getName() });
    Set<String> expectedAllGroups = new HashSet<String>();
    Set<String> expectedDirectGroups = new HashSet<String>();
    expectedAllGroups.add(group1.getName());
    expectedAllGroups.add(group2.getName());
    expectedDirectGroups.add(group1.getName());
    expectedDirectGroups.add(group2.getName());
    verifyMembership(acct1Id, expectedAllGroups, expectedDirectGroups);
    verifyMembership(acct2Id, expectedAllGroups, expectedDirectGroups);
}
Also used : Account(com.zimbra.cs.account.Account) Domain(com.zimbra.cs.account.Domain) DistributionList(com.zimbra.cs.account.DistributionList) HashSet(java.util.HashSet)

Example 48 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class TestLdapProvDistributionList method addMembers.

@Test
public void addMembers() throws Exception {
    String DL_NAME_LOCALPART = Names.makeDLNameLocalPart(genGroupNameLocalPart());
    String MEMBER_1 = "member_1@test.com";
    String MEMBER_2 = "member_2@test.com";
    String MEMBER_3 = "member_3@test.com";
    String MEMBER_4 = "member_4@test.com";
    Map<String, Object> attrs = new HashMap<String, Object>();
    // add initial members
    StringUtil.addToMultiMap(attrs, Provisioning.A_zimbraMailForwardingAddress, MEMBER_1);
    StringUtil.addToMultiMap(attrs, Provisioning.A_zimbraMailForwardingAddress, MEMBER_2);
    DistributionList dl = createDistributionList(DL_NAME_LOCALPART, attrs);
    prov.addMembers(dl, new String[] { MEMBER_3, MEMBER_4 });
    Set<String> allMembers = dl.getAllMembersSet();
    assertEquals(4, allMembers.size());
    assertTrue(allMembers.contains(MEMBER_1));
    assertTrue(allMembers.contains(MEMBER_2));
    assertTrue(allMembers.contains(MEMBER_3));
    assertTrue(allMembers.contains(MEMBER_4));
    deleteDistributionList(dl);
}
Also used : HashMap(java.util.HashMap) DistributionList(com.zimbra.cs.account.DistributionList)

Example 49 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class TestLdapProvDistributionList method getAccountDistributionLists.

@Test
public void getAccountDistributionLists() throws Exception {
    String DL_NAME_1_LOCALPART = Names.makeDLNameLocalPart(genGroupNameLocalPart("dl-1"));
    String DL_NAME_2_LOCALPART = Names.makeDLNameLocalPart(genGroupNameLocalPart("dl-2"));
    DistributionList dl1 = createDistributionList(DL_NAME_1_LOCALPART);
    DistributionList dl2 = createDistributionList(DL_NAME_2_LOCALPART);
    String ACCT_NAME_LOCALPART = Names.makeAccountNameLocalPart(genAcctNameLocalPart("acct"));
    Account acct = createAccount(ACCT_NAME_LOCALPART);
    prov.addMembers(dl1, new String[] { dl2.getName() });
    prov.addMembers(dl2, new String[] { acct.getName() });
    Set<String> dlIds = prov.getDistributionLists(acct);
    assertEquals(2, dlIds.size());
    assertTrue(dlIds.contains(dl1.getId()));
    assertTrue(dlIds.contains(dl2.getId()));
    Map<String, String> via = new HashMap<String, String>();
    List<DistributionList> inDlsDirect = prov.getDistributionLists(acct, true, via);
    assertEquals(1, inDlsDirect.size());
    assertEquals(dl2.getId(), inDlsDirect.get(0).getId());
    List<DistributionList> inDlsAll = prov.getDistributionLists(acct, false, via);
    assertEquals(2, inDlsAll.size());
    deleteAccount(acct);
    deleteDistributionList(dl1);
    deleteDistributionList(dl2);
}
Also used : Account(com.zimbra.cs.account.Account) HashMap(java.util.HashMap) DistributionList(com.zimbra.cs.account.DistributionList)

Example 50 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class TestJaxbProvisioning method ensureDlExists.

public static DistributionList ensureDlExists(String name) throws ServiceException {
    Provisioning prov = TestUtil.newSoapProvisioning();
    String domainName = name.substring(name.indexOf('@') + 1);
    ensureDomainExists(domainName);
    DistributionList dl = prov.get(Key.DistributionListBy.name, name);
    if (dl == null) {
        dl = prov.createDistributionList(name, null);
    }
    return dl;
}
Also used : Provisioning(com.zimbra.cs.account.Provisioning) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) DistributionList(com.zimbra.cs.account.DistributionList)

Aggregations

DistributionList (com.zimbra.cs.account.DistributionList)120 Account (com.zimbra.cs.account.Account)58 Domain (com.zimbra.cs.account.Domain)43 HashMap (java.util.HashMap)24 Test (org.junit.Test)24 Provisioning (com.zimbra.cs.account.Provisioning)22 NamedEntry (com.zimbra.cs.account.NamedEntry)18 HashSet (java.util.HashSet)18 ArrayList (java.util.ArrayList)14 ServiceException (com.zimbra.common.service.ServiceException)13 AccountServiceException (com.zimbra.cs.account.AccountServiceException)13 Right (com.zimbra.cs.account.accesscontrol.Right)12 DynamicGroup (com.zimbra.cs.account.DynamicGroup)10 LdapDistributionList (com.zimbra.cs.account.ldap.entry.LdapDistributionList)10 Group (com.zimbra.cs.account.Group)9 GuestAccount (com.zimbra.cs.account.GuestAccount)9 LdapProv (com.zimbra.cs.account.ldap.LdapProv)8 List (java.util.List)7 Entry (com.zimbra.cs.account.Entry)6 LdapEntry (com.zimbra.cs.account.ldap.entry.LdapEntry)6