@Test
public void extractMessage_openPgpEncrypted_withProtectedSubject() throws Exception {
MimeBodyPart encryptedPayload = bodypart("text/plain", "encrypted text");
Message message = messageFromBody(multipart("encrypted", "protocol=\"application/pgp-encrypted\"",
bodypart("application/pgp-encrypted"),
bodypart("application/octet-stream")
));
encryptedPayload.setHeader("Content-Type",
encryptedPayload.getHeader("Content-Type")[0] + "; protected-headers=v1");
encryptedPayload.setHeader("Subject", PROTECTED_SUBJECT);
MessageCryptoAnnotations cryptoAnnotations = new MessageCryptoAnnotations();
OpenPgpDecryptionResult decryptionResult = new OpenPgpDecryptionResult(OpenPgpDecryptionResult.RESULT_ENCRYPTED);
CryptoResultAnnotation openPgpResultAnnotation = CryptoResultAnnotation.createOpenPgpResultAnnotation(
decryptionResult, null, null, null, encryptedPayload, false);
cryptoAnnotations.put(message, openPgpResultAnnotation);
MessageViewInfo messageViewInfo = messageViewInfoExtractor.extractMessageForView(message, cryptoAnnotations,
true);
assertSame(openPgpResultAnnotation, messageViewInfo.cryptoResultAnnotation);
assertEquals("<pre class=\"k9mail\">encrypted text</pre>", messageViewInfo.text);
assertEquals(PROTECTED_SUBJECT, messageViewInfo.subject);
assertTrue(messageViewInfo.attachments.isEmpty());
assertTrue(messageViewInfo.extraAttachments.isEmpty());
}