use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestJaxb method testAcceptSeriesDeclineInstance.
/**
* Bug 94018. Accepting series, then declining single instance leads to inconsistent display of attendee
* status for organizer copy for the declined instance.
* Test steps:
* 1. Invite 2 users to a daily meeting.
* 2. User 1 replies, accepting the daily meeting.
* 3. User 1 replies again, declining one of the instances in the daily meeting.
* 4. User 2 replies tentatively accepting the daily meeting.
*
* At the end of this, check that an exception has been created. Check that that exception registers
* the decline from user 1 AND the tentative acceptance from user2 that arrived later.
*/
@Test
public void testAcceptSeriesDeclineInstance() throws Exception {
TestUtil.createAccount(ORGANIZER);
TestUtil.createAccount(ATTENDEE1);
TestUtil.createAccount(ATTENDEE2);
String subject = NAME_PREFIX + " Daily";
ZMailbox organizerBox = TestUtil.getZMailbox(ORGANIZER);
ZMailbox attendeeBox = TestUtil.getZMailbox(ATTENDEE1);
ZMailbox attendee2Box = TestUtil.getZMailbox(ATTENDEE2);
String organizerEmail = organizerBox.getName();
// Create and send the daily meeting
InviteComponent inviteComp = new InviteComponent();
inviteComp.addAttendee(CalendarAttendee.createForAddressDisplaynameRolePartstatRsvp(attendeeBox.getName(), getCN(attendeeBox), "REQ", "NE", true));
inviteComp.addAttendee(CalendarAttendee.createForAddressDisplaynameRolePartstatRsvp(attendee2Box.getName(), getCN(attendee2Box), "REQ", "NE", true));
inviteComp.setStatus("CONF");
inviteComp.setFreeBusy("B");
inviteComp.setCalClass("PUB");
inviteComp.setTransparency("O");
inviteComp.setIsDraft(false);
inviteComp.setIsAllDay(false);
inviteComp.setDtStart(DtTimeInfo.createForDatetimeAndZone("20161008T130000", "Europe/London"));
inviteComp.setDtEnd(DtTimeInfo.createForDatetimeAndZone("20161008T140000", "Europe/London"));
inviteComp.setName(subject);
inviteComp.setLocation("room 101");
inviteComp.setOrganizer(CalOrganizer.createForAddress(organizerEmail));
inviteComp.setRecurrence(RecurrenceInfo.create(AddRecurrenceInfo.create(SimpleRepeatingRule.createFromFrequencyAndInterval("DAI", IntervalRule.create(1)))));
InvitationInfo invite = new InvitationInfo();
invite.setInviteComponent(inviteComp);
EmailAddrInfo attendeeAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(attendeeBox.getName(), getCN(attendeeBox), "t");
EmailAddrInfo attendeeAddr2 = EmailAddrInfo.createForAddressPersonalAndAddressType(attendee2Box.getName(), getCN(attendee2Box), "t");
MimePartInfo mimePart = MimePartInfo.createForContentType("multipart/alternative");
mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/plain", "invite body"));
mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/html", "<html><body><p><b>invite</b> body</p></body></html>"));
Msg msg = new Msg();
msg.setFolderId("10");
msg.setInvite(invite);
msg.addEmailAddress(attendeeAddr);
msg.addEmailAddress(attendeeAddr2);
msg.setSubject(subject);
msg.setMimePart(mimePart);
CreateAppointmentRequest createSeriesRequest = CreateAppointmentRequest.create(msg);
CreateAppointmentResponse caResp = organizerBox.invokeJaxb(createSeriesRequest);
Assert.assertNotNull("JAXB CreateAppointmentResponse object", caResp);
Assert.assertNotNull("JAXB CreateAppointmentResponse calItemId", caResp.getCalItemId());
Assert.assertNotNull("JAXB CreateAppointmentResponse invId", caResp.getCalInvId());
Assert.assertNotNull("JAXB CreateAppointmentResponse modified sequence ms", caResp.getModifiedSequence());
Assert.assertNotNull("JAXB CreateAppointmentResponse rev", caResp.getRevision());
ZMessage seriesInviteMsg = TestUtil.waitForMessage(attendeeBox, subject);
Assert.assertNotNull("ZMessage for series invite", seriesInviteMsg);
ZInvite seriesInvite = seriesInviteMsg.getInvite();
Assert.assertNotNull("ZInvite for series invite", seriesInvite);
// User 1 accepts the daily meeting
ZMessage seriesAcceptMsg = sendInviteReplyToSeries(attendeeBox, organizerBox, seriesInviteMsg.getId(), subject, "ACCEPT");
Assert.assertNotNull("ZMessage for series accept", seriesAcceptMsg);
// User 1 declines one instance of the daily meeting
SendInviteReplyRequest sirReq = new SendInviteReplyRequest(seriesInviteMsg.getId(), 0, /* componentNum */
"DECLINE");
sirReq.setIdentityId(attendeeBox.getAccountInfo(false).getId());
sirReq.setExceptionId(DtTimeInfo.createForDatetimeAndZone("20161011T130000", "Europe/London"));
sirReq.setUpdateOrganizer(true);
attendeeAddr.setAddressType("f");
mimePart = MimePartInfo.createForContentType("multipart/alternative");
mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/plain", "I won't attend on Tuesday, October 11, 2016."));
mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/html", "<html><body><p><b>I won't attend on Tuesday, October 11, 2016</b></p></body></html>"));
msg = new Msg();
msg.setReplyType("r");
msg.setIdentityId(attendeeBox.getAccountInfo(false).getId());
EmailAddrInfo orgAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(organizerBox.getName(), organizerBox.getName(), "t");
msg.addEmailAddress(orgAddr);
msg.addEmailAddress(attendeeAddr);
String declineSubject = "Decline: " + subject;
msg.setSubject(declineSubject);
msg.setMimePart(mimePart);
sirReq.setMsg(msg);
SendInviteReplyResponse sirResp = attendeeBox.invokeJaxb(sirReq);
Assert.assertNotNull("JAXB SendInviteReplyResponse object", sirResp);
ZMessage instanceDeclineMsg = TestUtil.waitForMessage(organizerBox, String.format("subject:\"%s\"", declineSubject));
Assert.assertNotNull("ZMessage for series accept", instanceDeclineMsg);
seriesInviteMsg = TestUtil.waitForMessage(attendee2Box, subject);
Assert.assertNotNull("ZMessage for series invite", seriesInviteMsg);
seriesInvite = seriesInviteMsg.getInvite();
Assert.assertNotNull("ZInvite for series invite", seriesInvite);
// User 2 tentatively accepts the daily meeting
ZMessage seriesTentativeMsg = sendInviteReplyToSeries(attendee2Box, organizerBox, seriesInviteMsg.getId(), subject, "TENTATIVE");
Assert.assertNotNull("ZMessage for series tentative", seriesTentativeMsg);
// Search for the organizer's calendar entry
SearchRequest sReq = new SearchRequest();
sReq.setSearchTypes(ZSearchParams.TYPE_APPOINTMENT);
sReq.setCalItemExpandStart(ymdStringToDate("2016-10-09"));
sReq.setCalItemExpandEnd(ymdStringToDate("2016-10-14"));
sReq.setQuery((String.format("in:Calendar and subject:%s", subject)));
SearchResponse sResp = organizerBox.invokeJaxb(sReq);
List<SearchHit> hits = sResp.getSearchHits();
Assert.assertNotNull("Organizer calendar Search hits at end", hits);
Assert.assertEquals("Num Organizer calendar hits at end", 1, hits.size());
SearchHit orgCalHit = hits.get(0);
Assert.assertTrue(orgCalHit instanceof AppointmentHitInfo);
AppointmentHitInfo orgApptHit = (AppointmentHitInfo) orgCalHit;
String seriesInviteId = orgApptHit.getInvId();
Assert.assertNotNull("Organizer Calendar at end - series invite id", seriesInviteId);
List<InstanceDataInfo> instances = orgApptHit.getInstances();
Assert.assertNotNull("Organizer Calendar at end - instances in expansion", instances);
Assert.assertEquals("Organizer Calendar at end - number of instances in expansion", 5, instances.size());
// The third entry in the list should be for the exception
String exceptionInviteId = instances.get(2).getInvId();
Assert.assertNotNull("Organizer Calendar at end - exception invite id", exceptionInviteId);
String exceptionRidZ = instances.get(2).getRecurIdZ();
Assert.assertNotNull("Organizer Calendar at end - exception invite RecurIdZ", exceptionRidZ);
// Do a GetMsg for the exception in the Organizer's calendar
MsgSpec gmeMsgSpec = new MsgSpec(exceptionInviteId);
gmeMsgSpec.setRecurIdZ(exceptionRidZ);
GetMsgRequest gmeReq = new GetMsgRequest(gmeMsgSpec);
GetMsgResponse gmeResp = organizerBox.invokeJaxb(gmeReq);
List<InviteComponentWithGroupInfo> eInviteComps = gmeResp.getMsg().getInvite().getInviteComponents();
Assert.assertEquals("Organizer Calendar at end - number of components in exception", 1, eInviteComps.size());
List<CalendarAttendeeWithGroupInfo> eAttendees = eInviteComps.get(0).getAttendees();
Assert.assertEquals("Organizer Calendar at end - number of attendees in exception", 2, eAttendees.size());
for (CalendarAttendeeWithGroupInfo eAttendee : eAttendees) {
String addr = eAttendee.getAddress();
String ptst = eAttendee.getPartStat();
if (addr.equals(attendeeBox.getName())) {
Assert.assertEquals("exception attendee1 partstat", "DE", ptst);
} else if (addr.equals(attendee2Box.getName())) {
Assert.assertEquals("exception attendee2 partstat", "TE", ptst);
} else {
Assert.fail(String.format("Unexpected attendee in exception [%s]", addr));
}
}
// Do a GetMsg for the series in the Organizer's calendar
MsgSpec gmsMsgSpec = new MsgSpec(seriesInviteId);
GetMsgRequest gmsReq = new GetMsgRequest(gmsMsgSpec);
GetMsgResponse gmsResp = organizerBox.invokeJaxb(gmsReq);
List<InviteComponentWithGroupInfo> sInviteComps = gmsResp.getMsg().getInvite().getInviteComponents();
Assert.assertEquals("Organizer Calendar at end - number of components in series", 1, sInviteComps.size());
List<CalendarAttendeeWithGroupInfo> sAttendees = sInviteComps.get(0).getAttendees();
Assert.assertEquals("Organizer Calendar at end - number of attendees in exception", 2, sAttendees.size());
for (CalendarAttendeeWithGroupInfo sAttendee : sAttendees) {
String addr = sAttendee.getAddress();
String ptst = sAttendee.getPartStat();
if (addr.equals(attendeeBox.getName())) {
Assert.assertEquals("exception attendee1 partstat", "AC", ptst);
} else if (addr.equals(attendee2Box.getName())) {
Assert.assertEquals("exception attendee2 partstat", "TE", ptst);
} else {
Assert.fail(String.format("Unexpected attendee in exception [%s]", addr));
}
}
}
use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestJaxb method acceptInvite.
private ZMessage acceptInvite(ZMailbox attendeeBox, ZMailbox organizerBox, ZMessage inviteMsg, String subject) throws Exception {
SendInviteReplyRequest sirReq = new SendInviteReplyRequest(inviteMsg.getId(), 0, /* componentNum */
"ACCEPT");
sirReq.setIdentityId(attendeeBox.getAccountInfo(false).getId());
// ZWC 8.6 and earlier used to set this to false. Now sets it to true.
sirReq.setUpdateOrganizer(true);
MimePartInfo mimePart = MimePartInfo.createForContentType("multipart/alternative");
mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/plain", "Accepting"));
mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/html", "<html><body><p><b>Accepting</b></p></body></html>"));
Msg msg = new Msg();
msg.setReplyType("r");
msg.setIdentityId(attendeeBox.getAccountInfo(false).getId());
EmailAddrInfo orgAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(organizerBox.getName(), organizerBox.getName(), "t");
EmailAddrInfo attendeeAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(attendeeBox.getName(), getCN(attendeeBox), "f");
msg.addEmailAddress(orgAddr);
msg.addEmailAddress(attendeeAddr);
String acceptSubject = "Accept: " + subject;
msg.setSubject(acceptSubject);
msg.setMimePart(mimePart);
sirReq.setMsg(msg);
SendInviteReplyResponse sirResp = attendeeBox.invokeJaxb(sirReq);
Assert.assertNotNull("JAXB SendInviteReplyResponse object", sirResp);
ZMessage inboxMsg = TestUtil.waitForMessage(organizerBox, String.format("subject:\"%s\"", acceptSubject));
Assert.assertNotNull("ZMessage for accept", inboxMsg);
return inboxMsg;
}
use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestCalDav method testAppleCaldavProxyFunctions.
/**
* http://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk/doc/Extensions/caldav-proxy.txt
* This is an Apple standard implemented by Apple Mac OSX at least up to Yosemite and offers a fairly simple
* sharing model for calendars. The model is simpler than Zimbra's native model and there are mismatches,
* for instance Zimbra requires the proposed delegate to accept shares.
*/
@Test
public void testAppleCaldavProxyFunctions() throws ServiceException, IOException {
Account sharer = dav3;
Account sharee1 = dav1;
Account sharee2 = dav2;
ZMailbox mboxSharer = TestUtil.getZMailbox(sharer.getName());
ZMailbox mboxSharee1 = TestUtil.getZMailbox(sharee1.getName());
ZMailbox mboxSharee2 = TestUtil.getZMailbox(sharee2.getName());
setZimbraPrefAppleIcalDelegationEnabled(mboxSharer, true);
setZimbraPrefAppleIcalDelegationEnabled(mboxSharee1, true);
setZimbraPrefAppleIcalDelegationEnabled(mboxSharee2, true);
// Test PROPPATCH to "calendar-proxy-read" URL
setGroupMemberSet(TestCalDav.getCalendarProxyReadUrl(sharer), sharer, sharee2);
// Test PROPPATCH to "calendar-proxy-write" URL
setGroupMemberSet(TestCalDav.getCalendarProxyWriteUrl(sharer), sharer, sharee1);
// verify that adding new members to groups triggered notification messages
List<ZMessage> msgs = TestUtil.waitForMessages(mboxSharee1, "in:inbox subject:\"Share Created: Calendar shared by \"", 1, 10000);
assertNotNull(String.format("Notification msgs for %s", sharee1.getName()), msgs);
assertEquals(String.format("num msgs for %s", sharee1.getName()), 1, msgs.size());
msgs = TestUtil.waitForMessages(mboxSharee2, "in:inbox subject:\"Share Created: Calendar shared by \"", 1, 10000);
assertNotNull(String.format("Notification msgs for %s", sharee2.getName()), msgs);
assertEquals(String.format("num msgs for %s", sharee2.getName()), 1, msgs.size());
// Simulate acceptance of the shares (would normally need to be done in ZWC
createCalendarMountPoint(mboxSharee1, sharer);
createCalendarMountPoint(mboxSharee2, sharer);
Document doc = delegateForExpandProperty(sharee1);
XPath xpath = XPathFactory.newInstance().newXPath();
xpath.setNamespaceContext(TestCalDav.NamespaceContextForXPath.forCalDAV());
XPathExpression xPathExpr;
try {
String xpathS = "/D:multistatus/D:response/D:href/text()";
xPathExpr = xpath.compile(xpathS);
NodeList result = (NodeList) xPathExpr.evaluate(doc, XPathConstants.NODESET);
assertEquals(String.format("num XPath nodes for %s for %s", xpathS, sharee1.getName()), 1, result.getLength());
String text = (String) xPathExpr.evaluate(doc, XPathConstants.STRING);
assertEquals("HREF for account owner", UrlNamespace.getPrincipalUrl(sharee1).replaceAll("@", "%40"), text);
xpathS = "/D:multistatus/D:response/D:propstat/D:prop/CS:calendar-proxy-write-for/D:response/D:href/text()";
xPathExpr = xpath.compile(xpathS);
result = (NodeList) xPathExpr.evaluate(doc, XPathConstants.NODESET);
assertEquals(String.format("num XPath nodes for %s for %s", xpathS, sharee1.getName()), 1, result.getLength());
text = (String) xPathExpr.evaluate(doc, XPathConstants.STRING);
assertEquals("HREF for sharer", UrlNamespace.getPrincipalUrl(sharer).replaceAll("@", "%40"), text);
} catch (XPathExpressionException e1) {
ZimbraLog.test.debug("xpath problem", e1);
}
// Check that proxy write has sharee1 in it
doc = groupMemberSetExpandProperty(sharer, sharee1, true);
// Check that proxy read has sharee2 in it
doc = groupMemberSetExpandProperty(sharer, sharee2, false);
String davBaseName = "notAllowed@There";
String url = String.format("%s%s", getFolderUrl(sharee1, "Shared Calendar"), davBaseName);
HttpMethodExecutor exe;
if (DebugConfig.enableDAVclientCanChooseResourceBaseName) {
exe = doIcalPut(url, sharee1, simpleEvent(sharer), HttpStatus.SC_CREATED);
// rest of test deals with how redirecting to new name works - not needed here
return;
} else {
exe = doIcalPut(url, sharee1, simpleEvent(sharer), HttpStatus.SC_MOVED_TEMPORARILY);
}
String location = exe.getNonNullHeaderValue("Location", "When creating in shared calendar");
url = String.format("%s%s", getFolderUrl(sharee1, "Shared Calendar"), location.substring(location.lastIndexOf('/') + 1));
doIcalPut(url, sharee1, simpleEvent(sharer), HttpStatus.SC_CREATED);
}
use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestLmtp method testDiskStreamingEmptyFolder.
/**
* Another test for bug 25484. Delivers a message to user1 and user2, then confirms that
* user1 can still read the message after user2 empties the folder that contains the message.
*/
@Test
public void testDiskStreamingEmptyFolder() throws Exception {
TestUtil.createAccount(USER2_NAME);
TestUtil.setServerAttr(Provisioning.A_zimbraMailDiskStreamingThreshold, "0");
String[] recipients = { TestUtil.getAddress(USER_NAME), TestUtil.getAddress(USER2_NAME) };
String subject = NAME_PREFIX + " testDiskStreamingMultipleRecipients";
ZMailbox mbox1 = TestUtil.getZMailbox(USER_NAME);
ZMailbox mbox2 = TestUtil.getZMailbox(USER2_NAME);
TestUtil.addMessageLmtp(subject, recipients, TestUtil.getAddress(USER_NAME));
TestUtil.waitForMessage(mbox1, "in:inbox subject:\"" + subject + "\"");
ZMessage msg2 = TestUtil.waitForMessage(mbox2, "in:inbox subject:\"" + subject + "\"");
// Test bug 25484. Have user2 move the message to a folder, empty the folder,
// and then have user1 read the message.
ZFolder folder2 = TestUtil.createFolder(mbox2, "/" + NAME_PREFIX + " testDiskStreamingEmptyFolder");
mbox2.moveMessage(msg2.getId(), folder2.getId());
// Mark message as read, since unread messages result in uncache
// getting called explicitly in Folder.propagateDeletion().
mbox2.markItemRead(msg2.getId(), true, null);
mbox2.emptyFolder(folder2.getId());
mbox1 = TestUtil.getZMailbox(USER_NAME);
TestUtil.waitForMessage(mbox1, "in:inbox subject:\"" + subject + "\"");
}
use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestLmtp method testDiskStreamingMultipleRecipients.
/**
* Confirms that mail can successfully be delivered to multiple users when streaming to disk.
*/
@Test
public void testDiskStreamingMultipleRecipients() throws Exception {
TestUtil.createAccount(USER2_NAME);
TestUtil.setServerAttr(Provisioning.A_zimbraMailDiskStreamingThreshold, "0");
String[] recipients = { TestUtil.getAddress(USER_NAME), TestUtil.getAddress(USER2_NAME) };
String subject = NAME_PREFIX + " testDiskStreamingMultipleRecipients";
ZMailbox mbox1 = TestUtil.getZMailbox(USER_NAME);
ZMailbox mbox2 = TestUtil.getZMailbox(USER2_NAME);
TestUtil.addMessageLmtp(subject, recipients, TestUtil.getAddress(USER_NAME));
TestUtil.waitForMessage(mbox1, "in:inbox subject:\"" + subject + "\"");
ZMessage msg2 = TestUtil.waitForMessage(mbox2, "in:inbox subject:\"" + subject + "\"");
// Test bug 25484. Make sure that user1 can still read the message after user2
// deletes it.
mbox2.deleteMessage(msg2.getId());
mbox1 = TestUtil.getZMailbox(USER_NAME);
TestUtil.waitForMessage(mbox1, "in:inbox subject:\"" + subject + "\"");
}
Aggregations