Search in sources :

Example 71 with BodyPart

use of com.fsck.k9.mail.BodyPart in project k-9 by k9mail.

the class MessageDecryptVerifierTest method findEncrypted__withMultipartMixedSubSignedAndText__shouldReturnSigned.

@Test
public void findEncrypted__withMultipartMixedSubSignedAndText__shouldReturnSigned() throws Exception {
    Message message = messageFromBody(multipart("mixed", multipart("signed", bodypart("text/plain"), bodypart("application/pgp-signature")), bodypart("text/plain")));
    List<Part> signedParts = MessageDecryptVerifier.findSignedParts(message, messageCryptoAnnotations);
    assertEquals(1, signedParts.size());
    assertSame(getPart(message, 0), signedParts.get(0));
}
Also used : MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Test(org.junit.Test)

Example 72 with BodyPart

use of com.fsck.k9.mail.BodyPart in project k-9 by k9mail.

the class MessageDecryptVerifierTest method findEncrypted__withMultipartMixedSubEncryptedAndEncrypted__shouldReturnBoth.

@Test
public void findEncrypted__withMultipartMixedSubEncryptedAndEncrypted__shouldReturnBoth() throws Exception {
    Message message = messageFromBody(multipart("mixed", multipart("encrypted", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream")), multipart("encrypted", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream"))));
    List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(message);
    assertEquals(2, encryptedParts.size());
    assertSame(getPart(message, 0), encryptedParts.get(0));
    assertSame(getPart(message, 1), encryptedParts.get(1));
}
Also used : MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Test(org.junit.Test)

Example 73 with BodyPart

use of com.fsck.k9.mail.BodyPart in project k-9 by k9mail.

the class MessageDecryptVerifierTest method findEncrypted__withMultipartMixedSubTextAndEncrypted__shouldReturnEncrypted.

@Test
public void findEncrypted__withMultipartMixedSubTextAndEncrypted__shouldReturnEncrypted() throws Exception {
    Message message = messageFromBody(multipart("mixed", bodypart("text/plain"), multipart("encrypted", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream"))));
    List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(message);
    assertEquals(1, encryptedParts.size());
    assertSame(getPart(message, 1), encryptedParts.get(0));
}
Also used : MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Test(org.junit.Test)

Example 74 with BodyPart

use of com.fsck.k9.mail.BodyPart 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)

Example 75 with BodyPart

use of com.fsck.k9.mail.BodyPart in project k-9 by k9mail.

the class MessageDecryptVerifierTest method findEncrypted__withMultipartEncrypted__shouldReturnRoot.

@Test
public void findEncrypted__withMultipartEncrypted__shouldReturnRoot() throws Exception {
    Message message = messageFromBody(multipart("encrypted", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream")));
    List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(message);
    assertEquals(1, encryptedParts.size());
    assertSame(message, encryptedParts.get(0));
}
Also used : MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Test(org.junit.Test)

Aggregations

BodyPart (com.fsck.k9.mail.BodyPart)86 Test (org.junit.Test)73 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)65 Part (com.fsck.k9.mail.Part)64 Message (com.fsck.k9.mail.Message)58 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)50 Multipart (com.fsck.k9.mail.Multipart)28 Body (com.fsck.k9.mail.Body)25 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)22 ArrayList (java.util.ArrayList)13 RobolectricTest (com.fsck.k9.RobolectricTest)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)12 MessageCreationHelper.createEmptyPart (com.fsck.k9.message.MessageCreationHelper.createEmptyPart)11 MessageCreationHelper.createPart (com.fsck.k9.message.MessageCreationHelper.createPart)11 MessageCreationHelper.createTextPart (com.fsck.k9.message.MessageCreationHelper.createTextPart)11 OutputStream (java.io.OutputStream)11 K9RobolectricTest (com.fsck.k9.K9RobolectricTest)10 MessagingException (com.fsck.k9.mail.MessagingException)10 Stack (java.util.Stack)9 BinaryTempFileBody (com.fsck.k9.mail.internet.BinaryTempFileBody)8