Search in sources :

Example 61 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class TestLdapProvRenameDomain method populateDomain.

/*
     * create and setup entries in the domain
     */
private void populateDomain(int domainIdx) throws Exception {
    Names.IDNName domainName = new Names.IDNName(DOMAIN_NAME(domainIdx));
    System.out.println("setupDomain: " + domainName.uName());
    // create accounts and their aliases
    for (int a = 0; a < NUM_ACCOUNTS; a++) {
        Account acct = createAccount(ACCOUNT_NAME(a, domainIdx), domainName);
        for (int d = 0; d < NUM_DOMAINS; d++) prov.addAlias(acct, ACCOUNT_ALIAS_NAME(a, domainIdx, d));
        String[] signatureIds = createSignatures(acct);
        createIdentities(acct, signatureIds);
        createDataSources(acct, signatureIds);
    }
    // create nested dls and their aliases
    for (int nd = 0; nd < NUM_DLS_NESTED; nd++) {
        Map<String, Object> dlAttrs = new HashMap<String, Object>();
        DistributionList dl = prov.createDistributionList(NESTED_DL_NAME(nd, domainIdx), dlAttrs);
        for (int d = 0; d < NUM_DOMAINS; d++) {
            prov.addAlias(dl, NESTED_DL_ALIAS_NAME(nd, domainIdx, d));
        }
    }
    // create top dls and their aliases
    for (int td = 0; td < NUM_DLS_TOP; td++) {
        Map<String, Object> dlAttrs = new HashMap<String, Object>();
        DistributionList dl = prov.createDistributionList(TOP_DL_NAME(td, domainIdx), dlAttrs);
        for (int d = 0; d < NUM_DOMAINS; d++) {
            prov.addAlias(dl, TOP_DL_ALIAS_NAME(td, domainIdx, d));
        }
    }
    // create dynamic groups and their aliases
    for (int dg = 0; dg < NUM_DYNAMIC_GROUPS; dg++) {
        Map<String, Object> dlAttrs = new HashMap<String, Object>();
        DynamicGroup dynGroup = prov.createDynamicGroup(DYNAMIC_GROUP_NAME(dg, domainIdx), dlAttrs);
        for (int d = 0; d < NUM_DOMAINS; d++) {
            prov.addGroupAlias(dynGroup, DYNAMIC_GROUP_ALIAS_NAME(dg, domainIdx, d));
        }
    }
}
Also used : Names(com.zimbra.qa.unittest.prov.Names) Account(com.zimbra.cs.account.Account) DynamicGroup(com.zimbra.cs.account.DynamicGroup) HashMap(java.util.HashMap) DistributionList(com.zimbra.cs.account.DistributionList)

Example 62 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class TestLdapProvSearchDirectory method getAllDistributionLists.

@Test
public void getAllDistributionLists() throws Exception {
    DistributionList dl = createDistributionList(genGroupNameLocalPart());
    List<DistributionList> dls = prov.getAllDistributionLists(domain);
    Verify.verifyEquals(Lists.newArrayList(dl), dls, true);
    deleteGroup(dl);
}
Also used : DistributionList(com.zimbra.cs.account.DistributionList) ProvTest(com.zimbra.qa.unittest.prov.ProvTest)

Example 63 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class TestLdapProvSearchDirectory method dnSubtreeMatchFilter.

