@@ -2246,11 +2246,12 @@ mod tests {
2246
2246
2247
2247
use super :: * ;
2248
2248
use crate :: {
2249
+ chat,
2249
2250
chatlist:: Chatlist ,
2250
2251
constants:: { Blocked , DC_DESIRED_TEXT_LEN , DC_ELLIPSIS } ,
2251
2252
message:: { Message , MessageState , MessengerMessage } ,
2252
2253
receive_imf:: receive_imf,
2253
- test_utils:: TestContext ,
2254
+ test_utils:: { TestContext , TestContextManager } ,
2254
2255
tools:: time,
2255
2256
} ;
2256
2257
@@ -3569,6 +3570,29 @@ On 2020-10-25, Bob wrote:
3569
3570
) ;
3570
3571
}
3571
3572
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 \n Message-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
+
3572
3596
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
3573
3597
async fn test_long_in_reply_to ( ) -> Result < ( ) > {
3574
3598
let t = TestContext :: new_alice ( ) . await ;
0 commit comments