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);
}
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);
}
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);
}
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);
}
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;
}
Aggregations