This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 6637a40f8caf4f8c08d6bd1e58b194874fd87601 Author: Benoit Tellier <[email protected]> AuthorDate: Fri May 28 17:29:54 2021 +0700 JAMES-2157 Make it clear that HasMimeType do not walk the mime tree - Add a test - State it in the Java Doc - Explicitly say it in the online doc too. --- docs/modules/servers/partials/HasMimeType.adoc | 2 ++ .../james/transport/matchers/HasMimeType.java | 2 ++ .../james/transport/matchers/HasMimeTypeTest.java | 31 ++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/docs/modules/servers/partials/HasMimeType.adoc b/docs/modules/servers/partials/HasMimeType.adoc index 099ee3d..985f9a7 100644 --- a/docs/modules/servers/partials/HasMimeType.adoc +++ b/docs/modules/servers/partials/HasMimeType.adoc @@ -2,6 +2,8 @@ This matcher checks if the content type matches. +This matcher do not walk down the mime tree and stops at the top level mime part. + use: .... diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java index 2dcbc7e..8ca40b7 100644 --- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java +++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java @@ -42,6 +42,8 @@ import com.google.common.collect.ImmutableSet; /** * <p>This matcher checks if the content type matches.</p> * + * <p>This matcher do not walk down the mime tree and stops at the top level mime part.</p> + * * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre> */ public class HasMimeType extends GenericMatcher { diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java index 6ff4620..8cf7b1c 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java @@ -94,6 +94,37 @@ class HasMimeTypeTest { .filename("text_file.txt") .disposition("attachment"), MimeMessageBuilder.bodyPartBuilder() + .type("image/png") + .filename("file.png") + .disposition("attachment")) + .setSubject("test"); + + Mail mail = FakeMail.builder() + .name("mail") + .mimeMessage(message) + .sender(FROM) + .recipient(RECIPIENT) + .build(); + + assertThat(matcher.match(mail)).isEmpty(); + } + + @Test + void shouldNotMatchSubParts() throws Exception { + matcher.init(FakeMatcherConfig.builder() + .matcherName("HasMimeType") + .condition("application/zip") + .build()); + + MimeMessageBuilder message = MimeMessageBuilder.mimeMessageBuilder() + .setMultipartWithBodyParts( + MimeMessageBuilder.bodyPartBuilder() + .data("simple text") + .disposition("text"), + MimeMessageBuilder.bodyPartBuilder() + .filename("text_file.txt") + .disposition("attachment"), + MimeMessageBuilder.bodyPartBuilder() .type("application/zip") .filename("zip_file.zip") .disposition("attachment")) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
