@@ -5087,3 +5087,64 @@ PGh0bWw+PGJvZHk+dGV4dDwvYm9keT5kYXRh
5087
5087
5088
5088
Ok ( ( ) )
5089
5089
}
5090
+
5091
+ /// Tests that email contacts are not added into a group
5092
+ /// with PGP-contacts by a plaintext reply.
5093
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
5094
+ async fn test_no_email_contact_added_into_group ( ) -> Result < ( ) > {
5095
+ let mut tcm = TestContextManager :: new ( ) ;
5096
+ let alice = & tcm. alice ( ) . await ;
5097
+ let bob = & tcm. bob ( ) . await ;
5098
+
5099
+ let alice_chat_id = alice
5100
+ . create_group_with_members ( ProtectionStatus :: Unprotected , "Group" , & [ bob] )
5101
+ . await ;
5102
+ let bob_received_msg = bob
5103
+ . recv_msg ( & alice. send_text ( alice_chat_id, "Message" ) . await )
5104
+ . await ;
5105
+ let rfc724_mid = bob_received_msg. rfc724_mid ;
5106
+
5107
+ // Alice leaves the group so message from email address contact bob@example.com
5108
+ // does not fail the test for being non-member and is allowed to
5109
+ // modify the chat.
5110
+ remove_contact_from_chat ( alice, alice_chat_id, ContactId :: SELF ) . await ?;
5111
+
5112
+ // Wait 60 days so chatlist is stale.
5113
+ SystemTime :: shift ( Duration :: from_secs ( 60 * 24 * 60 * 60 + 1 ) ) ;
5114
+
5115
+ // Only Bob is the chat member.
5116
+ assert_eq ! (
5117
+ chat:: get_chat_contacts( alice, alice_chat_id) . await ?. len( ) ,
5118
+ 1
5119
+ ) ;
5120
+
5121
+ let msg = receive_imf (
5122
+ alice,
5123
+ format ! (
5124
+ "From: bob@example.com\n \
5125
+ To: alice@example.net, charlie@example.net, fiona@example.net\n \
5126
+ Subject: foo\n \
5127
+ Message-ID: <something@example.com>\n \
5128
+ Chat-Version: 1.0\n \
5129
+ In-Reply-To: {rfc724_mid}\n \
5130
+ Date: Sun, 22 Mar 2020 22:37:57 +0000\n \
5131
+ \n \
5132
+ Hello\n "
5133
+ )
5134
+ . as_bytes ( ) ,
5135
+ false ,
5136
+ )
5137
+ . await ?
5138
+ . unwrap ( ) ;
5139
+
5140
+ // Unencrypted message should not modify the chat member list.
5141
+ assert_eq ! (
5142
+ chat:: get_chat_contacts( alice, alice_chat_id) . await ?. len( ) ,
5143
+ 1
5144
+ ) ;
5145
+
5146
+ // Unencrypted message should not even be assigned to encrypted chat.
5147
+ assert_eq ! ( msg. chat_id, alice_chat_id) ;
5148
+
5149
+ Ok ( ( ) )
5150
+ }
0 commit comments