From 3a787519b339bc7bf7883d440613dc2012dc0b73 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 11 Feb 2024 21:53:44 +0000 Subject: [PATCH] test: test that encrypted Message-ID overwrites X-Microsoft-Original-Message-ID --- src/mimeparser.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 90e362bc9..801fa8ae2 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -2246,11 +2246,12 @@ mod tests { use super::*; use crate::{ + chat, chatlist::Chatlist, constants::{Blocked, DC_DESIRED_TEXT_LEN, DC_ELLIPSIS}, message::{Message, MessageState, MessengerMessage}, receive_imf::receive_imf, - test_utils::TestContext, + test_utils::{TestContext, TestContextManager}, tools::time, }; @@ -3569,6 +3570,29 @@ On 2020-10-25, Bob wrote: ); } + /// Tests that X-Microsoft-Original-Message-ID does not overwrite encrypted Message-ID. + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_x_microsoft_original_message_id_precedence() -> Result<()> { + let mut tcm = TestContextManager::new(); + let alice = tcm.alice().await; + let bob = tcm.bob().await; + + let bob_chat_id = tcm.send_recv_accept(&alice, &bob, "hi").await.chat_id; + chat::send_text_msg(&bob, bob_chat_id, "hi!".to_string()).await?; + let mut sent_msg = bob.pop_sent_msg().await; + + // Insert X-Microsoft-Original-Message-ID. + // It should be ignored because there is a Message-ID in the encrypted part. + sent_msg.payload = sent_msg.payload.replace( + "Message-ID:", + "X-Microsoft-Original-Message-ID: \r\nMessage-ID:", + ); + + let msg = alice.recv_msg(&sent_msg).await; + assert!(!msg.rfc724_mid.contains("fake-message-id")); + Ok(()) + } + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_long_in_reply_to() -> Result<()> { let t = TestContext::new_alice().await;