@Test
public void dnSubtreeMatchFilter() throws Exception {
    String SUB_DOMAIN_BASE = genDomainSegmentName() + "." + baseDomainName();
    String SUB_DOMAIN_NAME = "sub." + SUB_DOMAIN_BASE;
    Domain subDomain = provUtil.createDomain(SUB_DOMAIN_NAME);
    String SUB_SUB_DOMAIN_NAME = "sub." + SUB_DOMAIN_NAME;
    Domain subSubDomain = provUtil.createDomain(SUB_SUB_DOMAIN_NAME);
    // create objects in subDomain
    Account acct = provUtil.createAccount(genAcctNameLocalPart("acct"), subDomain);
    DistributionList dl = provUtil.createDistributionList(genGroupNameLocalPart("dl"), subDomain);
    DynamicGroup dg = provUtil.createDynamicGroup(genGroupNameLocalPart("dg"), subDomain);
    // create objects in subSubDomain
    Account acctSub = provUtil.createAccount(genAcctNameLocalPart("acct"), subSubDomain);
    DistributionList dlSub = provUtil.createDistributionList(genGroupNameLocalPart("dl"), subSubDomain);
    DynamicGroup dgSub = provUtil.createDynamicGroup(genGroupNameLocalPart("dg"), subSubDomain);
    SearchDirectoryOptions options;
    List<NamedEntry> entries;
    try {
        SKIP_FOR_INMEM_LDAP_SERVER(SkipTestReason.DN_SUBTREE_MATCH_FILTER);
        // do not specify a domain, so DnSubtreeMatchFilter won't be appened again in Ldapprovisioning
        options = new SearchDirectoryOptions();
        options.setTypes(ObjectType.accounts, ObjectType.distributionlists, ObjectType.dynamicgroups);
        options.setSortOpt(SortOpt.SORT_ASCENDING);
        options.setFilterString(FilterId.UNITTEST, ((LdapDomain) subDomain).getDnSubtreeMatchFilter().toFilterString());
        entries = prov.searchDirectory(options);
        Verify.verifyEquals(Lists.newArrayList(acct, dg, dl), entries, true);
    } catch (ProvTest.SkippedForInMemLdapServerException e) {
    }
    // specify a domain, search for accounts, distribution lists, and dynamic groups
    options = new SearchDirectoryOptions(subDomain);
    options.setTypes(ObjectType.accounts, ObjectType.distributionlists, ObjectType.dynamicgroups);
    options.setSortOpt(SortOpt.SORT_ASCENDING);
    options.setFilterString(FilterId.UNITTEST, null);
    entries = prov.searchDirectory(options);
    Verify.verifyEquals(Lists.newArrayList(acct, dg, dl), entries, true);
    // specify a domain, search for accounts, distribution lists
    options = new SearchDirectoryOptions(subDomain);
    options.setTypes(ObjectType.accounts, ObjectType.distributionlists);
    options.setSortOpt(SortOpt.SORT_ASCENDING);
    options.setFilterString(FilterId.UNITTEST, null);
    entries = prov.searchDirectory(options);
    Verify.verifyEquals(Lists.newArrayList(acct, dl), entries, true);
    // specify a domain, search for dynamic groups
    options = new SearchDirectoryOptions(subDomain);
    options.setTypes(ObjectType.dynamicgroups);
    options.setSortOpt(SortOpt.SORT_ASCENDING);
    options.setFilterString(FilterId.UNITTEST, null);
    entries = prov.searchDirectory(options);
    Verify.verifyEquals(Lists.newArrayList(dg), entries, true);
    // specify a domain, search for accounts and dynamic groups
    options = new SearchDirectoryOptions(subDomain);
    options.setTypes(ObjectType.accounts, ObjectType.dynamicgroups);
    options.setSortOpt(SortOpt.SORT_ASCENDING);
    options.setFilterString(FilterId.UNITTEST, null);
    entries = prov.searchDirectory(options);
    Verify.verifyEquals(Lists.newArrayList(acct, dg), entries, true);
    // cleanup
    deleteAccount(acct);
    deleteGroup(dl);
    deleteGroup(dg);
    deleteAccount(acctSub);
    deleteGroup(dlSub);
    deleteGroup(dgSub);
    deleteDomain(subSubDomain);
    deleteDomain(subDomain);
}
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) LdapDomain(com.zimbra.cs.account.ldap.entry.LdapDomain) Domain(com.zimbra.cs.account.Domain) LdapDomain(com.zimbra.cs.account.ldap.entry.LdapDomain) DistributionList(com.zimbra.cs.account.DistributionList) ProvTest(com.zimbra.qa.unittest.prov.ProvTest) ProvTest(com.zimbra.qa.unittest.prov.ProvTest)

Example 64 with DistributionList

use of com.zimbra.cs.account.DistributionList 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)

Example 65 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class TestLdapProvRenameDomain method setupDLs.

/*
     * add all accounts, nested Dls, and their aliases of the domain to all DLs of all domains
     */
