This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit fa5581f5d5bd284d60e68d7470470dcadcf4e02f Author: Benoit TELLIER <[email protected]> AuthorDate: Wed Feb 14 00:58:30 2024 +0100 [FIX] Add tests for multipart/alternative in OpenSearch test suite --- .../json/MessageToOpenSearchJsonTest.java | 46 +++++++++++++++++++++ .../src/test/resources/eml/alternative.eml | 45 ++++++++++++++++++++ .../src/test/resources/eml/alternative.json | 48 ++++++++++++++++++++++ .../src/test/resources/eml/alternative_simple.eml | 22 ++++++++++ .../src/test/resources/eml/alternative_simple.json | 37 +++++++++++++++++ 5 files changed, 198 insertions(+) diff --git a/mailbox/opensearch/src/test/java/org/apache/james/mailbox/opensearch/json/MessageToOpenSearchJsonTest.java b/mailbox/opensearch/src/test/java/org/apache/james/mailbox/opensearch/json/MessageToOpenSearchJsonTest.java index ab2b55fe0d..3b19c4a660 100644 --- a/mailbox/opensearch/src/test/java/org/apache/james/mailbox/opensearch/json/MessageToOpenSearchJsonTest.java +++ b/mailbox/opensearch/src/test/java/org/apache/james/mailbox/opensearch/json/MessageToOpenSearchJsonTest.java @@ -113,6 +113,52 @@ class MessageToOpenSearchJsonTest { .isEqualTo(ClassLoaderUtils.getSystemResourceAsString("eml/spamMail.json")); } + @Test + void alternative() throws IOException { + MessageToOpenSearchJson messageToOpenSearchJson = new MessageToOpenSearchJson( + new DefaultTextExtractor(), + ZoneId.of("Europe/Paris"), IndexAttachments.YES, IndexHeaders.YES); + MailboxMessage spamMail = new SimpleMailboxMessage(MESSAGE_ID, + THREAD_ID, + date, + SIZE, + BODY_START_OCTET, + new ByteContent(IOUtils.toByteArray(ClassLoaderUtils.getSystemResourceAsSharedStream("eml/alternative.eml"))), + new Flags(), + propertyBuilder.build(), + MAILBOX_ID); + spamMail.setUid(UID); + spamMail.setModSeq(MOD_SEQ); + + assertThatJson(messageToOpenSearchJson.convertToJson(spamMail).block()) + .when(IGNORING_ARRAY_ORDER) + .whenIgnoringPaths("headers") + .isEqualTo(ClassLoaderUtils.getSystemResourceAsString("eml/alternative.json")); + } + + @Test + void alternativeSimple() throws IOException { + MessageToOpenSearchJson messageToOpenSearchJson = new MessageToOpenSearchJson( + new DefaultTextExtractor(), + ZoneId.of("Europe/Paris"), IndexAttachments.YES, IndexHeaders.YES); + MailboxMessage spamMail = new SimpleMailboxMessage(MESSAGE_ID, + THREAD_ID, + date, + SIZE, + BODY_START_OCTET, + new ByteContent(IOUtils.toByteArray(ClassLoaderUtils.getSystemResourceAsSharedStream("eml/alternative_simple.eml"))), + new Flags(), + propertyBuilder.build(), + MAILBOX_ID); + spamMail.setUid(UID); + spamMail.setModSeq(MOD_SEQ); + + assertThatJson(messageToOpenSearchJson.convertToJson(spamMail).block()) + .when(IGNORING_ARRAY_ORDER) + .whenIgnoringPaths("headers") + .isEqualTo(ClassLoaderUtils.getSystemResourceAsString("eml/alternative_simple.json")); + } + @Test void badContentDescriptionShouldStillBeIndexed() throws IOException { MessageToOpenSearchJson messageToOpenSearchJson = new MessageToOpenSearchJson( diff --git a/mailbox/opensearch/src/test/resources/eml/alternative.eml b/mailbox/opensearch/src/test/resources/eml/alternative.eml new file mode 100644 index 0000000000..812cdb9e44 --- /dev/null +++ b/mailbox/opensearch/src/test/resources/eml/alternative.eml @@ -0,0 +1,45 @@ +MIME-Version: 1.0 +Subject: Test +From: Benoit TELLIER <[email protected]> +To: Benoit TELLIER <[email protected]> +Date: Tue, 13 Feb 2024 23:01:18 +0000 +Message-ID: <[email protected]> +Content-Type: multipart/mixed; + boundary="-=Part.17f.732e3d28e1c76db4.18da4b40791.62ef5e3fa995057d=-" + +---=Part.17f.732e3d28e1c76db4.18da4b40791.62ef5e3fa995057d=- +Content-Type: multipart/alternative; + boundary="-=Part.17e.48ac92d73c356567.18da4b40791.360a293e2f389efe=-" + +---=Part.17e.48ac92d73c356567.18da4b40791.360a293e2f389efe=- +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +Test + +---=Part.17e.48ac92d73c356567.18da4b40791.360a293e2f389efe=- +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +<div>Test<br><br></div> + +---=Part.17e.48ac92d73c356567.18da4b40791.360a293e2f389efe=--- + +---=Part.17f.732e3d28e1c76db4.18da4b40791.62ef5e3fa995057d=- +Content-Type: text/plain; name="=?US-ASCII?Q?id=5Frsa.txt?=" +Content-Disposition: attachment +Content-Transfer-Encoding: base64 + +c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFDQVFDa0dXMkp5c2lKR2hQZXdBOXRr +bVFFQm5EVjRaQ0llLy92ZFoyV0RybnZiNlZLQzdpWldjODFpU1ZkTFcxUkRBTll4c3ExN0dQanpV +OFlWdk9sRkFJSk1WTm9ESWhuQWtYOU9VUUJpd1hpOHlHZ3FLNGR0RmIxczJBRzNrQmxNUFFJOE5K +MkpLT2Z5MW51VnJubEtoVDlCVnpYMm5iSjNOak9PZlkxQlJEaDZZcVl1a2RuejBUT2k1Rkp1YUJT +NDZQemx3eWdIa0dzeXBLVHM2Y2FUNjBRdjl3eWFadm4yenN1RmNML3o2Mmd3aGZyZGFsakF1UGRX +cERlNG1IRVFmMXA2SXNRMDdPb0lwTmRHQ0tLZHRZQlVTcktzTXRpMllLUGZpSzB2WGU1L3owRWJE +VlRja1BrY3NwQ2cwYVZuZTB2eFVsRGt2U2pwV2tiQkZ0YTk5ekJjOVlJL0ROK28vRmtONlFTdXV5 +U29tNDZkamZpUjdqSzNMRmJKUkhaem9BblNvaTZvRlR0MW1LWjNzam44bnZWUG1PV3pJWHY0Tm1O +R1ExZHFrV1hXcUtyQjlIZUZiQnRPWVAzaEkxQ0kvaVhNbVR1SkdvcHVTUmlTNW1QZXlSQWV6VGtk +UG8vZ2NSVWNzbklhVW1EallUWHBFNzU3Yk5LWVNHbFJsS3FrbEhKc2JveEdTK0NaVzBJS2dZeTdG +cmZRZ1FGMTdvaUpWM1JJQ1VHcU9rM1I2VnZOYlhlL2VmZS9IT24xd0lZUS9qVGRzY0hCamRIM2FF +MmY4Y3dVS1IzNUtWNlJ1SE4vYVpiekxiVkJxUEMvUTcwd3NMQlloV29Da1dRMElUUmxGV2N3bnN3 +VTE5NnlGWkVHSmthOUNEaHZQdUVBV0NLWnFRT3gyMnRoYWVSQlE9PSBiZW53YUBob3Jpem9uCg== \ No newline at end of file diff --git a/mailbox/opensearch/src/test/resources/eml/alternative.json b/mailbox/opensearch/src/test/resources/eml/alternative.json new file mode 100644 index 0000000000..3cdb6043d1 --- /dev/null +++ b/mailbox/opensearch/src/test/resources/eml/alternative.json @@ -0,0 +1,48 @@ +{ + "attachments":[ + { + "mediaType":"text", + "subtype":"plain", + "fileName":null, + "fileExtension":null, + "contentDisposition":"attachment", + "textContent":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCkGW2JysiJGhPewA9tkmQEBnDV4ZCIe//vdZ2WDrnvb6VKC7iZWc81iSVdLW1RDANYxsq17GPjzU8YVvOlFAIJMVNoDIhnAkX9OUQBiwXi8yGgqK4dtFb1s2AG3kBlMPQI8NJ2JKOfy1nuVrnlKhT9BVzX2nbJ3NjOOfY1BRDh6YqYukdnz0TOi5FJuaBS46PzlwygHkGsypKTs6caT60Qv9wyaZvn2zsuFcL/z62gwhfrdaljAuPdWpDe4mHEQf1p6IsQ07OoIpNdGCKKdtYBUSrKsMti2YKPfiK0vXe5/z0EbDVTckPkcspCg0aVne0vxUlDkvSjpWkbBFta99zBc9YI/DN+o/FkN6QSuuySom46djfiR7jK3LFbJRHZzoAnSoi6oFTt1mKZ3sjn8nvVPmOWzIXv4NmNGQ1dqkWXWqKrB9H [...] + } + ], + "bcc":[], + "htmlBody":null, + "textBody":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCkGW2JysiJGhPewA9tkmQEBnDV4ZCIe//vdZ2WDrnvb6VKC7iZWc81iSVdLW1RDANYxsq17GPjzU8YVvOlFAIJMVNoDIhnAkX9OUQBiwXi8yGgqK4dtFb1s2AG3kBlMPQI8NJ2JKOfy1nuVrnlKhT9BVzX2nbJ3NjOOfY1BRDh6YqYukdnz0TOi5FJuaBS46PzlwygHkGsypKTs6caT60Qv9wyaZvn2zsuFcL/z62gwhfrdaljAuPdWpDe4mHEQf1p6IsQ07OoIpNdGCKKdtYBUSrKsMti2YKPfiK0vXe5/z0EbDVTckPkcspCg0aVne0vxUlDkvSjpWkbBFta99zBc9YI/DN+o/FkN6QSuuySom46djfiR7jK3LFbJRHZzoAnSoi6oFTt1mKZ3sjn8nvVPmOWzIXv4NmNGQ1dqkWXWqKrB9HeFbBtOY [...] + "cc":[], + "date":"2015-06-07T00:00:00+0200", + "from":[{"name":"Benoit TELLIER","address":"[email protected]","domain":"linagora"}], + "hasAttachment":false, + "headers":[ + {"name":"mime-version","value":"1.0"}, + {"name":"subject","value":"Test"}, + {"name":"from","value":"Benoit TELLIER <[email protected]>"}, + {"name":"to","value":"Benoit TELLIER <[email protected]>"}, + {"name":"date","value":"Tue, 13 Feb 2024 23:01:18 +0000"}, + {"name":"message-id","value":"<[email protected]>"}, + {"name":"content-type","value":"multipart/mixed; boundary=\"-=Part.17f.732e3d28e1c76db4.18da4b40791.62ef5e3fa995057d=-\""} + ], + "mailboxId":"18", + "mediaType":"plain", + "messageId":"184", + "threadId":"184", + "modSeq":42, + "sentDate":"2024-02-13T23:01:18+0000", + "saveDate":null, + "size":25, + "subject":["Test"], + "subtype":"text", + "to":[{"name":"Benoit TELLIER","address":"[email protected]","domain":"linagora"}], + "uid":25, + "userFlags":[], + "mimeMessageID":"<[email protected]>", + "isAnswered":false, + "isDeleted":false, + "isDraft":false, + "isFlagged":false, + "isRecent":false, + "isUnread":true +} diff --git a/mailbox/opensearch/src/test/resources/eml/alternative_simple.eml b/mailbox/opensearch/src/test/resources/eml/alternative_simple.eml new file mode 100644 index 0000000000..e26c5efa6e --- /dev/null +++ b/mailbox/opensearch/src/test/resources/eml/alternative_simple.eml @@ -0,0 +1,22 @@ +MIME-Version: 1.0 +Subject: Test +From: Benoit TELLIER <[email protected]> +To: Benoit TELLIER <[email protected]> +Date: Tue, 13 Feb 2024 23:01:18 +0000 +Message-ID: <[email protected]> +Content-Type: multipart/alternative; + boundary="-=Part.17e.48ac92d73c356567.18da4b40791.360a293e2f389efe=-" + +---=Part.17e.48ac92d73c356567.18da4b40791.360a293e2f389efe=- +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +Test + +---=Part.17e.48ac92d73c356567.18da4b40791.360a293e2f389efe=- +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +<div>Test<br><br></div> + +---=Part.17e.48ac92d73c356567.18da4b40791.360a293e2f389efe=--- diff --git a/mailbox/opensearch/src/test/resources/eml/alternative_simple.json b/mailbox/opensearch/src/test/resources/eml/alternative_simple.json new file mode 100644 index 0000000000..a3640dc0e8 --- /dev/null +++ b/mailbox/opensearch/src/test/resources/eml/alternative_simple.json @@ -0,0 +1,37 @@ +{ + "attachments":[], + "bcc":[], + "htmlBody":"<div>Test<br><br></div>\r\n", + "textBody":"Test\r\n", + "cc":[], + "date":"2015-06-07T00:00:00+0200", + "from":[{"name":"Benoit TELLIER","address":"[email protected]","domain":"linagora"}], + "hasAttachment":false,"headers":[ + {"name":"mime-version","value":"1.0"}, + {"name":"subject","value":"Test"}, + {"name":"from","value":"Benoit TELLIER <[email protected]>"}, + {"name":"to","value":"Benoit TELLIER <[email protected]>"}, + {"name":"date","value":"Tue, 13 Feb 2024 23:01:18 +0000"}, + {"name":"message-id","value":"<[email protected]>"}, + {"name":"content-type","value":"multipart/alternative; boundary=\"-=Part.17e.48ac92d73c356567.18da4b40791.360a293e2f389efe=-\""} +], + "mailboxId":"18", + "mediaType":"plain", + "messageId":"184", + "threadId":"184", + "modSeq":42, + "sentDate":"2024-02-13T23:01:18+0000", + "saveDate":null, + "size":25, + "subject":["Test"], + "subtype":"text", + "to":[{"name":"Benoit TELLIER","address":"[email protected]","domain":"linagora"}], + "uid":25, + "userFlags":[], + "mimeMessageID":"<[email protected]>", + "isAnswered":false, + "isDeleted":false, + "isDraft":false, + "isFlagged":false, + "isRecent":false,"isUnread":true +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
