use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class TestCalDav method testCreateModifyDeleteAttendeeModifyAndCancel.
/** Mostly checking that if attendees cease to exist (even via DLs) then modification and cancel iTip
* messages still work to the remaining attendees.
*/
@Test
public void testCreateModifyDeleteAttendeeModifyAndCancel() throws ServiceException, IOException {
Account dav1 = users[1].create();
Account dav2 = users[2].create();
Account dav3 = users[3].create();
Account dav4 = users[4].create();
DistributionList dl = TestUtil.createDistributionList(DL1);
String[] members = { dav4.getName() };
prov.addMembers(dl, members);
List<MailTarget> attendees = Lists.newArrayList();
attendees.add(dav1);
attendees.add(dav2);
attendees.add(dav3);
attendees.add(dl);
ZVCalendar vCal = simpleMeeting(dav1, attendees, "1", 8);
ZProperty uidProp = vCal.getComponent(ICalTok.VEVENT).getProperty(ICalTok.UID);
String uid = uidProp.getValue();
String davBaseName = uid + ".ics";
String url = String.format("%s%s", getFolderUrl(dav1, "Calendar"), davBaseName);
doIcalPut(url, dav1, zvcalendarToBytes(vCal), HttpStatus.SC_CREATED);
String inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav2, uid);
assertTrue("Found meeting request for newly created item", inboxhref.contains(uid));
doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav2, HttpStatus.SC_NO_CONTENT);
// attendee via DL
inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav4, uid);
assertTrue("Found meeting request for newly created item", inboxhref.contains(uid));
doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav4, HttpStatus.SC_NO_CONTENT);
vCal = simpleMeeting(dav1, attendees, uid, "2", 9);
doIcalPut(url, dav1, zvcalendarToBytes(vCal), HttpStatus.SC_CREATED);
inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav2, uid);
assertTrue("Found meeting request for newly created item", inboxhref.contains(uid));
doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav2, HttpStatus.SC_NO_CONTENT);
// attendee via DL
inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav4, uid);
assertTrue("Found meeting request for newly created item", inboxhref.contains(uid));
doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav4, HttpStatus.SC_NO_CONTENT);
// Test that iTip handling still happens when some of the attendees no longer exist.
users[3].cleanup();
// attendee via DL
users[4].cleanup();
vCal = simpleMeeting(dav1, attendees, uid, "3", 10);
doIcalPut(url, dav1, zvcalendarToBytes(vCal), HttpStatus.SC_CREATED);
inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav2, uid);
assertTrue("Found meeting request for newly created item", inboxhref.contains(uid));
doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav2, HttpStatus.SC_NO_CONTENT);
String dav2Url = String.format("%s%s", getFolderUrl(dav2, "Calendar"), davBaseName);
doGetMethod(dav2Url, dav2, HttpStatus.SC_OK);
// Cancel meeting by deleting it
doDeleteMethod(url, dav1, HttpStatus.SC_NO_CONTENT);
inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav2, uid);
assertTrue("Found meeting request for newly created item", inboxhref.contains(uid));
doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav2, HttpStatus.SC_NO_CONTENT);
// The associated calendar item should have been deleted as a result of the Cancel
doGetMethod(dav2Url, dav2, HttpStatus.SC_NOT_FOUND);
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class TestLdapProvDistributionList method getDlDistributionLists.
@Test
public void getDlDistributionLists() throws Exception {
String DL_NAME_1_LOCALPART = Names.makeDLNameLocalPart(genGroupNameLocalPart("dl-1"));
String DL_NAME_2_LOCALPART = Names.makeDLNameLocalPart(genGroupNameLocalPart("dl-2"));
DistributionList dl1 = createDistributionList(DL_NAME_1_LOCALPART);
DistributionList dl2 = createDistributionList(DL_NAME_2_LOCALPART);
String DL_NAME_LOCALPART = Names.makeDLNameLocalPart(genGroupNameLocalPart("dl"));
DistributionList dl = createDistributionList(DL_NAME_LOCALPART);
prov.addMembers(dl1, new String[] { dl2.getName() });
prov.addMembers(dl2, new String[] { dl.getName() });
Map<String, String> via = new HashMap<String, String>();
List<DistributionList> inDlsDirect = prov.getDistributionLists(dl, true, via);
assertEquals(1, inDlsDirect.size());
assertEquals(dl2.getId(), inDlsDirect.get(0).getId());
List<DistributionList> inDlsAll = prov.getDistributionLists(dl, false, via);
assertEquals(2, inDlsAll.size());
deleteDistributionList(dl);
deleteDistributionList(dl1);
deleteDistributionList(dl2);
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class TestLdapProvDistributionList method testCircular2.
@Test
public void testCircular2() throws Exception {
Domain domain = provUtil.createDomain(genDomainSegmentName() + "." + BASE_DOMAIN_NAME);
DistributionList group1 = provUtil.createDistributionList("group1", domain);
DistributionList group2 = provUtil.createDistributionList("group2", domain);
DistributionList group3 = provUtil.createDistributionList("group3", domain);
Account acct1 = provUtil.createAccount("acct1", domain);
Account acct2 = provUtil.createAccount("acct2", domain);
String acct1Id = acct1.getId();
String acct2Id = acct2.getId();
group1.addMembers(new String[] { group2.getName(), acct1.getName(), acct2.getName() });
group2.addMembers(new String[] { group3.getName() });
group3.addMembers(new String[] { group1.getName() });
Set<String> expectedAllGroups = new HashSet<String>();
Set<String> expectedDirectGroups = new HashSet<String>();
expectedAllGroups.add(group1.getName());
expectedAllGroups.add(group2.getName());
expectedAllGroups.add(group3.getName());
expectedDirectGroups.add(group1.getName());
verifyMembership(acct1Id, expectedAllGroups, expectedDirectGroups);
verifyMembership(acct2Id, expectedAllGroups, expectedDirectGroups);
}
use of com.zimbra.cs.account.DistributionList 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);
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class TestLdapProvDistributionList method createDistributionList.
@Test
public void createDistributionList() throws Exception {
String DL_NAME_LOCALPART = Names.makeDLNameLocalPart(genGroupNameLocalPart());
DistributionList dl = createDistributionList(DL_NAME_LOCALPART);
// make sure the group has a home server
Server homeServer = dl.getServer();
assertNotNull(homeServer);
deleteDistributionList(dl);
}
Aggregations