private void setupDLs(int domainIdx) throws Exception {
    String domainName = DOMAIN_NAME(domainIdx);
    System.out.println("crossLinkDomain: " + domainName);
    // Domain sourceDomain = mProv.get(Provisioning.DomainBy.name, domainName);
    List<String>[][] nestedDLMembers = new ArrayList[NUM_DOMAINS][NUM_DLS_NESTED];
    List<String>[][] topDLMembers = new ArrayList[NUM_DOMAINS][NUM_DLS_TOP];
    List<String>[][] dynamicGroupMembers = new ArrayList[NUM_DOMAINS][NUM_DYNAMIC_GROUPS];
    for (int d = 0; d < NUM_DOMAINS; d++) {
        for (int nd = 0; nd < NUM_DLS_TOP; nd++) {
            nestedDLMembers[d][nd] = new ArrayList();
        }
        for (int td = 0; td < NUM_DLS_TOP; td++) {
            topDLMembers[d][td] = new ArrayList();
        }
        for (int dd = 0; dd < NUM_DYNAMIC_GROUPS; dd++) {
            dynamicGroupMembers[d][dd] = new ArrayList();
        }
    }
    // entries is set to the dynamic group.
    for (int a = 0; a < NUM_ACCOUNTS; a++) {
        Set<String> members = ACCOUNT_NAMES(a, domainIdx, false);
        for (int d = 0; d < NUM_DOMAINS; d++) {
            for (int nd = 0; nd < NUM_DLS_NESTED; nd++) {
                for (String m : members) nestedDLMembers[d][nd].add(m);
            }
            for (int td = 0; td < NUM_DLS_TOP; td++) {
                for (String m : members) topDLMembers[d][td].add(m);
            }
            for (int dd = 0; dd < NUM_DYNAMIC_GROUPS; dd++) {
                for (String m : members) dynamicGroupMembers[d][dd].add(m);
            }
        }
    }
    // add nested dls and their aliases to top dls
    for (int nd = 0; nd < NUM_DLS_NESTED; nd++) {
        Set<String> members = NESTED_DL_NAMES(nd, domainIdx, false);
        for (int d = 0; d < NUM_DOMAINS; d++) {
            for (int td = 0; td < NUM_DLS_TOP; td++) {
                for (String m : members) topDLMembers[d][td].add(m);
            }
        }
    }
    // now add them
    for (int d = 0; d < NUM_DOMAINS; d++) {
        for (int nd = 0; nd < NUM_DLS_NESTED; nd++) {
            DistributionList dl = prov.get(Key.DistributionListBy.name, NESTED_DL_NAME(nd, d));
            prov.addMembers(dl, nestedDLMembers[d][nd].toArray(new String[0]));
        }
        for (int td = 0; td < NUM_DLS_TOP; td++) {
            DistributionList dl = prov.get(Key.DistributionListBy.name, TOP_DL_NAME(td, d));
            prov.addMembers(dl, topDLMembers[d][td].toArray(new String[0]));
        }
        for (int dd = 0; dd < NUM_DYNAMIC_GROUPS; dd++) {
            Group dynGroup = prov.getGroup(Key.DistributionListBy.name, DYNAMIC_GROUP_NAME(dd, d));
            prov.addGroupMembers(dynGroup, dynamicGroupMembers[d][dd].toArray(new String[0]));
        }
    }
}
Also used : DynamicGroup(com.zimbra.cs.account.DynamicGroup) Group(com.zimbra.cs.account.Group) ArrayList(java.util.ArrayList) DistributionList(com.zimbra.cs.account.DistributionList)

Aggregations

DistributionList (com.zimbra.cs.account.DistributionList)120 Account (com.zimbra.cs.account.Account)58 Domain (com.zimbra.cs.account.Domain)43 HashMap (java.util.HashMap)24 Test (org.junit.Test)24 Provisioning (com.zimbra.cs.account.Provisioning)22 NamedEntry (com.zimbra.cs.account.NamedEntry)18 HashSet (java.util.HashSet)18 ArrayList (java.util.ArrayList)14 ServiceException (com.zimbra.common.service.ServiceException)13 AccountServiceException (com.zimbra.cs.account.AccountServiceException)13 Right (com.zimbra.cs.account.accesscontrol.Right)12 DynamicGroup (com.zimbra.cs.account.DynamicGroup)10 LdapDistributionList (com.zimbra.cs.account.ldap.entry.LdapDistributionList)10 Group (com.zimbra.cs.account.Group)9 GuestAccount (com.zimbra.cs.account.GuestAccount)9 LdapProv (com.zimbra.cs.account.ldap.LdapProv)8 List (java.util.List)7 Entry (com.zimbra.cs.account.Entry)6 LdapEntry (com.zimbra.cs.account.ldap.entry.LdapEntry)6