@@ -3039,11 +3039,17 @@ async fn test_sync_block_before_first_msg() -> Result<()> {
3039
3039
let rcvd_msg = alice0. recv_msg ( & sent_msg) . await ;
3040
3040
let a0b_chat_id = rcvd_msg. chat_id ;
3041
3041
let a0b_contact_id = rcvd_msg. from_id ;
3042
- assert_eq ! ( Chat :: load_from_db( alice0, a0b_chat_id) . await ?. blocked, Blocked :: Request ) ;
3042
+ assert_eq ! (
3043
+ Chat :: load_from_db( alice0, a0b_chat_id) . await ?. blocked,
3044
+ Blocked :: Request
3045
+ ) ;
3043
3046
a0b_chat_id. block ( alice0) . await ?;
3044
3047
let a0b_contact = Contact :: get_by_id ( alice0, a0b_contact_id) . await ?;
3045
3048
assert_eq ! ( a0b_contact. origin, Origin :: IncomingUnknownFrom ) ;
3046
- assert_eq ! ( Chat :: load_from_db( alice0, a0b_chat_id) . await ?. blocked, Blocked :: Yes ) ;
3049
+ assert_eq ! (
3050
+ Chat :: load_from_db( alice0, a0b_chat_id) . await ?. blocked,
3051
+ Blocked :: Yes
3052
+ ) ;
3047
3053
3048
3054
sync ( alice0, alice1) . await ;
3049
3055
let alice1_contacts = Contact :: get_all ( alice1, 0 , None ) . await ?;
@@ -3053,7 +3059,12 @@ async fn test_sync_block_before_first_msg() -> Result<()> {
3053
3059
let a1b_contact_id = rcvd_msg. from_id ;
3054
3060
let a1b_contact = Contact :: get_by_id ( alice1, a1b_contact_id) . await ?;
3055
3061
assert_eq ! ( a1b_contact. origin, Origin :: IncomingUnknownFrom ) ;
3056
- let ChatIdBlocked { id : a1b_chat_id, blocked : a1b_chat_blocked} = ChatIdBlocked :: lookup_by_contact ( alice1, a1b_contact_id) . await ?. unwrap ( ) ;
3062
+ let ChatIdBlocked {
3063
+ id : a1b_chat_id,
3064
+ blocked : a1b_chat_blocked,
3065
+ } = ChatIdBlocked :: lookup_by_contact ( alice1, a1b_contact_id)
3066
+ . await ?
3067
+ . unwrap ( ) ;
3057
3068
assert_eq ! ( a1b_chat_blocked, Blocked :: Yes ) ;
3058
3069
assert_eq ! ( rcvd_msg. chat_id, a1b_chat_id) ;
3059
3070
Ok ( ( ) )
@@ -4098,3 +4109,25 @@ async fn test_oneone_gossip() -> Result<()> {
4098
4109
4099
4110
Ok ( ( ) )
4100
4111
}
4112
+
4113
+ /// Tests that email contacts cannot be added to encrypted group chats.
4114
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
4115
+ async fn test_no_email_contacts_in_group_chats ( ) -> Result < ( ) > {
4116
+ let mut tcm = TestContextManager :: new ( ) ;
4117
+ let alice = & tcm. alice ( ) . await ;
4118
+ let bob = & tcm. bob ( ) . await ;
4119
+ let charlie = & tcm. charlie ( ) . await ;
4120
+
4121
+ let chat_id = create_group_chat ( alice, ProtectionStatus :: Unprotected , "Group chat" ) . await ?;
4122
+ let pgp_bob_contact_id = alice. add_or_lookup_contact_id ( bob) . await ;
4123
+ let email_charlie_contact_id = alice. add_or_lookup_email_contact_id ( charlie) . await ;
4124
+
4125
+ // PGP-contact should be added successfully.
4126
+ add_contact_to_chat ( alice, chat_id, pgp_bob_contact_id) . await ?;
4127
+
4128
+ // Adding email-contact should fail.
4129
+ let res = add_contact_to_chat ( alice, chat_id, email_charlie_contact_id) . await ;
4130
+ assert ! ( res. is_err( ) ) ;
4131
+
4132
+ Ok ( ( ) )
4133
+ }
0 commit comments