@@ -4698,6 +4698,32 @@ async fn test_no_key_contacts_in_adhoc_chats() -> Result<()> {
4698
4698
Ok ( ( ) )
4699
4699
}
4700
4700
4701
+ /// Tests that key-contacts cannot be added to an unencrypted (ad hoc) group and the group and
4702
+ /// messages report that they are unencrypted.
4703
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
4704
+ async fn test_create_unencrypted_group_chat ( ) -> Result < ( ) > {
4705
+ let mut tcm = TestContextManager :: new ( ) ;
4706
+ let alice = & tcm. alice ( ) . await ;
4707
+ let bob = & tcm. bob ( ) . await ;
4708
+ let charlie = & tcm. charlie ( ) . await ;
4709
+
4710
+ let chat_id = create_group_ex ( alice, None , "Group chat" ) . await ?;
4711
+ let bob_key_contact_id = alice. add_or_lookup_contact_id ( bob) . await ;
4712
+ let charlie_address_contact_id = alice. add_or_lookup_address_contact_id ( charlie) . await ;
4713
+
4714
+ let res = add_contact_to_chat ( alice, chat_id, bob_key_contact_id) . await ;
4715
+ assert ! ( res. is_err( ) ) ;
4716
+
4717
+ add_contact_to_chat ( alice, chat_id, charlie_address_contact_id) . await ?;
4718
+
4719
+ let chat = Chat :: load_from_db ( alice, chat_id) . await ?;
4720
+ assert ! ( !chat. is_encrypted( alice) . await ?) ;
4721
+ let sent_msg = alice. send_text ( chat_id, "Hello" ) . await ;
4722
+ let msg = Message :: load_from_db ( alice, sent_msg. sender_msg_id ) . await ?;
4723
+ assert ! ( !msg. get_showpadlock( ) ) ;
4724
+ Ok ( ( ) )
4725
+ }
4726
+
4701
4727
/// Tests that avatar cannot be set in ad hoc groups.
4702
4728
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
4703
4729
async fn test_no_avatar_in_adhoc_chats ( ) -> Result < ( ) > {
0 commit comments