Skip to content

Commit 269bd5b

Browse files
committed
test: Contact shalln't be verified by another having unknown verifier
It must be verified by "unknown verifier" instead. But if the verifier has known verifier in turn, it must reverify contacts having unknown verifier. Add a check for this also.
1 parent e6ab1e3 commit 269bd5b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/receive_imf/receive_imf_tests.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5180,6 +5180,44 @@ async fn test_dont_reverify_by_self_on_outgoing_msg() -> Result<()> {
51805180
Ok(())
51815181
}
51825182

5183+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
5184+
async fn test_dont_verify_by_verified_by_unknown() -> Result<()> {
5185+
let mut tcm = TestContextManager::new();
5186+
let a0 = &tcm.alice().await;
5187+
let a1 = &tcm.alice().await;
5188+
let bob = &tcm.bob().await;
5189+
let fiona = &tcm.fiona().await;
5190+
5191+
let bob_chat_id = chat::create_group_chat(bob, ProtectionStatus::Protected, "Group").await?;
5192+
let qr = get_securejoin_qr(bob, Some(bob_chat_id)).await?;
5193+
tcm.exec_securejoin_qr(a0, bob, &qr).await;
5194+
tcm.exec_securejoin_qr(fiona, bob, &qr).await;
5195+
// Bob verifies Fiona for Alice#0.
5196+
a0.recv_msg(&bob.send_text(bob_chat_id, "Hi").await).await;
5197+
5198+
let chat_id = a0
5199+
.create_group_with_members(ProtectionStatus::Protected, "", &[fiona])
5200+
.await;
5201+
a1.recv_msg(&a0.send_text(chat_id, "Hi").await).await;
5202+
let a1_fiona = a1.add_or_lookup_contact(fiona).await;
5203+
assert_eq!(a1_fiona.get_verifier_id(a1).await?, Some(None));
5204+
5205+
let fiona_chat_id = fiona.get_last_msg().await.chat_id;
5206+
a1.recv_msg(&fiona.send_text(fiona_chat_id, "Hi").await)
5207+
.await;
5208+
let a1_bob = a1.add_or_lookup_contact(bob).await;
5209+
// There was a bug that Bob is verified by Fiona on Alice's other device.
5210+
assert_eq!(a1_bob.get_verifier_id(a1).await?, Some(None));
5211+
5212+
tcm.execute_securejoin(a1, fiona).await;
5213+
a1.recv_msg(&fiona.send_text(fiona_chat_id, "Hi").await)
5214+
.await;
5215+
// But now Bob's verifier id must be updated because Fiona is verified by a known verifier
5216+
// (moreover, directly), so Alice has reverse verification chains on her devices.
5217+
assert_eq!(a1_bob.get_verifier_id(a1).await?, Some(Some(a1_fiona.id)));
5218+
Ok(())
5219+
}
5220+
51835221
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
51845222
async fn test_sanitize_filename_in_received() -> Result<()> {
51855223
let alice = &TestContext::new_alice().await;

0 commit comments

Comments
 (0)