diff --git a/python/tests/test_0_complex_or_slow.py b/python/tests/test_0_complex_or_slow.py index af7f3b8da6..b22117d03d 100644 --- a/python/tests/test_0_complex_or_slow.py +++ b/python/tests/test_0_complex_or_slow.py @@ -140,6 +140,9 @@ def test_qr_verified_group_and_chatting(acfactory, lp): assert msg.is_system_message() assert "added" in msg.text.lower() + assert any(m.is_system_message() and m.text == "Messages are guaranteed to be end-to-end encrypted from now on."\ + for m in msg.chat.get_messages()) + lp.sec("ac1: send message") msg_out = chat1.send_text("hello") assert msg_out.is_encrypted() @@ -580,6 +583,7 @@ def test_use_new_verified_group_after_going_online(acfactory, tmp_path, lp): assert msg_in.get_sender_contact().addr == ac1.get_config("addr") chat2 = msg_in.chat assert chat2.is_protected() + assert chat2.get_messages()[0].text == "Messages are guaranteed to be end-to-end encrypted from now on." lp.sec("ac2_offl: sending message") msg_out = chat2.send_text("hello") diff --git a/src/tests/verified_chats.rs b/src/tests/verified_chats.rs index 03c025ba25..36429567bf 100644 --- a/src/tests/verified_chats.rs +++ b/src/tests/verified_chats.rs @@ -1,7 +1,7 @@ use anyhow::Result; use pretty_assertions::assert_eq; -use crate::chat::{Chat, ProtectionStatus}; +use crate::chat::ProtectionStatus; use crate::chatlist::Chatlist; use crate::config::Config; use crate::constants::DC_GCL_FOR_FORWARDING; @@ -126,24 +126,22 @@ async fn test_create_verified_oneonone_chat() -> Result<()> { VerifiedStatus::BidirectVerified ); - // As soon as Alice creates a chat with Fiona, it should directly be protected + // Alice should have a hidden protected chat with Fiona { - let chat = alice.create_chat(&fiona).await; + let chat = alice.get_chat(&fiona).await; assert!(chat.is_protected()); - let msg = alice.get_last_msg_in(chat.id).await; + let msg = get_chat_msg(&alice, chat.id, 0, 1).await; let expected_text = stock_str::chat_protection_enabled(&alice).await; assert_eq!(msg.text, expected_text); } - // Fiona should also see the chat as protected + // Fiona should have a hidden protected chat with Alice { - let rcvd = tcm.send_recv(&alice, &fiona, "Hi Fiona").await; - let alice_fiona_id = rcvd.chat_id; - let chat = Chat::load_from_db(&fiona, alice_fiona_id).await?; + let chat = fiona.get_chat(&alice).await; assert!(chat.is_protected()); - let msg0 = get_chat_msg(&fiona, chat.id, 0, 2).await; + let msg0 = get_chat_msg(&fiona, chat.id, 0, 1).await; let expected_text = stock_str::chat_protection_enabled(&fiona).await; assert_eq!(msg0.text, expected_text); } @@ -165,6 +163,15 @@ async fn test_create_verified_oneonone_chat() -> Result<()> { assert!(!chat.is_protected()); assert!(chat.is_protection_broken()); + let msg1 = get_chat_msg(&alice, chat.id, 0, 3).await; + assert_eq!(msg1.get_info_type(), SystemMessage::ChatProtectionEnabled); + + let msg2 = get_chat_msg(&alice, chat.id, 1, 3).await; + assert_eq!(msg2.get_info_type(), SystemMessage::ChatProtectionDisabled); + + let msg2 = get_chat_msg(&alice, chat.id, 2, 3).await; + assert_eq!(msg2.text, "I have a new device"); + // After recreating the chat, it should still be unprotected chat.id.delete(&alice).await?; diff --git a/test-data/golden/test_create_verified_oneonone_chat__alice b/test-data/golden/test_create_verified_oneonone_chat__alice new file mode 100644 index 0000000000..2ec3ba3d42 --- /dev/null +++ b/test-data/golden/test_create_verified_oneonone_chat__alice @@ -0,0 +1,6 @@ +Single#Chat#11: fiona@example.net [fiona@example.net] +-------------------------------------------------------------------------------- +Msg#18: info (Contact#Contact#Info): Messages are guaranteed to be end-to-end encrypted from now on. [NOTICED][INFO 🛡️] +Msg#21: info (Contact#Contact#Info): fiona@example.net sent a message from another device. [NOTICED][INFO 🛡️❌] +Msg#22: (Contact#Contact#11): I have a new device [SEEN] +--------------------------------------------------------------------------------