Skip to content

Commit 5b0e334

Browse files
committed
test: test that encrypted Message-ID overwrites X-Microsoft-Original-Message-ID
1 parent c3b5df3 commit 5b0e334

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/mimeparser.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2246,11 +2246,12 @@ mod tests {
22462246

22472247
use super::*;
22482248
use crate::{
2249+
chat,
22492250
chatlist::Chatlist,
22502251
constants::{Blocked, DC_DESIRED_TEXT_LEN, DC_ELLIPSIS},
22512252
message::{Message, MessageState, MessengerMessage},
22522253
receive_imf::receive_imf,
2253-
test_utils::TestContext,
2254+
test_utils::{TestContext, TestContextManager},
22542255
tools::time,
22552256
};
22562257

@@ -3569,6 +3570,29 @@ On 2020-10-25, Bob wrote:
35693570
);
35703571
}
35713572

3573+
/// Tests that X-Microsoft-Original-Message-ID does not overwrite encrypted Message-ID.
3574+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
3575+
async fn test_x_microsoft_original_message_id_precedence() -> Result<()> {
3576+
let mut tcm = TestContextManager::new();
3577+
let alice = tcm.alice().await;
3578+
let bob = tcm.bob().await;
3579+
3580+
let bob_chat_id = tcm.send_recv_accept(&alice, &bob, "hi").await.chat_id;
3581+
chat::send_text_msg(&bob, bob_chat_id, "hi!".to_string()).await?;
3582+
let mut sent_msg = bob.pop_sent_msg().await;
3583+
3584+
// Insert X-Microsoft-Original-Message-ID.
3585+
// It should be ignored because there is a Message-ID in the encrypted part.
3586+
sent_msg.payload = sent_msg.payload.replace(
3587+
"Message-ID:",
3588+
"X-Microsoft-Original-Message-ID: <fake-message-id@example.net>\r\nMessage-ID:",
3589+
);
3590+
3591+
let msg = alice.recv_msg(&sent_msg).await;
3592+
assert!(!msg.rfc724_mid.contains("fake-message-id"));
3593+
Ok(())
3594+
}
3595+
35723596
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
35733597
async fn test_long_in_reply_to() -> Result<()> {
35743598
let t = TestContext::new_alice().await;

0 commit comments

Comments
 (0)