mirror of
https://github.com/chatmail/core.git
synced 2026-04-18 22:16:30 +03:00
test: Message from old setup preserves contact verification, but breaks 1:1 protection
If a message from an old contact's setup is received, the outdated Autocrypt header isn't applied, so the contact verification preserves. But the chat protection breaks because the old message is sorted to the bottom as it mustn't be sorted over the protection info message (which is `InNoticed` moreover). Would be nice to preserve the chat protection too e.g. add a "protection broken" message, then the old message and then a new "protection enabled" message, but let's record the current behaviour first.
This commit is contained in:
@@ -730,6 +730,46 @@ async fn test_break_protection_then_verify_again() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_message_from_old_dc_setup() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
let alice = &tcm.alice().await;
|
||||
let bob_old = &tcm.unconfigured().await;
|
||||
enable_verified_oneonone_chats(&[alice, bob_old]).await;
|
||||
mark_as_verified(bob_old, alice).await;
|
||||
bob_old.configure_addr("bob@example.net").await;
|
||||
let chat = bob_old.create_chat(alice).await;
|
||||
let sent_old = bob_old
|
||||
.send_text(chat.id, "Soon i'll have a new device")
|
||||
.await;
|
||||
SystemTime::shift(std::time::Duration::from_secs(3600));
|
||||
|
||||
tcm.section("Bob reinstalls DC");
|
||||
let bob = &tcm.bob().await;
|
||||
enable_verified_oneonone_chats(&[bob]).await;
|
||||
|
||||
mark_as_verified(alice, bob).await;
|
||||
mark_as_verified(bob, alice).await;
|
||||
|
||||
tcm.send_recv(bob, alice, "Now i have it!").await;
|
||||
assert_verified(alice, bob, ProtectionStatus::Protected).await;
|
||||
|
||||
let msg = alice.recv_msg(&sent_old).await;
|
||||
assert!(!msg.get_showpadlock());
|
||||
let contact = alice.add_or_lookup_contact(bob).await;
|
||||
// The outdated Bob's Autocrypt header isn't applied, so the verification preserves.
|
||||
assert!(contact.is_verified(alice).await.unwrap());
|
||||
let chat = alice.get_chat(bob).await;
|
||||
// But the chat protection is broken because the old message is sorted to the bottom as it
|
||||
// mustn't be sorted over the protection info message (which is `InNoticed` moreover).
|
||||
assert_eq!(chat.is_protected(), false);
|
||||
assert_eq!(chat.is_protection_broken(), true);
|
||||
alice
|
||||
.golden_test_chat(msg.chat_id, "verified_chats_message_from_old_dc_setup")
|
||||
.await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Regression test for the following bug:
|
||||
///
|
||||
/// - Scan your chat partner's QR Code
|
||||
|
||||
Reference in New Issue
Block a user