Search in sources :

Example 41 with MimeMessage

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));
}
Also used : MimeMessage(com.fsck.k9.mail.internet.MimeMessage) MimeMultipart(com.fsck.k9.mail.internet.MimeMultipart) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Test(org.junit.Test)

Example 42 with MimeMessage

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));
}
Also used : TextBody(com.fsck.k9.mail.internet.TextBody) MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Test(org.junit.Test)

Example 43 with MimeMessage

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);
}
Also used : TextBody(com.fsck.k9.mail.internet.TextBody) MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message) MimeMessage(com.fsck.k9.mail.internet.MimeMessage) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 44 with MimeMessage

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));
}
Also used : TextBody(com.fsck.k9.mail.internet.TextBody) MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Test(org.junit.Test)

Example 45 with MimeMessage

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;
}
Also used : MimeMessage(com.fsck.k9.mail.internet.MimeMessage)

Aggregations

MimeMessage (com.fsck.k9.mail.internet.MimeMessage)44 Test (org.junit.Test)35 TextBody (com.fsck.k9.mail.internet.TextBody)16 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)14 Part (com.fsck.k9.mail.Part)11 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 ArrayList (java.util.ArrayList)9 BodyPart (com.fsck.k9.mail.BodyPart)8 Message (com.fsck.k9.mail.Message)7 Viewable (com.fsck.k9.mail.internet.Viewable)7 ViewableExtractedText (com.fsck.k9.mailstore.MessageViewInfoExtractor.ViewableExtractedText)7 Intent (android.content.Intent)6 OutputStream (java.io.OutputStream)6 PendingIntent (android.app.PendingIntent)5 Callback (com.fsck.k9.message.MessageBuilder.Callback)5 OpenPgpDataSource (org.openintents.openpgp.util.OpenPgpApi.OpenPgpDataSource)5 ComposeCryptoStatus (com.fsck.k9.activity.compose.ComposeCryptoStatus)4 Address (com.fsck.k9.mail.Address)4 BinaryTempFileBody (com.fsck.k9.mail.internet.BinaryTempFileBody)4