Search in sources :

Example 26 with Message

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

the class ReplyToParserTest method getRecipientsToReplyTo_should_prefer_listPost_over_from_field.

@Test
public void getRecipientsToReplyTo_should_prefer_listPost_over_from_field() throws Exception {
    when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
    when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(LIST_POST_HEADER_VALUES);
    when(message.getFrom()).thenReturn(FROM_ADDRESSES);
    ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
    assertArrayEquals(LIST_POST_ADDRESSES, result.to);
    assertArrayEquals(EMPTY_ADDRESSES, result.cc);
    verify(account).isAnIdentity(result.to);
}
Also used : ReplyToAddresses(com.fsck.k9.helper.ReplyToParser.ReplyToAddresses) Test(org.junit.Test)

Example 27 with Message

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

the class MessageDecryptVerifierTest method isPgpInlineMethods__withEncryptedDataAndLeadingWhitespace__shouldReturnTrue.

@Test
public void isPgpInlineMethods__withEncryptedDataAndLeadingWhitespace__shouldReturnTrue() throws Exception {
    String pgpInlineData = "\n   \n \n" + "-----BEGIN PGP MESSAGE-----\n" + "Header: Value\n" + "\n" + "base64base64base64base64\n" + "-----END PGP MESSAGE-----\n";
    MimeMessage message = new MimeMessage();
    message.setBody(new TextBody(pgpInlineData));
    assertTrue(MessageDecryptVerifier.isPartPgpInlineEncryptedOrSigned(message));
    assertTrue(MessageDecryptVerifier.isPartPgpInlineEncrypted(message));
}
Also used : TextBody(com.fsck.k9.mail.internet.TextBody) MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Test(org.junit.Test)

Example 28 with Message

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

the class MessageDecryptVerifierTest method findPrimaryCryptoPart_withMultipartMixedContainingPgpInline.

@Test
public void findPrimaryCryptoPart_withMultipartMixedContainingPgpInline() throws Exception {
    List<Part> outputExtraParts = new ArrayList<>();
    BodyPart pgpInlinePart = bodypart("text/plain", PGP_INLINE_DATA);
    Message message = messageFromBody(multipart("mixed", pgpInlinePart, bodypart("application/octet-stream")));
    Part cryptoPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, outputExtraParts);
    assertSame(pgpInlinePart, cryptoPart);
}
Also used : BodyPart(com.fsck.k9.mail.BodyPart) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) 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) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 29 with Message

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

the class MessageDecryptVerifierTest method findPrimaryCryptoPart_withEmptyMultipartAlternative_shouldReturnNull.

@Test
public void findPrimaryCryptoPart_withEmptyMultipartAlternative_shouldReturnNull() throws Exception {
    List<Part> outputExtraParts = new ArrayList<>();
    Message message = messageFromBody(multipart("alternative"));
    Part cryptoPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, outputExtraParts);
    assertNull(cryptoPart);
}
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) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 30 with Message

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

the class MessageDecryptVerifierTest method findEncrypted__withMultipartMixedSubSigned__shouldReturnSigned.

@Test
public void findEncrypted__withMultipartMixedSubSigned__shouldReturnSigned() throws Exception {
    Message message = messageFromBody(multipart("mixed", multipart("signed", bodypart("text/plain"), bodypart("application/pgp-signature"))));
    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)

Aggregations

Test (org.junit.Test)127 Message (com.fsck.k9.mail.Message)111 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)102 Part (com.fsck.k9.mail.Part)47 LocalMessage (com.fsck.k9.mailstore.LocalMessage)46 MessagingException (com.fsck.k9.mail.MessagingException)41 ArrayList (java.util.ArrayList)41 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)33 BodyPart (com.fsck.k9.mail.BodyPart)32 Account (com.fsck.k9.Account)27 LocalFolder (com.fsck.k9.mailstore.LocalFolder)24 TextBody (com.fsck.k9.mail.internet.TextBody)23 IOException (java.io.IOException)22 Address (com.fsck.k9.mail.Address)21 LocalStore (com.fsck.k9.mailstore.LocalStore)21 Date (java.util.Date)20 MessageReference (com.fsck.k9.activity.MessageReference)16 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)16 Folder (com.fsck.k9.mail.Folder)14 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)13