Search in sources :

Example 11 with DynamicGroup

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

Example 12 with DynamicGroup

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);
}
Also used : DynamicGroup(com.zimbra.cs.account.DynamicGroup) LdapDynamicGroup(com.zimbra.cs.account.ldap.entry.LdapDynamicGroup) ServiceException(com.zimbra.common.service.ServiceException) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 13 with DynamicGroup

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);
}
Also used : DynamicGroup(com.zimbra.cs.account.DynamicGroup) LdapDynamicGroup(com.zimbra.cs.account.ldap.entry.LdapDynamicGroup) Server(com.zimbra.cs.account.Server) Test(org.junit.Test)

Example 14 with DynamicGroup

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);
}
Also used : DynamicGroup(com.zimbra.cs.account.DynamicGroup) LdapDynamicGroup(com.zimbra.cs.account.ldap.entry.LdapDynamicGroup) ServiceException(com.zimbra.common.service.ServiceException) Test(org.junit.Test)

Example 15 with DynamicGroup

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()));
}
Also used : DynamicGroup(com.zimbra.cs.account.DynamicGroup) LdapDynamicGroup(com.zimbra.cs.account.ldap.entry.LdapDynamicGroup) LdapAccount(com.zimbra.cs.account.ldap.entry.LdapAccount) GuestAccount(com.zimbra.cs.account.GuestAccount) Account(com.zimbra.cs.account.Account) Test(org.junit.Test)

Aggregations

DynamicGroup (com.zimbra.cs.account.DynamicGroup)24 LdapDynamicGroup (com.zimbra.cs.account.ldap.entry.LdapDynamicGroup)10 ServiceException (com.zimbra.common.service.ServiceException)9 Account (com.zimbra.cs.account.Account)9 DistributionList (com.zimbra.cs.account.DistributionList)9 Group (com.zimbra.cs.account.Group)7 Test (org.junit.Test)7 Domain (com.zimbra.cs.account.Domain)6 NamedEntry (com.zimbra.cs.account.NamedEntry)6 LdapDomain (com.zimbra.cs.account.ldap.entry.LdapDomain)5 HashMap (java.util.HashMap)5 Entry (com.zimbra.cs.account.Entry)4 GuestAccount (com.zimbra.cs.account.GuestAccount)3 SearchDirectoryOptions (com.zimbra.cs.account.SearchDirectoryOptions)3 ProvTest (com.zimbra.qa.unittest.prov.ProvTest)3 Element (com.zimbra.common.soap.Element)2 Provisioning (com.zimbra.cs.account.Provisioning)2 Names (com.zimbra.qa.unittest.prov.Names)2 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)2 HashSet (java.util.HashSet)2