use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class TestLdapProvAttrCallback method accountStatus.
@Test
public void accountStatus() throws Exception {
String ACCT_NAME_LOCALPART = Names.makeAccountNameLocalPart(genAcctNameLocalPart("account"));
Account acct = createAccount(ACCT_NAME_LOCALPART);
String ALIAS_LOCALPART_1 = Names.makeAliasNameLocalPart(genAcctNameLocalPart("alias-1"));
String ALIAS_NAME_1 = TestUtil.getAddress(ALIAS_LOCALPART_1, domain.getName()).toLowerCase();
String ALIAS_LOCALPART_2 = Names.makeAliasNameLocalPart(genAcctNameLocalPart("alias-2"));
String ALIAS_NAME_2 = TestUtil.getAddress(ALIAS_LOCALPART_2, domain.getName()).toLowerCase();
prov.addAlias(acct, ALIAS_NAME_1);
prov.addAlias(acct, ALIAS_NAME_2);
String DL_NAME_LOCALPART = Names.makeDLNameLocalPart("accountStatus-dl");
DistributionList dl = createDistributionList(DL_NAME_LOCALPART);
dl.addMembers(new String[] { acct.getName(), ALIAS_NAME_1, ALIAS_NAME_2 });
prov.flushCache(CacheEntryType.account, null);
prov.flushCache(CacheEntryType.group, null);
Set<String> allMembers = dl.getAllMembersSet();
assertEquals(3, allMembers.size());
assertTrue(allMembers.contains(acct.getName()));
assertTrue(allMembers.contains(ALIAS_NAME_1));
assertTrue(allMembers.contains(ALIAS_NAME_2));
Map<String, Object> attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_zimbraAccountStatus, ZAttrProvisioning.AccountStatus.closed.name());
prov.modifyAttrs(acct, attrs);
prov.flushCache(CacheEntryType.account, null);
prov.flushCache(CacheEntryType.group, null);
dl = prov.get(Key.DistributionListBy.id, dl.getId());
allMembers = dl.getAllMembersSet();
assertEquals(0, allMembers.size());
deleteAccount(acct);
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class TestLdapProvAlias method removeDistributionListAlias.
@Test
public void removeDistributionListAlias() throws Exception {
String DL_NAME_LOCALPART = Names.makeDLNameLocalPart(genGroupNameLocalPart("dl"));
DistributionList dl = createDistributionList(DL_NAME_LOCALPART);
String DL_ID = dl.getId();
String ALIAS_LOCALPART = Names.makeAliasNameLocalPart(genGroupNameLocalPart("alias"));
String ALIAS_NAME = TestUtil.getAddress(ALIAS_LOCALPART, domain.getName());
prov.addAlias(dl, ALIAS_NAME);
prov.flushCache(CacheEntryType.group, null);
DistributionList dlByAlias = prov.get(Key.DistributionListBy.name, ALIAS_NAME);
assertEquals(DL_ID, dlByAlias.getId());
prov.removeAlias(dl, ALIAS_NAME);
prov.flushCache(CacheEntryType.group, null);
dlByAlias = prov.get(Key.DistributionListBy.name, ALIAS_NAME);
assertNull(dlByAlias);
deleteDistributionList(dl);
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class TestLdapProvDistributionList method removeMembers.
@Test
public void removeMembers() 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);
StringUtil.addToMultiMap(attrs, Provisioning.A_zimbraMailForwardingAddress, MEMBER_3);
StringUtil.addToMultiMap(attrs, Provisioning.A_zimbraMailForwardingAddress, MEMBER_4);
DistributionList dl = createDistributionList(DL_NAME_LOCALPART, attrs);
prov.removeMembers(dl, new String[] { MEMBER_3, MEMBER_4 });
Set<String> allMembers = dl.getAllMembersSet();
assertEquals(2, allMembers.size());
assertTrue(allMembers.contains(MEMBER_1));
assertTrue(allMembers.contains(MEMBER_2));
deleteDistributionList(dl);
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class TestLdapProvDistributionList method getDistributionListById.
private void getDistributionListById(String id) throws Exception {
prov.flushCache(CacheEntryType.group, null);
DistributionList dl = prov.get(Key.DistributionListBy.id, id);
assertNotNull(dl);
assertEquals(id, dl.getId());
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class TestLdapProvDistributionList method renameDistributionListDomainChanged.
@Test
public void renameDistributionListDomainChanged() throws Exception {
String DL_NAME_LOCALPART = Names.makeDLNameLocalPart(genGroupNameLocalPart());
String NEW_DOMAIN_NAME = genDomainSegmentName() + "." + BASE_DOMAIN_NAME;
Domain newDomain = provUtil.createDomain(NEW_DOMAIN_NAME, null);
String DL_NEW_NAME_LOCALPART = Names.makeDLNameLocalPart(genGroupNameLocalPart("new"));
String DL_NEW_NAME = TestUtil.getAddress(DL_NEW_NAME_LOCALPART, newDomain.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);
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);
provUtil.deleteDomain(newDomain);
}
Aggregations