Skip to content

Commit

Permalink
feat: [CO-850] show Disposition-Notification on GetMsg delegated requ…
Browse files Browse the repository at this point in the history
…ests (#354)

* refactor: refactor tests to use MailboxTestUtil

- move DirectInsertionMailboxManager to upper level
- refactor classes using DirectInsertionMailboxManager
- adapt SendMsgTest to new logic

* test: add characterization test about popup

- add characterization test in SendMsgTest with help of GreenMail

* feat: always parse Disposition-Notification-To

- do not skip Disposition-Notification-To for delegated requests

* chore: move test to GetMsgTest

- put back SendMsgTest

* chore: undo changes

- undo test refactor changes

* test: refactor test about Disposition-Notification

- check there is disposition-notification-to in GetMsg

* test: skip native required

- native is not loading for some reasons. Skip it during tests
  • Loading branch information
frisonisland authored Oct 19, 2023
1 parent 4f5e8e5 commit f8cbb88
Show file tree
Hide file tree
Showing 8 changed files with 336 additions and 122 deletions.
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,6 @@
<exclude>com.zimbra.cs.util.tnef.mapi.TestTnefTimeZone.java</exclude>
<!-- Exclude classes that were already excluded before maven migration -->
<exclude>com.zimbra.cs.mailbox.CalendarItemTest.java</exclude>
<exclude>com.zimbra.cs.service.mail.SendMsgTest.java</exclude>
<exclude>com.zimbra.cs.service.mail.CalendarRequestTest.java</exclude>
<exclude>com.zimbra.cs.service.mail.GetMsgTest.java</exclude>
<exclude>com.zimbra.cs.service.mail.SearchActionTest.java</exclude>
Expand Down
7 changes: 1 addition & 6 deletions store/src/main/java/com/zimbra/cs/service/mail/ToXML.java
Original file line number Diff line number Diff line change
Expand Up @@ -1843,12 +1843,7 @@ private static Element encodeMessageAsMPHelper(
m,
Mime.parseAddressHeader(mm.getHeader("Resent-From", null), false),
EmailType.RESENT_FROM);
// read-receipts only get sent by the mailbox's owner
if (!(octxt.isDelegatedRequest(msg.getMailbox())
&& octxt.isOnBehalfOfRequest(msg.getMailbox()))) {
addEmails(
m, Mime.parseAddressHeader(mm, "Disposition-Notification-To"), EmailType.READ_RECEIPT);
}
addEmails(m, Mime.parseAddressHeader(mm, "Disposition-Notification-To"), EmailType.READ_RECEIPT);

String calIntendedFor = msg.getCalendarIntendedFor();
m.addAttribute(MailConstants.A_CAL_INTENDED_FOR, calIntendedFor);
Expand Down
24 changes: 24 additions & 0 deletions store/src/test/java/com/zextras/mailbox/util/MailboxTestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@
import com.zimbra.cs.account.accesscontrol.RightManager;
import com.zimbra.cs.db.DbPool;
import com.zimbra.cs.db.HSQLDB;
import com.zimbra.cs.mailbox.DeliveryOptions;
import com.zimbra.cs.mailbox.Mailbox;
import com.zimbra.cs.mailbox.Message;
import com.zimbra.cs.mailbox.ScheduledTaskManager;
import com.zimbra.cs.mime.ParsedMessage;
import com.zimbra.cs.redolog.RedoLogProvider;
import com.zimbra.cs.store.StoreManager;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import javax.mail.internet.MimeMessage;

/**
* This utility class allows easy setup for the Mailbox environment using {@link #setUp()} method.
Expand All @@ -41,6 +47,7 @@ private MailboxTestUtil() {}
* @throws Exception
*/
public static void setUp() throws Exception {
System.setProperty("zimbra.native.required", "false");
System.setProperty(
"zimbra.config",
Objects.requireNonNull(
Expand Down Expand Up @@ -96,4 +103,21 @@ public static Account createAccountDefaultDomain(Map<String, Object> extraAttrs)
return Provisioning.getInstance()
.createAccount(UUID.randomUUID() + "@" + MailboxTestUtil.DEFAULT_DOMAIN, "password", attrs);
}

/**
* Saves a message in a mailbox. Used to simulate receiving of a message.
*
* @param mailbox mailbox where to save the message
* @param message message to save
* @return saved {@link javax.mail.Message}
* @throws ServiceException
* @throws IOException
*/
public static Message saveMsgInInbox(Mailbox mailbox, javax.mail.Message message)
throws ServiceException, IOException {
final ParsedMessage parsedMessage = new ParsedMessage((MimeMessage) message, false);
final DeliveryOptions deliveryOptions =
new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
return mailbox.addMessage(null, parsedMessage, deliveryOptions, null);
}
}
Loading

0 comments on commit f8cbb88

Please sign in to comment.