mirror of
https://github.com/chatmail/core.git
synced 2026-04-19 14:36:29 +03:00
test: Fix test_verified_oneonone_chat_broken_by_device_change() (#5280)
It was broken completely and before "fix: apply Autocrypt headers if timestamp is unchanged" that didn't show up because the message from the second Bob's device never had "Date" greater than one from the message sent before from the first device.
This commit is contained in:
@@ -43,7 +43,7 @@ async fn check_verified_oneonone_chat(broken_by_classical_email: bool) {
|
||||
b"Subject: Re: Message from alice\r\n\
|
||||
From: <bob@example.net>\r\n\
|
||||
To: <alice@example.org>\r\n\
|
||||
Date: Mon, 12 Dec 2022 14:33:39 +0000\r\n\
|
||||
Date: Mon, 12 Dec 3000 14:33:39 +0000\r\n\
|
||||
Message-ID: <abcd@example.net>\r\n\
|
||||
\r\n\
|
||||
Heyho!\r\n",
|
||||
@@ -52,26 +52,28 @@ async fn check_verified_oneonone_chat(broken_by_classical_email: bool) {
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
// Bob's contact is still verified, but the chat isn't marked as protected anymore
|
||||
let contact = alice.add_or_lookup_contact(&bob).await;
|
||||
assert_eq!(contact.is_verified(&alice).await.unwrap(), true);
|
||||
assert_verified(&alice, &bob, ProtectionStatus::ProtectionBroken).await;
|
||||
} else {
|
||||
tcm.section("Bob sets up another Delta Chat device");
|
||||
let bob2 = TestContext::new().await;
|
||||
enable_verified_oneonone_chats(&[&bob2]).await;
|
||||
bob2.set_name("bob2");
|
||||
bob2.configure_addr("bob@example.net").await;
|
||||
|
||||
SystemTime::shift(std::time::Duration::from_secs(3600));
|
||||
tcm.send_recv(&bob2, &alice, "Using another device now")
|
||||
.await;
|
||||
let contact = alice.add_or_lookup_contact(&bob).await;
|
||||
assert_eq!(contact.is_verified(&alice).await.unwrap(), false);
|
||||
assert_verified(&alice, &bob, ProtectionStatus::ProtectionBroken).await;
|
||||
}
|
||||
|
||||
// Bob's contact is still verified, but the chat isn't marked as protected anymore
|
||||
assert_verified(&alice, &bob, ProtectionStatus::ProtectionBroken).await;
|
||||
|
||||
tcm.section("Bob sends another message from DC");
|
||||
SystemTime::shift(std::time::Duration::from_secs(3600));
|
||||
tcm.send_recv(&bob, &alice, "Using DC again").await;
|
||||
|
||||
let contact = alice.add_or_lookup_contact(&bob).await;
|
||||
assert_eq!(contact.is_verified(&alice.ctx).await.unwrap(), true);
|
||||
|
||||
// Bob's chat is marked as verified again
|
||||
assert_verified(&alice, &bob, ProtectionStatus::Protected).await;
|
||||
}
|
||||
@@ -816,8 +818,10 @@ async fn test_create_protected_grp_multidev() -> Result<()> {
|
||||
// ============== Helper Functions ==============
|
||||
|
||||
async fn assert_verified(this: &TestContext, other: &TestContext, protected: ProtectionStatus) {
|
||||
let contact = this.add_or_lookup_contact(other).await;
|
||||
assert_eq!(contact.is_verified(this).await.unwrap(), true);
|
||||
if protected != ProtectionStatus::ProtectionBroken {
|
||||
let contact = this.add_or_lookup_contact(other).await;
|
||||
assert_eq!(contact.is_verified(this).await.unwrap(), true);
|
||||
}
|
||||
|
||||
let chat = this.get_chat(other).await;
|
||||
let (expect_protected, expect_broken) = match protected {
|
||||
|
||||
Reference in New Issue
Block a user