Search in sources :

Example 86 with DistributionList

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

the class TestDistListACL method testMilterGuestSendToDL.

/**
     * "gst" GranteeType testing.
     * Sender must match the configured guest email address.  The secret is ignored!
     */
@Test
public void testMilterGuestSendToDL() throws Exception {
    DistributionList dl = prov.createDistributionList(listAddress, new HashMap<String, Object>());
    String guestName = "fred@example.test";
    prov.grantRight("dl", TargetBy.name, listAddress, GranteeType.GT_GUEST.getCode(), GranteeBy.name, guestName, "", /* secret */
    RightConsts.RT_sendToDistList, (RightModifier) null);
    doCheckSentToDistListGuestRight(dl, guestName, guestName, true);
    doCheckSentToDistListGuestRight(dl, "pete@example.test", guestName, false);
    // Bug 83252 case shouldn't matter
    doCheckSentToDistListGuestRight(dl, "FreD@example.test", guestName, true);
}
Also used : DistributionList(com.zimbra.cs.account.DistributionList) Test(org.junit.Test)

Example 87 with DistributionList

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

the class TestDistListACL method testMilterDomainSendToDL.

/**
     * "dom" GranteeType testing.
     * Sender must exist and be in the domain that is allowed to send to the DL
     */
@Test
public void testMilterDomainSendToDL() throws Exception {
    DistributionList dl = prov.createDistributionList(listAddress, new HashMap<String, Object>());
    String user1email = TestUtil.getAddress(USER_NAME);
    Account user1account = TestUtil.getAccount(USER_NAME);
    prov.grantRight("dl", TargetBy.name, listAddress, GranteeType.GT_DOMAIN.getCode(), GranteeBy.name, user1account.getDomainName(), null, /* secret */
    RightConsts.RT_sendToDistList, (RightModifier) null);
    doCheckSentToDistListDomRight(dl, user1email, user1account.getDomainName(), true);
    doCheckSentToDistListDomRight(dl, "pete@example.test", user1account.getDomainName(), false);
    doCheckSentToDistListDomRight(dl, user1email.toUpperCase(Locale.ENGLISH), user1account.getDomainName(), true);
}
Also used : Account(com.zimbra.cs.account.Account) DistributionList(com.zimbra.cs.account.DistributionList) Test(org.junit.Test)

Example 88 with DistributionList

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

the class TestDistListACL method testMilterUserSendToDL.

/**
     * "usr" GranteeType testing.
     * Sender must match the configured user email address.
     */
@Test
public void testMilterUserSendToDL() throws Exception {
    DistributionList dl = prov.createDistributionList(listAddress, new HashMap<String, Object>());
    String user1email = TestUtil.getAddress(USER_NAME);
    String user2email = TestUtil.getAddress(USER_NAME2);
    prov.grantRight("dl", TargetBy.name, listAddress, GranteeType.GT_USER.getCode(), GranteeBy.name, user1email, null, /* secret */
    RightConsts.RT_sendToDistList, (RightModifier) null);
    doCheckSentToDistListUserRight(dl, user1email, user1email, true);
    doCheckSentToDistListUserRight(dl, "pete@example.test", user1email, false);
    doCheckSentToDistListUserRight(dl, user2email, user1email, false);
    doCheckSentToDistListUserRight(dl, user1email.toUpperCase(Locale.ENGLISH), user1email, true);
}
Also used : DistributionList(com.zimbra.cs.account.DistributionList) Test(org.junit.Test)

Example 89 with DistributionList

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

the class TestLdapProvSearchDirectory method renameDomainSearchAcctCrDl.

@Test
public void renameDomainSearchAcctCrDl() throws Exception {
    Account acct = createAccount(genAcctNameLocalPart("acct"));
    CalendarResource cr = createCalendarResource(genAcctNameLocalPart("cr"));
    DistributionList dl = createDistributionList(genGroupNameLocalPart("dl"));
    String domainDN = ((LdapDomain) domain).getDN();
    String searchBase = ((LdapProv) prov).getDIT().domainDNToAccountSearchDN(domainDN);
    final List<NamedEntry> entries = Lists.newArrayList();
    NamedEntry.Visitor visitor = new NamedEntry.Visitor() {

        @Override
        public void visit(NamedEntry entry) throws ServiceException {
            // System.out.println(entry.getName());
            entries.add(entry);
        }
    };
    SearchDirectoryOptions options = new SearchDirectoryOptions();
    options.setDomain(domain);
    options.setOnMaster(true);
    options.setFilterString(FilterId.RENAME_DOMAIN, null);
    options.setTypes(ObjectType.accounts, ObjectType.resources, ObjectType.distributionlists);
    prov.searchDirectory(options, visitor);
    Verify.verifyEquals(Lists.newArrayList(acct, cr, dl), entries, false);
    /*
         // legacy code and ldap trace
        int flags = Provisioning.SD_ACCOUNT_FLAG + Provisioning.SD_CALENDAR_RESOURCE_FLAG + Provisioning.SD_DISTRIBUTION_LIST_FLAG;
        ((LdapProvisioning) prov).searchObjects(null, null, searchBase, flags, visitor, 0);
         *
         Oct 12 22:10:43 pshao-macbookpro-2 slapd[3065]: conn=1081 op=434 SRCH base="ou=people,dc=com,dc=zimbra,dc=qa,dc=unittest,dc=testldapprovsearchdirectory" scope=2 deref=0 filter="(|(objectClass=zimbraAccount)(objectClass=zimbraDistributionList)(objectClass=zimbraCalendarResource))"
         Oct 12 22:10:43 pshao-macbookpro-2 slapd[3065]: conn=1081 op=434 SEARCH RESULT tag=101 err=0 nentries=3 text=

         */
    deleteAccount(acct);
    deleteAccount(cr);
    deleteGroup(dl);
}
Also used : Account(com.zimbra.cs.account.Account) NamedEntry(com.zimbra.cs.account.NamedEntry) SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions) LdapDomain(com.zimbra.cs.account.ldap.entry.LdapDomain) CalendarResource(com.zimbra.cs.account.CalendarResource) DistributionList(com.zimbra.cs.account.DistributionList) ProvTest(com.zimbra.qa.unittest.prov.ProvTest)

Example 90 with DistributionList

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

the class TestLdapProvSearchDirectory method getAllGroups.

@Test
public void getAllGroups() throws Exception {
    DistributionList dl = createDistributionList(genGroupNameLocalPart("dl"));
    DynamicGroup dg = createDynamicGroup(genGroupNameLocalPart("dg"));
    // create a sub domain
    String SUB_DOMAIN_NAME = "sub." + baseDomainName();
    Domain subDomain = provUtil.createDomain(SUB_DOMAIN_NAME, null);
    // create a DL and a DG in the sub domain
    DistributionList dlSub = createDistributionList(genGroupNameLocalPart("dl-sub"), subDomain);
    DynamicGroup dgSub = createDynamicGroup(genGroupNameLocalPart("dg-sub"), subDomain);
    List<Group> groups = prov.getAllGroups(domain);
    Verify.verifyEquals(Lists.newArrayList(dg, dl), groups, true);
    deleteGroup(dl);
    deleteGroup(dg);
    deleteGroup(dlSub);
    deleteGroup(dgSub);
}
Also used : DynamicGroup(com.zimbra.cs.account.DynamicGroup) DynamicGroup(com.zimbra.cs.account.DynamicGroup) Group(com.zimbra.cs.account.Group) 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)

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