Skip to content

Commit d22c29a

Browse files
committed
test: After AEAP, 1:1 chat isn't available for sending, but unprotected groups are (#6222)
1 parent 22b9308 commit d22c29a

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

src/tests/aeap.rs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use anyhow::Result;
22

3-
use crate::chat;
4-
use crate::chat::ChatId;
3+
use crate::chat::{self, Chat, ChatId, ProtectionStatus};
54
use crate::contact;
65
use crate::contact::Contact;
76
use crate::contact::ContactId;
87
use crate::message::Message;
98
use crate::peerstate::Peerstate;
109
use crate::receive_imf::receive_imf;
10+
use crate::securejoin::get_securejoin_qr;
1111
use crate::stock_str;
1212
use crate::test_utils::mark_as_verified;
1313
use crate::test_utils::TestContext;
@@ -394,3 +394,40 @@ async fn test_aeap_replay_attack() -> Result<()> {
394394

395395
Ok(())
396396
}
397+
398+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
399+
async fn test_write_to_alice_after_aeap() -> Result<()> {
400+
let mut tcm = TestContextManager::new();
401+
let alice = &tcm.alice().await;
402+
let bob = &tcm.bob().await;
403+
let alice_grp_id = chat::create_group_chat(alice, ProtectionStatus::Protected, "Group").await?;
404+
let qr = get_securejoin_qr(alice, Some(alice_grp_id)).await?;
405+
tcm.exec_securejoin_qr(bob, alice, &qr).await;
406+
let bob_alice_contact = bob.add_or_lookup_contact(alice).await;
407+
assert!(bob_alice_contact.is_verified(bob).await?);
408+
let bob_alice_chat = bob.create_chat(alice).await;
409+
assert!(bob_alice_chat.is_protected());
410+
let bob_unprotected_grp_id = bob
411+
.create_group_with_members(ProtectionStatus::Unprotected, "Group", &[alice])
412+
.await;
413+
414+
tcm.change_addr(alice, "alice@someotherdomain.xyz").await;
415+
let sent = alice.send_text(alice_grp_id, "Hello!").await;
416+
bob.recv_msg(&sent).await;
417+
418+
assert!(!bob_alice_contact.is_verified(bob).await?);
419+
let bob_alice_chat = Chat::load_from_db(bob, bob_alice_chat.id).await?;
420+
assert!(bob_alice_chat.is_protected());
421+
let mut msg = Message::new_text("hi".to_string());
422+
assert!(chat::send_msg(bob, bob_alice_chat.id, &mut msg)
423+
.await
424+
.is_err());
425+
426+
// But encrypted communication is still possible in unprotected groups with old Alice.
427+
let sent = bob
428+
.send_text(bob_unprotected_grp_id, "Alice, how is your address change?")
429+
.await;
430+
let msg = Message::load_from_db(bob, sent.sender_msg_id).await?;
431+
assert!(msg.get_showpadlock());
432+
Ok(())
433+
}

0 commit comments

Comments
 (0)