-
-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
13 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,8 @@ private static EmailFromOutlookMessage buildEmailFromOutlookMessage( | |
checkNonEmptyArgument(outlookMessage, "outlookMessage"); | ||
String fromEmail = ofNullable(outlookMessage.getFromEmail()).orElse("[email protected]"); | ||
builder.from(outlookMessage.getFromName(), fromEmail); | ||
builder.fixingMessageId(outlookMessage.getMessageId()); | ||
builder.fixingSentDate(ofNullable(outlookMessage.getClientSubmitTime()).orElse(outlookMessage.getDate())); // FIXME creation date? | ||
if (!MiscUtil.valueNullOrEmpty(outlookMessage.getReplyToEmail())) { | ||
builder.withReplyTo(outlookMessage.getReplyToName(), outlookMessage.getReplyToEmail()); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,9 +71,7 @@ public void testSMIMEMessageFromOutlookMsgWithDefaultMergeBehavior() { | |
// verify msg that was sent with Outlook against eml that was received in Thunderbird | ||
EmailPopulatingBuilder fromEmlBuilder = EmailConverter.emlToEmailBuilder(new File(RESOURCE_FOLDER + "/SMIME (signed and clear text).eml")); | ||
Email emailExpectedFromEml = fromEmlBuilder | ||
.clearId() // set by Outlook when sending, so is missing in the saved .msg from before sending | ||
.clearSentDate() // same | ||
.clearHeaders() // same | ||
.clearHeaders() // set by Outlook when sending, so is missing in the saved .msg from before sending | ||
.clearReplyTo() // same | ||
.clearBounceTo() // same | ||
.from(assumeNonNull(fromEmlBuilder.getFromRecipient()).getName(), "[email protected]") | ||
|
@@ -156,9 +154,7 @@ public void testSMIMEMessageFromOutlookMsgWithNonMergingBehavior() { | |
// verify msg that was sent with Outlook against eml that was received in Thunderbird | ||
EmailPopulatingBuilder fromEmlBuilder = EmailConverter.emlToEmailBuilder(new File(RESOURCE_FOLDER + "/SMIME (signed and clear text).eml")); | ||
Email emailExpectedFromEml = fromEmlBuilder | ||
.clearId() // set by Outlook when sending, so is missing in the saved .msg from before sending | ||
.clearSentDate() // same | ||
.clearHeaders() // same | ||
.clearHeaders() // set by Outlook when sending, so is missing in the saved .msg from before sending | ||
.clearReplyTo() // same | ||
.clearBounceTo() // same | ||
.from(assumeNonNull(fromEmlBuilder.getFromRecipient()).getName(), "[email protected]") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,7 +106,7 @@ public void createMailSession_StandardDummyMailWithIdAndSendDate() | |
@Test | ||
public void createMailSession_OutlookMessageTest() | ||
throws IOException, MessagingException, ExecutionException, InterruptedException { | ||
Email email = assertSendingEmail(readOutlookMessage("test-messages/HTML mail with replyto and attachment and embedded image.msg"), false, false, false, false); | ||
Email email = assertSendingEmail(readOutlookMessage("test-messages/HTML mail with replyto and attachment and embedded image.msg"), false, false, false, true); | ||
verifyReceivedOutlookEmail(email, false, false); | ||
} | ||
|
||
|
@@ -115,7 +115,7 @@ public void createMailSession_OutlookMessageSmimeSignTest() | |
throws IOException, MessagingException, ExecutionException, InterruptedException { | ||
EmailPopulatingBuilder builder = readOutlookMessage("test-messages/HTML mail with replyto and attachment and embedded image.msg"); | ||
builder.signWithSmime(new File(RESOURCES_PKCS + "/smime_keystore.pkcs12"), "letmein", "smime_test_user_alias", "letmein"); | ||
Email email = assertSendingEmail(builder, false, true, false, false); | ||
Email email = assertSendingEmail(builder, false, true, false, true); | ||
verifyReceivedOutlookEmail(email, true, false); | ||
|
||
EmailAssert.assertThat(email).wasNotMergedWithSmimeSignedMessage(); | ||
|
@@ -135,7 +135,7 @@ public void createMailSession_OutlookMessageSmimeEncryptTest() | |
throws IOException, MessagingException, ExecutionException, InterruptedException { | ||
EmailPopulatingBuilder builder = readOutlookMessage("test-messages/HTML mail with replyto and attachment and embedded image.msg"); | ||
builder.encryptWithSmime(new File(RESOURCES_PKCS + "/smime_test_user.pem.standard.crt")); | ||
Email email = assertSendingEmail(builder, false, true, false, false); | ||
Email email = assertSendingEmail(builder, false, true, false, true); | ||
verifyReceivedOutlookEmail(email, false, true); | ||
|
||
EmailAssert.assertThat(email).wasMergedWithSmimeSignedMessage(); | ||
|
@@ -154,7 +154,7 @@ public void createMailSession_OutlookMessageSmimeSignEncryptTest() | |
EmailPopulatingBuilder builder = readOutlookMessage("test-messages/HTML mail with replyto and attachment and embedded image.msg"); | ||
builder.signWithSmime(new File(RESOURCES_PKCS + "/smime_keystore.pkcs12"), "letmein", "smime_test_user_alias", "letmein"); | ||
builder.encryptWithSmime(new File(RESOURCES_PKCS + "/smime_test_user.pem.standard.crt")); | ||
Email email = assertSendingEmail(builder, false, true, false, false); | ||
Email email = assertSendingEmail(builder, false, true, false, true); | ||
verifyReceivedOutlookEmail(email, true, true); | ||
|
||
EmailAssert.assertThat(email).wasMergedWithSmimeSignedMessage(); | ||
|
@@ -230,7 +230,7 @@ private void verifyReceivedOutlookEmail(final Email email, final boolean smimeSi | |
} | ||
|
||
private Email assertSendingEmail(final EmailPopulatingBuilder originalEmailPopulatingBuilder, boolean compensateForDresscodeAttachmentNameOverrideErasure, boolean skipChecksDueToSmime, | ||
boolean async, final boolean fixedSentDate) | ||
boolean async, final boolean sentDateWasFixed) | ||
throws MessagingException, ExecutionException, InterruptedException { | ||
Email originalEmail = originalEmailPopulatingBuilder.buildEmail(); | ||
|
||
|
@@ -250,12 +250,12 @@ private Email assertSendingEmail(final EmailPopulatingBuilder originalEmailPopul | |
|
||
Email receivedEmail = mimeMessageToEmail(receivedMimeMessage.getMimeMessage(), loadPkcs12KeyStore()); | ||
|
||
if (!fixedSentDate) { | ||
if (!sentDateWasFixed) { | ||
GregorianCalendar receiveWindowStart = new GregorianCalendar(); | ||
receiveWindowStart.add(Calendar.SECOND, -5); | ||
assertThat(receivedEmail.getSentDate()).isBetween(receiveWindowStart.getTime(), new Date()); | ||
} else { | ||
assertThat(receivedEmail.getSentDate()).isEqualTo(CUSTOM_SENT_DATE); | ||
assertThat(receivedEmail.getSentDate()).isEqualTo(originalEmailPopulatingBuilder.getSentDate()); | ||
} | ||
|
||
// ID will always be generated when sending: if set to a specific value, just assume the generated one | ||
|
@@ -308,7 +308,7 @@ public void createMailSession_ReplyToMessage() | |
|
||
// send reply to initial mail | ||
Email reply = EmailBuilder | ||
.replyingToAll(assertSendingEmail(receivedEmailPopulatingBuilder, false, false, false, false)) | ||
.replyingToAll(assertSendingEmail(receivedEmailPopulatingBuilder, false, false, false, true)) | ||
.from("[email protected]") | ||
.withPlainText("This is the reply") | ||
.buildEmail(); | ||
|
@@ -340,7 +340,7 @@ public void createMailSession_ReplyToMessage_NotAll_AndCustomReferences() | |
|
||
// send reply to initial mail | ||
Email reply = EmailBuilder | ||
.replyingTo(assertSendingEmail(receivedEmailPopulatingBuilder, false, false, false, false)) | ||
.replyingTo(assertSendingEmail(receivedEmailPopulatingBuilder, false, false, false, true)) | ||
.from("Moo Shmoo", "[email protected]") | ||
.withPlainText("This is the reply") | ||
.buildEmail(); | ||
|