use of com.fsck.k9.mail.internet.MimeMessage in project k-9 by k9mail.
the class MessageDecryptVerifierTest method findEncryptedPartsShouldReturnEmptyEncryptedPart.
@Test
public void findEncryptedPartsShouldReturnEmptyEncryptedPart() throws Exception {
MimeMessage message = new MimeMessage();
MimeMultipart multipartEncrypted = MimeMultipart.newInstance();
multipartEncrypted.setSubType("encrypted");
MimeMessageHelper.setBody(message, multipartEncrypted);
setContentTypeWithProtocol(message, MIME_TYPE_MULTIPART_ENCRYPTED, PROTCOL_PGP_ENCRYPTED);
List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(message);
assertEquals(1, encryptedParts.size());
assertSame(message, encryptedParts.get(0));
}
use of com.fsck.k9.mail.internet.MimeMessage in project k-9 by k9mail.
the class MessageDecryptVerifierTest method isPgpInlineMethods__withEncryptedDataAndLeadingGarbage__shouldReturnFalse.
@Test
public void isPgpInlineMethods__withEncryptedDataAndLeadingGarbage__shouldReturnFalse() throws Exception {
String pgpInlineData = "garbage!" + "-----BEGIN PGP MESSAGE-----\n" + "Header: Value\n" + "\n" + "base64base64base64base64\n" + "-----END PGP MESSAGE-----\n";
MimeMessage message = new MimeMessage();
message.setBody(new TextBody(pgpInlineData));
assertFalse(MessageDecryptVerifier.isPartPgpInlineEncryptedOrSigned(message));
assertFalse(MessageDecryptVerifier.isPartPgpInlineEncrypted(message));
}
use of com.fsck.k9.mail.internet.MimeMessage in project k-9 by k9mail.
the class MessageDecryptVerifierTest method findPrimaryCryptoPart_withSimplePgpInline.
@Test
public void findPrimaryCryptoPart_withSimplePgpInline() throws Exception {
List<Part> outputExtraParts = new ArrayList<>();
Message message = new MimeMessage();
MimeMessageHelper.setBody(message, new TextBody(PGP_INLINE_DATA));
Part cryptoPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, outputExtraParts);
assertSame(message, cryptoPart);
}
use of com.fsck.k9.mail.internet.MimeMessage in project k-9 by k9mail.
the class MessageDecryptVerifierTest method isPartPgpInlineEncrypted__withSignedData__shouldReturnFalse.
@Test
public void isPartPgpInlineEncrypted__withSignedData__shouldReturnFalse() throws Exception {
String pgpInlineData = "-----BEGIN PGP SIGNED MESSAGE-----\n" + "Header: Value\n" + "\n" + "-----BEGIN PGP SIGNATURE-----\n" + "Header: Value\n" + "\n" + "base64base64base64base64\n" + "-----END PGP SIGNED MESSAGE-----\n";
MimeMessage message = new MimeMessage();
message.setBody(new TextBody(pgpInlineData));
assertFalse(MessageDecryptVerifier.isPartPgpInlineEncrypted(message));
}
use of com.fsck.k9.mail.internet.MimeMessage in project k-9 by k9mail.
the class MessageDecryptVerifierTest method messageFromBody.
MimeMessage messageFromBody(BodyPart bodyPart) throws MessagingException {
MimeMessage message = new MimeMessage();
MimeMessageHelper.setBody(message, bodyPart.getBody());
return message;
}
Aggregations