Skip to content

Commit 9a564b5

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 6bdba33 commit 9a564b5

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
@@ -5154,6 +5154,44 @@ async fn test_dont_reverify_by_self_on_outgoing_msg() -> Result<()> {
51545154
Ok(())
51555155
}
51565156

5157+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
5158+
async fn test_dont_verify_by_verified_by_unknown() -> Result<()> {
5159+
let mut tcm = TestContextManager::new();
5160+
let a0 = &tcm.alice().await;
5161+
let a1 = &tcm.alice().await;
5162+
let bob = &tcm.bob().await;
5163+
let fiona = &tcm.fiona().await;
5164+
5165+
let bob_chat_id = chat::create_group_chat(bob, ProtectionStatus::Protected, "Group").await?;
5166+
let qr = get_securejoin_qr(bob, Some(bob_chat_id)).await?;
5167+
tcm.exec_securejoin_qr(a0, bob, &qr).await;
5168+
tcm.exec_securejoin_qr(fiona, bob, &qr).await;
5169+
// Bob verifies Fiona for Alice#0.
5170+
a0.recv_msg(&bob.send_text(bob_chat_id, "Hi").await).await;
5171+
5172+
let chat_id = a0
5173+
.create_group_with_members(ProtectionStatus::Protected, "", &[fiona])
5174+
.await;
5175+
a1.recv_msg(&a0.send_text(chat_id, "Hi").await).await;
5176+
let a1_fiona = a1.add_or_lookup_contact(fiona).await;
5177+
assert_eq!(a1_fiona.get_verifier_id(a1).await?, Some(None));
5178+
5179+
let fiona_chat_id = fiona.get_last_msg().await.chat_id;
5180+
a1.recv_msg(&fiona.send_text(fiona_chat_id, "Hi").await)
5181+
.await;
5182+
let a1_bob = a1.add_or_lookup_contact(bob).await;
5183+
// There was a bug that Bob is verified by Fiona on Alice's other device.
5184+
assert_eq!(a1_bob.get_verifier_id(a1).await?, Some(None));
5185+
5186+
tcm.execute_securejoin(a1, fiona).await;
5187+
a1.recv_msg(&fiona.send_text(fiona_chat_id, "Hi").await)
5188+
.await;
5189+
// But now Bob's verifier id must be updated because Fiona is verified by a known verifier
5190+
// (moreover, directly), so Alice has reverse verification chains on her devices.
5191+
assert_eq!(a1_bob.get_verifier_id(a1).await?, Some(Some(a1_fiona.id)));
5192+
Ok(())
5193+
}
5194+
51575195
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
51585196
async fn test_sanitize_filename_in_received() -> Result<()> {
51595197
let alice = &TestContext::new_alice().await;

0 commit comments

Comments
 (0)