Search in sources :

Example 11 with NamedEntry

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);
}
Also used : Account(com.zimbra.cs.account.Account) SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions) NamedEntry(com.zimbra.cs.account.NamedEntry) ProvTest(com.zimbra.qa.unittest.prov.ProvTest) Bug(com.zimbra.qa.QA.Bug)

Example 12 with NamedEntry

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);
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) Account(com.zimbra.cs.account.Account) NamedEntry(com.zimbra.cs.account.NamedEntry) SearchAccountsOptions(com.zimbra.cs.account.SearchAccountsOptions) Signature(com.zimbra.cs.account.Signature) ProvTest(com.zimbra.qa.unittest.prov.ProvTest)

Example 13 with NamedEntry

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);
}
Also used : Account(com.zimbra.cs.account.Account) NamedEntry(com.zimbra.cs.account.NamedEntry) Server(com.zimbra.cs.account.Server) CalendarResource(com.zimbra.cs.account.CalendarResource) ProvTest(com.zimbra.qa.unittest.prov.ProvTest)

Example 14 with NamedEntry

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);
}
Also used : Account(com.zimbra.cs.account.Account) SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions) NamedEntry(com.zimbra.cs.account.NamedEntry) Domain(com.zimbra.cs.account.Domain) LdapDomain(com.zimbra.cs.account.ldap.entry.LdapDomain) ProvTest(com.zimbra.qa.unittest.prov.ProvTest) Bug(com.zimbra.qa.QA.Bug)

Example 15 with NamedEntry

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);
}
Also used : Account(com.zimbra.cs.account.Account) DynamicGroup(com.zimbra.cs.account.DynamicGroup) SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions) NamedEntry(com.zimbra.cs.account.NamedEntry) Alias(com.zimbra.cs.account.Alias) CalendarResource(com.zimbra.cs.account.CalendarResource) DistributionList(com.zimbra.cs.account.DistributionList) ProvTest(com.zimbra.qa.unittest.prov.ProvTest)

Aggregations

NamedEntry (com.zimbra.cs.account.NamedEntry)109 Account (com.zimbra.cs.account.Account)51 ServiceException (com.zimbra.common.service.ServiceException)24 Domain (com.zimbra.cs.account.Domain)24 Provisioning (com.zimbra.cs.account.Provisioning)23 DistributionList (com.zimbra.cs.account.DistributionList)19 SearchDirectoryOptions (com.zimbra.cs.account.SearchDirectoryOptions)19 ProvTest (com.zimbra.qa.unittest.prov.ProvTest)19 AccountServiceException (com.zimbra.cs.account.AccountServiceException)18 HashSet (java.util.HashSet)17 Entry (com.zimbra.cs.account.Entry)15 HashMap (java.util.HashMap)15 Element (com.zimbra.common.soap.Element)14 Group (com.zimbra.cs.account.Group)14 SearchAccountsOptions (com.zimbra.cs.account.SearchAccountsOptions)12 GuestAccount (com.zimbra.cs.account.GuestAccount)9 MailTarget (com.zimbra.cs.account.MailTarget)8 LdapDomain (com.zimbra.cs.account.ldap.entry.LdapDomain)8 ArrayList (java.util.ArrayList)8 AccessManager (com.zimbra.cs.account.AccessManager)7