@@ -919,64 +919,6 @@ def test_gossip_optimization(acfactory, lp):
919
919
assert gossiped_timestamp == int (msg .time_sent .timestamp ())
920
920
921
921
922
- def test_gossip_encryption_preference (acfactory , lp ):
923
- """Test that encryption preference of group members is gossiped to new members.
924
- This is a Delta Chat extension to Autocrypt 1.1.0, which Autocrypt-Gossip headers
925
- SHOULD NOT contain encryption preference.
926
- """
927
- ac1 , ac2 , ac3 = acfactory .get_online_accounts (3 )
928
-
929
- lp .sec ("ac1 learns that ac2 prefers encryption" )
930
- ac1 .create_chat (ac2 )
931
- msg = ac2 .create_chat (ac1 ).send_text ("first message" )
932
- msg = ac1 ._evtracker .wait_next_incoming_message ()
933
- assert msg .text == "first message"
934
- assert not msg .is_encrypted ()
935
- res = "End-to-end encryption preferred:\n {}" .format (ac2 .get_config ("addr" ))
936
- assert msg .chat .get_encryption_info () == res
937
- lp .sec ("ac2 learns that ac3 prefers encryption" )
938
- ac2 .create_chat (ac3 )
939
- msg = ac3 .create_chat (ac2 ).send_text ("I prefer encryption" )
940
- msg = ac2 ._evtracker .wait_next_incoming_message ()
941
- assert msg .text == "I prefer encryption"
942
- assert not msg .is_encrypted ()
943
-
944
- lp .sec ("ac3 does not know that ac1 prefers encryption" )
945
- ac1 .create_chat (ac3 )
946
- chat = ac3 .create_chat (ac1 )
947
- res = "No encryption:\n {}" .format (ac1 .get_config ("addr" ))
948
- assert chat .get_encryption_info () == res
949
- msg = chat .send_text ("not encrypted" )
950
- msg = ac1 ._evtracker .wait_next_incoming_message ()
951
- assert msg .text == "not encrypted"
952
- assert not msg .is_encrypted ()
953
-
954
- lp .sec ("ac1 creates a group chat with ac2" )
955
- group_chat = ac1 .create_group_chat ("hello" )
956
- group_chat .add_contact (ac2 )
957
- encryption_info = group_chat .get_encryption_info ()
958
- res = "End-to-end encryption preferred:\n {}" .format (ac2 .get_config ("addr" ))
959
- assert encryption_info == res
960
- msg = group_chat .send_text ("hi" )
961
-
962
- msg = ac2 ._evtracker .wait_next_incoming_message ()
963
- assert msg .is_encrypted ()
964
- assert msg .text == "hi"
965
-
966
- lp .sec ("ac2 adds ac3 to the group" )
967
- msg .chat .add_contact (ac3 )
968
- assert msg .is_encrypted ()
969
-
970
- lp .sec ("ac3 learns that ac1 prefers encryption" )
971
- msg = ac3 ._evtracker .wait_next_incoming_message ()
972
- encryption_info = msg .chat .get_encryption_info ().splitlines ()
973
- assert encryption_info [0 ] == "End-to-end encryption preferred:"
974
- assert ac1 .get_config ("addr" ) in encryption_info [1 :]
975
- assert ac2 .get_config ("addr" ) in encryption_info [1 :]
976
- msg = chat .send_text ("encrypted" )
977
- assert msg .is_encrypted ()
978
-
979
-
980
922
def test_send_first_message_as_long_unicode_with_cr (acfactory , lp ):
981
923
ac1 , ac2 = acfactory .get_online_accounts (2 )
982
924
@@ -1167,61 +1109,6 @@ def test_dont_show_emails(acfactory, lp):
1167
1109
assert len (msg .chat .get_messages ()) == 3
1168
1110
1169
1111
1170
- def test_prefer_encrypt (acfactory , lp ):
1171
- """Test quorum rule for encryption preference in 1:1 and group chat."""
1172
- ac1 = acfactory .new_online_configuring_account (fix_is_chatmail = True )
1173
- ac2 = acfactory .new_online_configuring_account (fix_is_chatmail = True )
1174
- ac3 = acfactory .new_online_configuring_account (fix_is_chatmail = True )
1175
- acfactory .bring_accounts_online ()
1176
- ac1 .set_config ("e2ee_enabled" , "0" )
1177
- ac2 .set_config ("e2ee_enabled" , "1" )
1178
- ac3 .set_config ("e2ee_enabled" , "0" )
1179
-
1180
- # Make sure we do not send a copy to ourselves. This is to
1181
- # test that we count own preference even when we are not in
1182
- # the recipient list.
1183
- ac1 .set_config ("bcc_self" , "0" )
1184
- ac2 .set_config ("bcc_self" , "0" )
1185
- ac3 .set_config ("bcc_self" , "0" )
1186
-
1187
- acfactory .introduce_each_other ([ac1 , ac2 , ac3 ])
1188
-
1189
- lp .sec ("ac1: sending message to ac2" )
1190
- chat1 = ac1 .create_chat (ac2 )
1191
- msg1 = chat1 .send_text ("message1" )
1192
- assert not msg1 .is_encrypted ()
1193
- ac2 ._evtracker .wait_next_incoming_message ()
1194
-
1195
- lp .sec ("ac2: sending message to ac1" )
1196
- chat2 = ac2 .create_chat (ac1 )
1197
- msg2 = chat2 .send_text ("message2" )
1198
- # Own preference is `Mutual` and we have the peer's key.
1199
- assert msg2 .is_encrypted ()
1200
- ac1 ._evtracker .wait_next_incoming_message ()
1201
-
1202
- lp .sec ("ac1: sending message to group chat with ac2 and ac3" )
1203
- group = ac1 .create_group_chat ("hello" )
1204
- group .add_contact (ac2 )
1205
- group .add_contact (ac3 )
1206
- msg3 = group .send_text ("message3" )
1207
- assert not msg3 .is_encrypted ()
1208
- ac2 ._evtracker .wait_next_incoming_message ()
1209
- ac3 ._evtracker .wait_next_incoming_message ()
1210
-
1211
- lp .sec ("ac3: start preferring encryption and inform ac1" )
1212
- ac3 .set_config ("e2ee_enabled" , "1" )
1213
- chat3 = ac3 .create_chat (ac1 )
1214
- msg4 = chat3 .send_text ("message4" )
1215
- # Own preference is `Mutual` and we have the peer's key.
1216
- assert msg4 .is_encrypted ()
1217
- ac1 ._evtracker .wait_next_incoming_message ()
1218
-
1219
- lp .sec ("ac1: sending another message to group chat with ac2 and ac3" )
1220
- msg5 = group .send_text ("message5" )
1221
- # Majority prefers encryption now
1222
- assert msg5 .is_encrypted ()
1223
-
1224
-
1225
1112
def test_bot (acfactory , lp ):
1226
1113
"""Test that bot messages can be identified as such"""
1227
1114
ac1 , ac2 = acfactory .get_online_accounts (2 )
@@ -1250,59 +1137,6 @@ def test_bot(acfactory, lp):
1250
1137
assert msg_in .is_bot ()
1251
1138
1252
1139
1253
- def test_quote_encrypted (acfactory , lp ):
1254
- """Test that replies to encrypted messages with quotes are encrypted."""
1255
- ac1 , ac2 = acfactory .get_online_accounts (2 )
1256
-
1257
- lp .sec ("ac1: create chat with ac2" )
1258
- chat = ac1 .create_chat (ac2 )
1259
-
1260
- lp .sec ("sending text message from ac1 to ac2" )
1261
- msg1 = chat .send_text ("message1" )
1262
- assert not msg1 .is_encrypted ()
1263
-
1264
- lp .sec ("wait for ac2 to receive message" )
1265
- msg2 = ac2 ._evtracker .wait_next_incoming_message ()
1266
- assert msg2 .text == "message1"
1267
- assert not msg2 .is_encrypted ()
1268
-
1269
- lp .sec ("create new chat with contact and send back (encrypted) message" )
1270
- msg2 .create_chat ().send_text ("message-back" )
1271
-
1272
- lp .sec ("wait for ac1 to receive message" )
1273
- msg3 = ac1 ._evtracker .wait_next_incoming_message ()
1274
- assert msg3 .text == "message-back"
1275
- assert msg3 .is_encrypted ()
1276
-
1277
- lp .sec ("ac1: e2ee_enabled=0 and see if reply is encrypted" )
1278
- print ("ac1: e2ee_enabled={}" .format (ac1 .get_config ("e2ee_enabled" )))
1279
- print ("ac2: e2ee_enabled={}" .format (ac2 .get_config ("e2ee_enabled" )))
1280
- ac1 .set_config ("e2ee_enabled" , "0" )
1281
-
1282
- for quoted_msg in msg1 , msg3 :
1283
- # Save the draft with a quote.
1284
- msg_draft = Message .new_empty (ac1 , "text" )
1285
- msg_draft .set_text ("message reply" )
1286
- msg_draft .quote = quoted_msg
1287
- chat .set_draft (msg_draft )
1288
-
1289
- # Get the draft and send it.
1290
- msg_draft = chat .get_draft ()
1291
- chat .send_msg (msg_draft )
1292
-
1293
- chat .set_draft (None )
1294
- assert chat .get_draft () is None
1295
-
1296
- # Quote should be replaced with "..." if quoted message is encrypted.
1297
- msg_in = ac2 ._evtracker .wait_next_incoming_message ()
1298
- assert msg_in .text == "message reply"
1299
- assert not msg_in .is_encrypted ()
1300
- if quoted_msg .is_encrypted ():
1301
- assert msg_in .quoted_text == "..."
1302
- else :
1303
- assert msg_in .quoted_text == quoted_msg .text
1304
-
1305
-
1306
1140
def test_quote_attachment (tmp_path , acfactory , lp ):
1307
1141
"""Test that replies with an attachment and a quote are received correctly."""
1308
1142
ac1 , ac2 = acfactory .get_online_accounts (2 )
0 commit comments