From 90b0f946ec49eca8449f0ef137e62ef21416cb0e Mon Sep 17 00:00:00 2001 From: Hocuri Date: Wed, 21 Jan 2026 22:16:08 +0100 Subject: [PATCH] Make the remaining Rust tests pass --- src/chat/chat_tests.rs | 17 ++++++++------ src/mimefactory.rs | 1 + src/securejoin/securejoin_tests.rs | 22 ++++++++----------- ...test_broadcast_joining_golden_private_chat | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index 1be8cb46d..8e2636626 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -2741,8 +2741,8 @@ async fn test_broadcast_members_cant_see_each_other() -> Result<()> { let vc_pubkey = alice.pop_sent_msg().await; assert_eq!(vc_pubkey.recipients, "charlie@example.net"); let parsed = charlie.parse_msg(&vc_pubkey).await; - assert!(parsed.get_header(HeaderDef::AutocryptGossip).is_some()); - assert!(parsed.decoded_data_contains("charlie@example.net")); + assert!(parsed.get_header(HeaderDef::AutocryptGossip).is_none()); + assert_eq!(parsed.decoded_data_contains("charlie@example.net"), false); assert_eq!(parsed.decoded_data_contains("bob@example.net"), false); let parsed_by_bob = bob.parse_msg(&vc_pubkey).await; @@ -3182,14 +3182,17 @@ async fn test_broadcast_joining_golden() -> Result<()> { .await; let alice_bob_contact = alice.add_or_lookup_contact_no_key(bob).await; - let private_chat = ChatIdBlocked::lookup_by_contact(alice, alice_bob_contact.id) - .await? - .unwrap(); // The 1:1 chat with Bob should not be visible to the user: - assert_eq!(private_chat.blocked, Blocked::Yes); + assert!( + ChatIdBlocked::lookup_by_contact(alice, alice_bob_contact.id) + .await? + .is_none() + ); + let private_chat_id = + ChatId::create_for_contact_with_blocked(alice, alice_bob_contact.id, Blocked::Not).await?; alice .golden_test_chat( - private_chat.id, + private_chat_id, "test_broadcast_joining_golden_private_chat", ) .await; diff --git a/src/mimefactory.rs b/src/mimefactory.rs index 22af1b2bf..08500899b 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -2310,6 +2310,7 @@ pub(crate) async fn render_symm_encrypted_securejoin_message( "Auto-Submitted", mail_builder::headers::raw::Raw::new("auto-generated".to_string()).into(), )); + // TODO it's not nice that we're comparing strings here } else if step != "vc-request-pubkey" { headers.push(( "Auto-Submitted", diff --git a/src/securejoin/securejoin_tests.rs b/src/securejoin/securejoin_tests.rs index 62a59ece5..6e79e288e 100644 --- a/src/securejoin/securejoin_tests.rs +++ b/src/securejoin/securejoin_tests.rs @@ -462,7 +462,7 @@ async fn test_secure_join() -> Result<()> { msg.get_header(HeaderDef::SecureJoin).unwrap(), "vc-request-pubkey" ); - assert!(msg.get_header(HeaderDef::SecureJoinInvitenumber).is_some()); + assert!(msg.get_header(HeaderDef::SecureJoinAuth).is_some()); assert!(!msg.header_exists(HeaderDef::AutoSubmitted)); // Old Delta Chat core sent `Secure-Join-Group` header in `vg-request`, @@ -473,19 +473,16 @@ async fn test_secure_join() -> Result<()> { // is only sent in `vg-request-with-auth` for compatibility. assert!(!msg.header_exists(HeaderDef::SecureJoinGroup)); - tcm.section("Step 3: Alice receives vg-request, sends vg-auth-required"); + tcm.section("Step 3: Alice receives vc-request-pubkey, sends vc-pubkey"); alice.recv_msg_trash(&sent).await; let sent = alice.pop_sent_msg().await; assert!(sent.payload.contains("Auto-Submitted: auto-replied")); let msg = bob.parse_msg(&sent).await; assert!(msg.was_encrypted()); - assert_eq!( - msg.get_header(HeaderDef::SecureJoin).unwrap(), - "vg-auth-required" - ); + assert_eq!(msg.get_header(HeaderDef::SecureJoin).unwrap(), "vc-pubkey"); - tcm.section("Step 4: Bob receives vg-auth-required, sends vg-request-with-auth"); + tcm.section("Step 4: Bob receives vc-pubkey, sends vg-request-with-auth"); bob.recv_msg_trash(&sent).await; let sent = bob.pop_sent_msg().await; @@ -579,13 +576,12 @@ async fn test_secure_join() -> Result<()> { { // Now Alice's chat with Bob should still be hidden, the verified message should // appear in the group chat. - - let chat = alice.get_chat(&bob).await; - assert_eq!( - chat.blocked, - Blocked::Yes, - "Alice's 1:1 chat with Bob is not hidden" + assert!( + ChatIdBlocked::lookup_by_contact(&alice, contact_bob.id) + .await? + .is_none() ); + // There should be 2 messages in the chat: // - The ChatProtectionEnabled message // - You added member bob@example.net diff --git a/test-data/golden/test_broadcast_joining_golden_private_chat b/test-data/golden/test_broadcast_joining_golden_private_chat index d4a1739d4..a77ef169a 100644 --- a/test-data/golden/test_broadcast_joining_golden_private_chat +++ b/test-data/golden/test_broadcast_joining_golden_private_chat @@ -1,4 +1,4 @@ Single#Chat#1002: bob@example.net [KEY bob@example.net] -------------------------------------------------------------------------------- -Msg#1003: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO] +Msg#1007: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO] --------------------------------------------------------------------------------