fix: create group chats unprotected on verification error

This commit is contained in:
link2xt
2025-05-31 11:04:12 +00:00
committed by l
parent 32263b4574
commit becb83faf1
3 changed files with 24 additions and 13 deletions

View File

@@ -434,9 +434,10 @@ def test_verified_group_vs_delete_server_after(acfactory, tmp_path, lp):
- First device of the user downloads "member added" from the group. - First device of the user downloads "member added" from the group.
- First device removes "member added" from the server. - First device removes "member added" from the server.
- Some new messages are sent to the group. - Some new messages are sent to the group.
- Second device comes online, receives these new messages. The result is a verified group with unverified members. - Second device comes online, receives these new messages.
The result is an unverified group with unverified members.
- First device re-gossips Autocrypt keys to the group. - First device re-gossips Autocrypt keys to the group.
- Now the seconds device has all members verified. - Now the second device has all members and group verified.
""" """
ac1, ac2 = acfactory.get_online_accounts(2) ac1, ac2 = acfactory.get_online_accounts(2)
acfactory.remove_preconfigured_keys() acfactory.remove_preconfigured_keys()
@@ -474,12 +475,12 @@ def test_verified_group_vs_delete_server_after(acfactory, tmp_path, lp):
ac2_offl.start_io() ac2_offl.start_io()
msg_in = ac2_offl._evtracker.wait_next_incoming_message() msg_in = ac2_offl._evtracker.wait_next_incoming_message()
assert not msg_in.is_system_message() assert not msg_in.is_system_message()
assert msg_in.text.startswith("[The message was sent with non-verified encryption") assert msg_in.text == "hi"
ac2_offl_ac1_contact = msg_in.get_sender_contact() ac2_offl_ac1_contact = msg_in.get_sender_contact()
assert ac2_offl_ac1_contact.addr == ac1.get_config("addr") assert ac2_offl_ac1_contact.addr == ac1.get_config("addr")
assert not ac2_offl_ac1_contact.is_verified() assert not ac2_offl_ac1_contact.is_verified()
chat2_offl = msg_in.chat chat2_offl = msg_in.chat
assert chat2_offl.is_protected() assert not chat2_offl.is_protected()
lp.sec("ac2: sending message re-gossiping Autocrypt keys") lp.sec("ac2: sending message re-gossiping Autocrypt keys")
chat2.send_text("hi2") chat2.send_text("hi2")
@@ -500,6 +501,7 @@ def test_verified_group_vs_delete_server_after(acfactory, tmp_path, lp):
assert msg_in.text == "hi2" assert msg_in.text == "hi2"
assert msg_in.chat == chat2_offl assert msg_in.chat == chat2_offl
assert msg_in.get_sender_contact().addr == ac2.get_config("addr") assert msg_in.get_sender_contact().addr == ac2.get_config("addr")
assert msg_in.chat.is_protected()
assert ac2_offl_ac1_contact.is_verified() assert ac2_offl_ac1_contact.is_verified()

View File

@@ -2138,11 +2138,14 @@ async fn create_group(
let create_protected = if mime_parser.get_header(HeaderDef::ChatVerified).is_some() { let create_protected = if mime_parser.get_header(HeaderDef::ChatVerified).is_some() {
if let VerifiedEncryption::NotVerified(err) = verified_encryption { if let VerifiedEncryption::NotVerified(err) = verified_encryption {
warn!(context, "Verification problem: {err:#}."); warn!(
let s = format!("{err}. See 'Info' for more details"); context,
mime_parser.replace_msg_by_error(&s); "Creating unprotected group because of the verification problem: {err:#}."
);
ProtectionStatus::Unprotected
} else {
ProtectionStatus::Protected
} }
ProtectionStatus::Protected
} else { } else {
ProtectionStatus::Unprotected ProtectionStatus::Unprotected
}; };

View File

@@ -918,12 +918,18 @@ async fn test_verified_member_added_reordering() -> Result<()> {
let bob_sent_message = bob.send_text(bob_chat_id, "Hi").await; let bob_sent_message = bob.send_text(bob_chat_id, "Hi").await;
// Fiona receives message from Bob before receiving // Fiona receives message from Bob before receiving
// "Member added" message. // "Member added" message, so unverified group is created.
let fiona_received_message = fiona.recv_msg(&bob_sent_message).await; let fiona_received_message = fiona.recv_msg(&bob_sent_message).await;
assert_eq!( let fiona_chat = Chat::load_from_db(fiona, fiona_received_message.chat_id).await?;
fiona_received_message.get_text(),
"[The message was sent with non-verified encryption. See 'Info' for more details]" assert_eq!(fiona_received_message.get_text(), "Hi");
); assert_eq!(fiona_chat.is_protected(), false);
// Fiona receives late "Member added" message
// and the chat becomes protected.
fiona.recv_msg(&alice_sent_member_added).await;
let fiona_chat = Chat::load_from_db(fiona, fiona_received_message.chat_id).await?;
assert_eq!(fiona_chat.is_protected(), true);
Ok(()) Ok(())
} }