-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JAMES-4054 Update SMIMECheckSignatureIntegrationTest to include IsSMI…
…MESigned matcher (#2409)
- Loading branch information
1 parent
a120c9f
commit d8d8fc4
Showing
8 changed files
with
112 additions
and
6 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
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
80 changes: 80 additions & 0 deletions
80
mailet/crypto/src/test/java/org/apache/james/transport/matcher/IsSMIMESignedTest.java
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/**************************************************************** | ||
* Licensed to the Apache Software Foundation (ASF) under one * | ||
* or more contributor license agreements. See the NOTICE file * | ||
* distributed with this work for additional information * | ||
* regarding copyright ownership. The ASF licenses this file * | ||
* to you under the Apache License, Version 2.0 (the * | ||
* "License"); you may not use this file except in compliance * | ||
* with the License. You may obtain a copy of the License at * | ||
* * | ||
* http://www.apache.org/licenses/LICENSE-2.0 * | ||
* * | ||
* Unless required by applicable law or agreed to in writing, * | ||
* software distributed under the License is distributed on an * | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * | ||
* KIND, either express or implied. See the License for the * | ||
* specific language governing permissions and limitations * | ||
* under the License. * | ||
****************************************************************/ | ||
|
||
package org.apache.james.transport.matcher; | ||
|
||
import static org.apache.mailet.base.MailAddressFixture.RECIPIENT1; | ||
import static org.apache.mailet.base.MailAddressFixture.SENDER; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.apache.james.core.builder.MimeMessageBuilder; | ||
import org.apache.mailet.base.test.FakeMail; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
public class IsSMIMESignedTest { | ||
private IsSMIMESigned isSMIMESigned; | ||
|
||
@BeforeEach | ||
void beforeEach() { | ||
isSMIMESigned = new IsSMIMESigned(); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"multipart/signed", | ||
"application/pkcs7-signature", | ||
"application/x-pkcs7-signature", | ||
"application/pkcs7-mime; smime-type=signed-data; name=\"smime.p7m\"", | ||
"application/x-pkcs7-mime; smime-type=signed-data; name=\"smime.p7m\""}) | ||
void matchShouldReturnNonEmptyListWhenMessageContentTypeIsSMIMERelated(String contentType) throws Exception { | ||
FakeMail mail = FakeMail.builder() | ||
.name("mail") | ||
.mimeMessage(MimeMessageBuilder.mimeMessageBuilder().addHeader("Content-Type", contentType)) | ||
.sender(SENDER) | ||
.recipient(RECIPIENT1) | ||
.build(); | ||
assertThat(isSMIMESigned.match(mail)).isNotEmpty(); | ||
} | ||
|
||
@Test | ||
void matchShouldReturnNullWhenMessageContentTypeIsNotSMIMERelated() throws Exception { | ||
FakeMail mail = FakeMail.builder() | ||
.name("mail") | ||
.mimeMessage(MimeMessageBuilder.mimeMessageBuilder().addHeader("Content-Type", "text/plain")) | ||
.sender(SENDER) | ||
.recipient(RECIPIENT1) | ||
.build(); | ||
assertThat(isSMIMESigned.match(mail)).isNull(); | ||
} | ||
|
||
@Test | ||
void matchShouldReturnNullWhenMailIsNull() throws Exception { | ||
assertThat(isSMIMESigned.match(null)).isNull(); | ||
} | ||
|
||
@Test | ||
void matchShouldReturnNullWhenMessageIsNull() throws Exception { | ||
FakeMail mail = FakeMail.builder() | ||
.name("mail") | ||
.build(); | ||
assertThat(isSMIMESigned.match(mail)).isNull(); | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
server/mailet/integration-testing/src/main/resources/eml/non_smime_mail.eml
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
From: user@james.org | ||
To: user2@james.org | ||
Subject: test | ||
Message-ID: <df73c05a-2e18-3e22-040c-9eda6abe02ae@open-paas.org> | ||
Date: Fri, 1 Nov 2019 10:21:39 +0700 | ||
|
||
test SMIME |
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
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
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