use of com.zimbra.cs.account.DynamicGroup in project zm-mailbox by Zimbra.
the class TestLdapProvRenameDomain method verifyEntries.
/*
* verify all expected entries are in the domain and the domain only contains these entries
*/
private void verifyEntries(int domainIdx, Domain domain) throws Exception {
// get all the entries reside in the domain
SearchDirectoryOptions options = new SearchDirectoryOptions();
options.setTypes(SearchDirectoryOptions.ObjectType.accounts, SearchDirectoryOptions.ObjectType.distributionlists, SearchDirectoryOptions.ObjectType.dynamicgroups);
options.setDomain(domain);
options.setFilterString(FilterId.UNITTEST, null);
List<NamedEntry> list = prov.searchDirectory(options);
// come up with all expected entries
Set<String> expectedEntries = new HashSet<String>();
for (int a = 0; a < NUM_ACCOUNTS; a++) {
Names.IDNName name = new Names.IDNName(ACCOUNT_NAME(a, domainIdx));
Account entry = prov.get(Key.AccountBy.name, name.uName());
assertNotNull(entry);
expectedEntries.add(name.uName());
}
for (int nd = 0; nd < NUM_DLS_NESTED; nd++) {
Names.IDNName name = new Names.IDNName(NESTED_DL_NAME(nd, domainIdx));
DistributionList entry = prov.get(Key.DistributionListBy.name, name.uName());
assertNotNull(entry);
expectedEntries.add(name.uName());
}
for (int td = 0; td < NUM_DLS_TOP; td++) {
Names.IDNName name = new Names.IDNName(TOP_DL_NAME(td, domainIdx));
DistributionList entry = prov.get(Key.DistributionListBy.name, name.uName());
assertNotNull(entry);
expectedEntries.add(name.uName());
}
for (int td = 0; td < NUM_DYNAMIC_GROUPS; td++) {
Names.IDNName name = new Names.IDNName(DYNAMIC_GROUP_NAME(td, domainIdx));
DynamicGroup entry = (DynamicGroup) prov.getGroup(Key.DistributionListBy.name, name.uName());
assertNotNull(entry);
expectedEntries.add(name.uName());
}
// verify all our aliases are there
Set<String> actualEntries = namedEntryListToNameSet(list, UnicodeOrACE.UNICODE);
dumpStrings("expectedEntries", expectedEntries);
dumpStrings("actualEntries", actualEntries);
Verify.verifyEquals(expectedEntries, actualEntries);
verifyEntryAttrs(list, domain);
}
use of com.zimbra.cs.account.DynamicGroup in project zm-mailbox by Zimbra.
the class TestLdapProvDynamicGroup method zimbraIsACLGroup_and_memeberURL_2.
/*
* On create: if memeberURL is not specified, zimbraIsACLGroup must be either not
* specified, or set to TRUE.
*/
@Test
public void zimbraIsACLGroup_and_memeberURL_2() throws Exception {
Map<String, Object> attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_zimbraIsACLGroup, ProvisioningConstants.TRUE);
DynamicGroup group = createDynamicGroup(genGroupNameLocalPart(seq), attrs);
assertEquals(true, group.isIsACLGroup());
String errCode = null;
attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_zimbraIsACLGroup, ProvisioningConstants.FALSE);
try {
createDynamicGroup(genGroupNameLocalPart(seq), attrs);
} catch (ServiceException e) {
errCode = e.getCode();
}
assertEquals(ServiceException.INVALID_REQUEST, errCode);
}
use of com.zimbra.cs.account.DynamicGroup in project zm-mailbox by Zimbra.
the class TestLdapProvDynamicGroup method createDynamicGroup.
/*
* basic creation test
*/
@Test
public void createDynamicGroup() throws Exception {
DynamicGroup group = createDynamicGroup(genGroupNameLocalPart());
// make sure the group has a home server
Server homeServer = group.getServer();
assertNotNull(homeServer);
deleteDynamicGroup(group);
}
use of com.zimbra.cs.account.DynamicGroup in project zm-mailbox by Zimbra.
the class TestLdapProvDynamicGroup method zimbraIsACLGroup_and_memeberURL_4.
/*
* On modify: memeberURL cannot be modified if zimbraIsACLGroup is TRUE.
*/
@Test
public void zimbraIsACLGroup_and_memeberURL_4() throws Exception {
DynamicGroup group = createDynamicGroup(genGroupNameLocalPart());
Map<String, Object> attrs;
String errCode = null;
try {
attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_memberURL, "blah");
prov.modifyAttrs(group, attrs, true);
} catch (ServiceException e) {
errCode = e.getCode();
}
assertEquals(ServiceException.INVALID_REQUEST, errCode);
}
use of com.zimbra.cs.account.DynamicGroup in project zm-mailbox by Zimbra.
the class TestLdapProvDynamicGroup method deleteDynamicGroup.
/*
* deletion test
*/
@Test
public void deleteDynamicGroup() throws Exception {
DynamicGroup group = createDynamicGroup(genGroupNameLocalPart());
Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
// add a member
prov.addGroupMembers(group, new String[] { acct.getName() });
assertTrue(acct.getMultiAttrSet(Provisioning.A_zimbraMemberOf).contains(group.getId()));
// delete the group
deleteDynamicGroup(group);
// reget the acct
acct = prov.get(AccountBy.id, acct.getId());
assertFalse(acct.getMultiAttrSet(Provisioning.A_zimbraMemberOf).contains(group.getId()));
}
Aggregations