diff --git a/deltachat-rpc-client/tests/test_securejoin.py b/deltachat-rpc-client/tests/test_securejoin.py index da7b6090e..effb3149a 100644 --- a/deltachat-rpc-client/tests/test_securejoin.py +++ b/deltachat-rpc-client/tests/test_securejoin.py @@ -61,9 +61,16 @@ def test_qr_setup_contact_svg(acfactory) -> None: @pytest.mark.parametrize("protect", [True, False]) -def test_qr_securejoin(acfactory, protect): +def test_qr_securejoin(acfactory, protect, tmp_path): alice, bob = acfactory.get_online_accounts(2) + # Setup second device for Alice + # to test observing securejoin protocol. + alice.export_backup(tmp_path) + files = list(tmp_path.glob("*.tar")) + alice2 = acfactory.get_unconfigured_account() + alice2.import_backup(files[0]) + logging.info("Alice creates a verified group") alice_chat = alice.create_group("Verified group", protect=protect) assert alice_chat.get_basic_snapshot().is_protected == protect @@ -97,6 +104,14 @@ def test_qr_securejoin(acfactory, protect): bob_contact_alice_snapshot = bob_contact_alice.get_snapshot() assert bob_contact_alice_snapshot.is_verified + # Start second Alice device. + # Alice observes securejoin protocol and verifies Bob on second device. + alice2.start_io() + alice2.wait_for_securejoin_inviter_success() + alice2_contact_bob = alice2.get_contact_by_addr(bob.get_config("addr")) + alice2_contact_bob_snapshot = alice2_contact_bob.get_snapshot() + assert alice2_contact_bob_snapshot.is_verified + def test_qr_securejoin_contact_request(acfactory) -> None: """Alice invites Bob to a group when Bob's chat with Alice is in a contact request mode.""" diff --git a/src/securejoin.rs b/src/securejoin.rs index fdd393e69..42d0525be 100644 --- a/src/securejoin.rs +++ b/src/securejoin.rs @@ -637,6 +637,10 @@ pub(crate) async fn observe_securejoin_on_other_device( return Ok(HandshakeMessage::Ignore); }; peerstate.set_verified(key.clone(), fingerprint, addr)?; + if matches!(step, "vg-member-added" | "vc-contact-confirm") { + peerstate.backward_verified_key_id = + Some(context.get_config_i64(Config::KeyId).await?).filter(|&id| id > 0); + } peerstate.prefer_encrypt = EncryptPreference::Mutual; peerstate.save_to_db(&context.sql).await?;