use of com.zimbra.cs.account.NamedEntry in project zm-mailbox by Zimbra.
the class TestLdapProvSearchDirectory method wildcardFilter.
@Test
@Bug(bug = 67379)
public void wildcardFilter() throws Exception {
Account acct1 = createAccount(genAcctNameLocalPart("1"));
Account acct2 = createAccount(genAcctNameLocalPart("2"));
Account acct3 = createAccount(genAcctNameLocalPart("3"));
SearchDirectoryOptions options = new SearchDirectoryOptions(domain);
options.setTypes(ObjectType.accounts);
options.setSortOpt(SortOpt.SORT_ASCENDING);
options.setFilterString(FilterId.UNITTEST, "(cn=*)");
options.setConvertIDNToAscii(true);
List<NamedEntry> entries = prov.searchDirectory(options);
Verify.verifyEquals(Lists.newArrayList(acct1, acct2, acct3), entries, true);
deleteAccount(acct1);
deleteAccount(acct2);
deleteAccount(acct3);
}
use of com.zimbra.cs.account.NamedEntry in project zm-mailbox by Zimbra.
the class TestLdapProvSearchDirectory method accountsOnServerAndCosHasSubordinates.
@Test
public void accountsOnServerAndCosHasSubordinates() throws Exception {
/*
* X.501: 14.4.4 Has Subordinates operational attribute
* is not supported in ubid InMemoryLdapServer
*/
SKIP_FOR_INMEM_LDAP_SERVER(SkipTestReason.SUBORDINATES_OPERTIONAL_ATTRIBUTE);
String COS_ID = prov.get(CosBy.name, Provisioning.DEFAULT_COS_NAME).getId();
Account acct = createAccount(genAcctNameLocalPart());
Signature sig1 = prov.createSignature(acct, "sig1", new HashMap<String, Object>());
Signature sig2 = prov.createSignature(acct, "sig2", new HashMap<String, Object>());
SearchAccountsOptions searchOpts = new SearchAccountsOptions();
ZLdapFilter filter = ZLdapFilterFactory.getInstance().accountsOnServerAndCosHasSubordinates(prov.getLocalServer().getServiceHostname(), COS_ID);
searchOpts.setFilter(filter);
List<NamedEntry> accounts = prov.searchDirectory(searchOpts);
Verify.verifyEquals(Lists.newArrayList(acct), accounts, false);
deleteAccount(acct);
}
use of com.zimbra.cs.account.NamedEntry in project zm-mailbox by Zimbra.
the class TestLdapProvSearchDirectory method getAllCalendarResourcesOnServer.
@Test
public void getAllCalendarResourcesOnServer() throws Exception {
Account acct = createAccount(genAcctNameLocalPart("acct"));
CalendarResource cr = createCalendarResource(genAcctNameLocalPart("cr"));
final List<NamedEntry> crs = Lists.newArrayList();
NamedEntry.Visitor visitor = new NamedEntry.Visitor() {
@Override
public void visit(NamedEntry entry) throws ServiceException {
crs.add(entry);
}
};
Server server = prov.getLocalServer();
prov.getAllCalendarResources(domain, server, visitor);
Verify.verifyEquals(Lists.newArrayList(cr), crs, false);
crs.clear();
Server otherServer = createServer(genServerName());
assertNotNull(otherServer);
prov.getAllCalendarResources(domain, otherServer, visitor);
Verify.verifyEquals(null, crs, false);
deleteAccount(acct);
deleteAccount(cr);
deleteServer(otherServer);
}
use of com.zimbra.cs.account.NamedEntry in project zm-mailbox by Zimbra.
the class TestLdapProvSearchDirectory method filterWithTrailingDot.
@Test
@Bug(bug = 68964)
public void filterWithTrailingDot() throws Exception {
Domain subDomain = provUtil.createDomain(genDomainName(baseDomainName()));
Account acct = provUtil.createAccount(genAcctNameLocalPart(), subDomain);
SearchDirectoryOptions options = new SearchDirectoryOptions();
options.setDomain(subDomain);
options.setTypes(SearchDirectoryOptions.ObjectType.accounts);
options.setFilterString(FilterId.UNITTEST, "(zimbraMailDeliveryAddress=*.*)");
options.setReturnAttrs(new String[] { Provisioning.A_zimbraMailDeliveryAddress });
options.setConvertIDNToAscii(true);
List<NamedEntry> entries = prov.searchDirectory(options);
Verify.verifyEquals(Lists.newArrayList(acct), entries, true);
deleteAccount(acct);
deleteDomain(subDomain);
}
use of com.zimbra.cs.account.NamedEntry in project zm-mailbox by Zimbra.
the class TestLdapProvSearchDirectory method searchAliasTarget.
@Test
public void searchAliasTarget() throws Exception {
Account acct = createAccount(genAcctNameLocalPart("acct"));
CalendarResource cr = createCalendarResource(genAcctNameLocalPart("cr"));
DistributionList dl = createDistributionList(genGroupNameLocalPart("dl"));
DynamicGroup dg = createDynamicGroup(genGroupNameLocalPart("dg"));
// prepend a digit so the order returned from SearchDirectory is predictable
prov.addAlias(acct, TestUtil.getAddress("1-acct-alias", domain.getName()));
prov.addAlias(cr, TestUtil.getAddress("2-cr-alias", domain.getName()));
prov.addGroupAlias(dl, TestUtil.getAddress("3-dl-alias", domain.getName()));
prov.addGroupAlias(dg, TestUtil.getAddress("4-dg-alias", domain.getName()));
SearchDirectoryOptions options = new SearchDirectoryOptions(domain);
options.setTypes(ObjectType.aliases);
options.setSortOpt(SortOpt.SORT_ASCENDING);
options.setFilterString(FilterId.UNITTEST, null);
List<NamedEntry> aliases = prov.searchDirectory(options);
assertEquals(4, aliases.size());
Alias acctAlias = (Alias) aliases.get(0);
Alias crAlias = (Alias) aliases.get(1);
Alias dlAlias = (Alias) aliases.get(2);
Alias dgAlias = (Alias) aliases.get(3);
NamedEntry acctAliasTarget = prov.searchAliasTarget(acctAlias, true);
assertEquals(acct.getId(), acctAliasTarget.getId());
NamedEntry crAliasTarget = prov.searchAliasTarget(crAlias, true);
assertEquals(cr.getId(), crAliasTarget.getId());
NamedEntry dlAliasTarget = prov.searchAliasTarget(dlAlias, true);
assertEquals(dl.getId(), dlAliasTarget.getId());
NamedEntry dgAliasTarget = prov.searchAliasTarget(dgAlias, true);
assertEquals(dg.getId(), dgAliasTarget.getId());
deleteAccount(acct);
deleteAccount(cr);
deleteGroup(dl);
deleteGroup(dg);
}
Aggregations