-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test that reordering of Member added message results in square …
…bracket error This is a test reproducing the problem in <#5339>. Fix would be to avoid reordering on the server side, so the test checks that the unverified message is replaced with a square bracket error as expected if messages arrive in the wrong order.
- Loading branch information
Showing
1 changed file
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
use anyhow::Result; | ||
use pretty_assertions::assert_eq; | ||
|
||
use crate::chat::{self, Chat, ProtectionStatus}; | ||
use crate::chat::{self, add_contact_to_chat, Chat, ProtectionStatus}; | ||
use crate::chatlist::Chatlist; | ||
use crate::config::Config; | ||
use crate::constants::{Chattype, DC_GCL_FOR_FORWARDING}; | ||
|
@@ -815,6 +815,49 @@ async fn test_create_protected_grp_multidev() -> Result<()> { | |
Ok(()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
async fn test_verified_member_added_reordering() -> Result<()> { | ||
let mut tcm = TestContextManager::new(); | ||
let alice = &tcm.alice().await; | ||
let bob = &tcm.bob().await; | ||
let fiona = &tcm.fiona().await; | ||
enable_verified_oneonone_chats(&[alice, bob, fiona]).await; | ||
|
||
let alice_fiona_contact_id = Contact::create(&alice, "Fiona", "[email protected]").await?; | ||
|
||
// Bob and Fiona scan Alice's QR code. | ||
tcm.execute_securejoin(bob, alice).await; | ||
tcm.execute_securejoin(fiona, alice).await; | ||
|
||
// Alice creates protected group with Bob. | ||
let alice_chat_id = alice | ||
.create_group_with_members(ProtectionStatus::Protected, "Group", &[bob]) | ||
.await; | ||
let alice_sent_group_promotion = alice.send_text(alice_chat_id, "I created a group").await; | ||
let msg = bob.recv_msg(&alice_sent_group_promotion).await; | ||
let bob_chat_id = msg.chat_id; | ||
|
||
// Alice adds Fiona. | ||
add_contact_to_chat(&alice, alice_chat_id, alice_fiona_contact_id).await?; | ||
let alice_sent_member_added = alice.pop_sent_msg().await; | ||
|
||
// Bob receives "Alice added Fiona" message. | ||
bob.recv_msg(&alice_sent_member_added).await; | ||
|
||
// Bob sends a message to the group. | ||
let bob_sent_message = bob.send_text(bob_chat_id, "Hi").await; | ||
|
||
// Fiona receives message from Bob before receiving | ||
// "Member added" message. | ||
let fiona_received_message = fiona.recv_msg(&bob_sent_message).await; | ||
assert_eq!( | ||
fiona_received_message.get_text(), | ||
"[The message was sent with non-verified encryption. See 'Info' for more details]" | ||
); | ||
|
||
Ok(()) | ||
} | ||
|
||
// ============== Helper Functions ============== | ||
|
||
async fn assert_verified(this: &TestContext, other: &TestContext, protected: ProtectionStatus) { | ||
|