diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index bdd54f31f..1a635c591 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -1050,6 +1050,7 @@ async fn chatlist_len(ctx: &Context, listflags: usize) -> usize { async fn test_archive() { // create two chats let t = TestContext::new_alice().await; + let mut msg = Message::new_text("foo".to_string()); let msg_id = add_device_msg(&t, None, Some(&mut msg)).await.unwrap(); let chat_id1 = message::Message::load_from_db(&t, msg_id) @@ -1386,6 +1387,7 @@ async fn test_markfresh_chat() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_archive_fresh_msgs() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; async fn msg_from(t: &TestContext, name: &str, num: u32) -> Result<()> { receive_imf( @@ -1918,6 +1920,7 @@ async fn test_marknoticed_chat() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_contact_request_fresh_messages() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; let chats = Chatlist::try_load(&t, 0, None, None).await?; assert_eq!(chats.len(), 0); @@ -2013,6 +2016,7 @@ async fn test_contact_request_archive() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_classic_email_chat() -> Result<()> { let alice = TestContext::new_alice().await; + alice.allow_unencrypted().await?; // Alice receives a classic (non-chat) message from Bob. receive_imf( @@ -2566,6 +2570,7 @@ async fn test_forward_encrypted_to_unencrypted() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; let charlie = &tcm.charlie().await; + bob.allow_unencrypted().await?; let txt = "This should be encrypted"; let sent = alice.send_text(alice.create_chat(bob).await.id, txt).await; @@ -4702,6 +4707,7 @@ async fn test_sync_adhoc_grp() -> Result<()> { let alice1 = &tcm.alice().await; for a in [alice0, alice1] { a.set_config_bool(Config::SyncMsgs, true).await?; + a.allow_unencrypted().await?; } let mut chat_ids = Vec::new(); @@ -6073,6 +6079,7 @@ async fn test_no_key_contacts_in_adhoc_chats() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; let charlie = &tcm.charlie().await; + alice.allow_unencrypted().await?; let chat_id = receive_imf( alice, @@ -6108,6 +6115,7 @@ async fn test_no_key_contacts_in_adhoc_chats() -> Result<()> { async fn test_create_unencrypted_group_chat() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; + alice.allow_unencrypted().await?; let bob = &tcm.bob().await; let charlie = &tcm.charlie().await; diff --git a/src/chatlist.rs b/src/chatlist.rs index 534dccf91..0563ea70e 100644 --- a/src/chatlist.rs +++ b/src/chatlist.rs @@ -665,6 +665,7 @@ mod tests { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_search_single_chat() -> anyhow::Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; // receive a one-to-one-message receive_imf( @@ -725,6 +726,7 @@ mod tests { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_search_single_chat_without_authname() -> anyhow::Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; // receive a one-to-one-message without authname set receive_imf( diff --git a/src/contact/contact_tests.rs b/src/contact/contact_tests.rs index 47312f4db..fbdf8133c 100644 --- a/src/contact/contact_tests.rs +++ b/src/contact/contact_tests.rs @@ -335,6 +335,7 @@ async fn test_add_or_lookup() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_contact_name_changes() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; // first message creates contact and one-to-one-chat without name set receive_imf( @@ -927,9 +928,12 @@ async fn test_synchronize_status() -> Result<()> { // Alice has two devices. let alice1 = &tcm.alice().await; let alice2 = &tcm.alice().await; + alice1.allow_unencrypted().await?; + alice2.allow_unencrypted().await?; // Bob has one device. let bob = &tcm.bob().await; + bob.allow_unencrypted().await?; let default_status = alice1.get_config(Config::Selfstatus).await?; @@ -1083,6 +1087,7 @@ async fn test_was_seen_recently_event() -> Result<()> { async fn test_lookup_id_by_addr_recent_ex(accept_unencrypted_chat: bool) -> Result<()> { let mut tcm = TestContextManager::new(); let bob = &tcm.bob().await; + bob.allow_unencrypted().await?; let raw = include_bytes!("../../test-data/message/thunderbird_with_autocrypt.eml"); assert!(std::str::from_utf8(raw)?.contains("Date: Thu, 24 Nov 2022 20:05:57 +0100")); diff --git a/src/context/context_tests.rs b/src/context/context_tests.rs index 7b8a036dc..bb5efa369 100644 --- a/src/context/context_tests.rs +++ b/src/context/context_tests.rs @@ -54,6 +54,7 @@ async fn receive_msg(t: &TestContext, chat: &Chat) { async fn test_get_fresh_msgs_and_muted_chats() { // receive various mails in 3 chats let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); let bob = t.create_chat_with_contact("", "bob@g.it").await; let claire = t.create_chat_with_contact("", "claire@g.it").await; let dave = t.create_chat_with_contact("", "dave@g.it").await; @@ -103,6 +104,7 @@ async fn test_get_fresh_msgs_and_muted_chats() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_get_fresh_msgs_and_muted_until() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); let bob = t.create_chat_with_contact("", "bob@g.it").await; receive_msg(&t, &bob).await; assert_eq!(get_chat_msgs(&t, bob.id).await.unwrap().len(), 1); @@ -158,6 +160,7 @@ async fn test_get_fresh_msgs_and_muted_until() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_muted_context() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; assert_eq!(t.get_fresh_msgs().await.unwrap().len(), 0); t.set_config(Config::IsMuted, Some("1")).await?; let chat = t.create_chat_with_contact("", "bob@g.it").await; diff --git a/src/decrypt.rs b/src/decrypt.rs index 21fd3d3cf..5768aff4a 100644 --- a/src/decrypt.rs +++ b/src/decrypt.rs @@ -402,6 +402,7 @@ mod tests { assert!(get_attachment_mime(&mail).is_some()); let bob = TestContext::new_bob().await; + bob.allow_unencrypted().await?; receive_imf(&bob, attachment_mime, false).await?; let msg = bob.get_last_msg().await; // Subject should be prepended because the attachment doesn't have "Chat-Version". @@ -416,6 +417,7 @@ mod tests { // Desktop via MS Exchange (actually made with TB though). let mixed_up_mime = include_bytes!("../test-data/message/mixed-up-long.eml"); let bob = TestContext::new_bob().await; + bob.allow_unencrypted().await?; receive_imf(&bob, mixed_up_mime, false).await?; let msg = bob.get_last_msg().await; assert!(!msg.get_text().is_empty()); diff --git a/src/e2ee.rs b/src/e2ee.rs index 0ca08e1be..45edc4d6b 100644 --- a/src/e2ee.rs +++ b/src/e2ee.rs @@ -160,6 +160,7 @@ Sent with my Delta Chat Messenger: https://delta.chat"; let mut tcm = TestContextManager::new(); let bob = &tcm.bob().await; bob.set_config_bool(Config::IsChatmail, true).await?; + bob.allow_unencrypted().await?; let bob_chat_id = receive_imf( bob, b"From: alice@example.org\n\ diff --git a/src/events/chatlist_events.rs b/src/events/chatlist_events.rs index 540e6a6e0..ec909a12f 100644 --- a/src/events/chatlist_events.rs +++ b/src/events/chatlist_events.rs @@ -521,6 +521,7 @@ mod test_chatlist_events { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_adhoc_group() -> Result<()> { let alice = TestContext::new_alice().await; + alice.allow_unencrypted().await?; let mime = br#"Subject: First thread Message-ID: first@example.org To: Alice , Bob diff --git a/src/html.rs b/src/html.rs index 5c64ee665..b05600e2d 100644 --- a/src/html.rs +++ b/src/html.rs @@ -451,6 +451,7 @@ test some special html-characters as < > and & but also " and &#x // alice receives a non-delta html-message let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; + alice.allow_unencrypted().await?; let chat = alice .create_chat_with_contact("", "sender@testrun.org") .await; @@ -484,6 +485,7 @@ test some special html-characters as < > and & but also " and &#x // bob: check that bob also got the html-part of the forwarded message let bob = &tcm.bob().await; + bob.allow_unencrypted().await?; let chat_bob = bob.create_chat_with_contact("", "alice@example.org").await; async fn check_receiver(ctx: &TestContext, chat: &Chat, sender: &TestContext) { let msg = ctx.recv_msg(&sender.pop_sent_msg().await).await; @@ -523,6 +525,7 @@ test some special html-characters as < > and & but also " and &#x async fn test_html_save_msg() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; + alice.allow_unencrypted().await?; // Alice receives a non-delta html-message let chat = alice .create_chat_with_contact("", "sender@testrun.org") @@ -554,6 +557,7 @@ test some special html-characters as < > and & but also " and &#x let mut tcm = TestContextManager::new(); // Alice receives a non-delta html-message let alice = &tcm.alice().await; + alice.allow_unencrypted().await.unwrap(); let chat = alice .create_chat_with_contact("", "sender@testrun.org") .await; @@ -619,6 +623,7 @@ test some special html-characters as < > and & but also " and &#x async fn test_cp1252_html() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; + alice.allow_unencrypted().await?; receive_imf( alice, include_bytes!("../test-data/message/cp1252-html.eml"), diff --git a/src/message/message_tests.rs b/src/message/message_tests.rs index 0293465e3..959491163 100644 --- a/src/message/message_tests.rs +++ b/src/message/message_tests.rs @@ -111,6 +111,8 @@ async fn test_unencrypted_quote_encrypted_message() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; + alice.allow_unencrypted().await?; + bob.allow_unencrypted().await?; tcm.section("Bob sends encrypted message to Alice"); let alice_chat = alice.create_chat(bob).await; @@ -458,6 +460,7 @@ async fn test_get_state() -> Result<()> { async fn test_is_bot() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; + alice.allow_unencrypted().await?; // Alice receives an auto-generated non-chat message. // diff --git a/src/mimefactory/mimefactory_tests.rs b/src/mimefactory/mimefactory_tests.rs index a47b613e8..d67fb2b7e 100644 --- a/src/mimefactory/mimefactory_tests.rs +++ b/src/mimefactory/mimefactory_tests.rs @@ -183,10 +183,12 @@ async fn test_subject_from_dc() { async fn test_subject_outgoing() { // 3. Send the first message to a new contact let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); assert_eq!(first_subject_str(t).await, "Message from alice@example.org"); let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); t.set_config(Config::Displayname, Some("Alice")) .await .unwrap(); @@ -229,6 +231,7 @@ async fn test_subject_mdn() { let mut tcm = TestContextManager::new(); let t = &tcm.alice().await; let bob = &tcm.bob().await; + t.allow_unencrypted().await.unwrap(); receive_imf( t, b"From: alice@example.org\r\n\ @@ -280,10 +283,12 @@ async fn test_subject_mdn() { async fn test_mdn_create_encrypted() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; + alice.allow_unencrypted().await?; alice .set_config(Config::Displayname, Some("Alice Exampleorg")) .await?; let bob = tcm.bob().await; + bob.allow_unencrypted().await?; bob.set_config(Config::Displayname, Some("Bob Examplenet")) .await?; bob.set_config(Config::Selfstatus, Some("Bob Examplenet")) diff --git a/src/mimeparser/mimeparser_tests.rs b/src/mimeparser/mimeparser_tests.rs index 476853fdb..9ea75bd2b 100644 --- a/src/mimeparser/mimeparser_tests.rs +++ b/src/mimeparser/mimeparser_tests.rs @@ -1185,6 +1185,7 @@ async fn test_allinkl_blockquote() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_add_subj_to_multimedia_msg() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf( &t.ctx, include_bytes!("../../test-data/message/subj_with_multimedia_msg.eml"), @@ -1461,6 +1462,7 @@ async fn test_intended_recipient_fingerprint() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_long_in_reply_to() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; // A message with a long Message-ID. // Long message-IDs are generated by Mailjet. @@ -1599,6 +1601,7 @@ async fn test_ignore_read_receipt_to_self() -> Result<()> { async fn test_ms_exchange_mdn() -> Result<()> { let mut tcm = TestContextManager::new(); let t = tcm.alice().await; + t.allow_unencrypted().await?; let original = include_bytes!("../../test-data/message/ms_exchange_report_original_message.eml"); @@ -1985,6 +1988,8 @@ async fn test_chat_edit_imf_header() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; let bob = &tcm.bob().await; + alice.allow_unencrypted().await?; + bob.allow_unencrypted().await?; let alice_chat = alice.create_email_chat(bob).await; // Alice sends a message, then sends an invalid edit request. @@ -2049,6 +2054,7 @@ async fn test_multiple_autocrypt_hdrs() -> Result<()> { async fn test_receive_signed_only() -> Result<()> { let mut tcm = TestContextManager::new(); let bob = &tcm.bob().await; + bob.allow_unencrypted().await?; let imf_raw = include_bytes!("../../test-data/message/unencrypted_signed_simple.eml"); let msg = receive_imf(bob, imf_raw, false).await?.unwrap(); diff --git a/src/receive_imf/receive_imf_tests.rs b/src/receive_imf/receive_imf_tests.rs index 04c292237..844f6cd2b 100644 --- a/src/receive_imf/receive_imf_tests.rs +++ b/src/receive_imf/receive_imf_tests.rs @@ -81,6 +81,7 @@ static GRP_MAIL: &[u8] = #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_adhoc_group_is_shown() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap(); assert_eq!(chats.len(), 0); @@ -101,6 +102,7 @@ async fn test_adhoc_group_is_shown() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_adhoc_group_show_accepted_contact_accepted() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); // accept Bob by accepting a delta-message from Bob receive_imf(&t, MSGRMSG, false).await.unwrap(); @@ -136,6 +138,7 @@ async fn test_adhoc_group_show_accepted_contact_accepted() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_adhoc_group_show_all() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf(&t, GRP_MAIL, false).await.unwrap(); // adhoc-group with unknown contacts with show_emails=all will show up in a single chat @@ -155,6 +158,7 @@ async fn test_adhoc_group_show_all() { async fn test_adhoc_groups_merge() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; + alice.allow_unencrypted().await?; receive_imf( alice, b"From: bob@example.net\n\ @@ -355,6 +359,7 @@ async fn test_no_message_id_header() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_escaped_from() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); let contact_id = Contact::create(&t, "foobar", "foobar@example.com") .await .unwrap(); @@ -388,6 +393,7 @@ async fn test_escaped_from() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_escaped_recipients() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); Contact::create(&t, "foobar", "foobar@example.com") .await .unwrap(); @@ -435,6 +441,7 @@ async fn test_escaped_recipients() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_cc_to_contact() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); Contact::create(&t, "foobar", "foobar@example.com") .await .unwrap(); @@ -591,6 +598,7 @@ async fn test_parse_ndn( ) -> (TestContext, MsgId) { let t = TestContext::new().await; t.configure_addr(self_addr).await; + t.allow_unencrypted().await.unwrap(); receive_imf( &t, @@ -675,6 +683,7 @@ async fn test_resend_after_ndn() -> Result<()> { async fn test_parse_ndn_group_msg() -> Result<()> { let t = TestContext::new().await; t.configure_addr("alice@gmail.com").await; + t.allow_unencrypted().await?; receive_imf( &t, @@ -716,6 +725,7 @@ async fn test_parse_ndn_group_msg() -> Result<()> { async fn test_concat_multiple_ndns() -> Result<()> { let t = TestContext::new().await; t.configure_addr("alice@posteo.org").await; + t.allow_unencrypted().await?; let mid = "1234@mail.gmail.com"; receive_imf( &t, @@ -773,6 +783,7 @@ async fn load_imf_email(context: &Context, imf_raw: &[u8]) -> Message { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_html_only_mail() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); let msg = load_imf_email(&t, include_bytes!("../../test-data/message/wrong-html.eml")).await; assert_eq!( msg.text, @@ -808,6 +819,7 @@ static GH_MAILINGLIST2: &str = "Received: (Postfix, from userid 1000); Mon, 4 De #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_github_mailing_list() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; receive_imf(&t.ctx, GH_MAILINGLIST, false).await?; @@ -881,6 +893,8 @@ static DC_MAILINGLIST2: &[u8] = b"Received: (Postfix, from userid 1000); Mon, 4 #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_classic_mailing_list() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; + receive_imf(&t.ctx, DC_MAILINGLIST, false).await.unwrap(); let chats = Chatlist::try_load(&t.ctx, 0, None, None).await.unwrap(); let chat_id = chats.get_chat_id(0).unwrap(); @@ -922,6 +936,8 @@ Hello mailinglist!\r\n" #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_other_device_writes_to_mailinglist() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; + receive_imf(&t, DC_MAILINGLIST, false).await.unwrap(); let first_msg = t.get_last_msg().await; let first_chat = Chat::load_from_db(&t, first_msg.chat_id).await?; @@ -972,6 +988,7 @@ async fn test_other_device_writes_to_mailinglist() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_block_mailing_list() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf(&t.ctx, DC_MAILINGLIST, false).await.unwrap(); t.evtracker.wait_next_incoming_message().await; @@ -1006,6 +1023,7 @@ async fn test_block_mailing_list() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mailing_list_decide_block_then_unblock() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf(&t, DC_MAILINGLIST, false).await.unwrap(); let blocked = Contact::get_all_blocked(&t).await.unwrap(); @@ -1036,6 +1054,7 @@ async fn test_mailing_list_decide_block_then_unblock() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mailing_list_decide_not_now() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf(&t.ctx, DC_MAILINGLIST, false).await.unwrap(); @@ -1063,6 +1082,7 @@ async fn test_mailing_list_decide_not_now() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mailing_list_decide_accept() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf(&t.ctx, DC_MAILINGLIST, false).await.unwrap(); @@ -1085,6 +1105,8 @@ async fn test_mailing_list_decide_accept() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mailing_list_multiple_names_in_subject() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; + receive_imf( &t, b"From: Foo Bar \n\ @@ -1109,6 +1131,7 @@ async fn test_mailing_list_multiple_names_in_subject() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_majordomo_mailing_list() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; // test mailing lists not having a `ListId:`-header receive_imf( @@ -1161,6 +1184,7 @@ async fn test_majordomo_mailing_list() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mailchimp_mailing_list() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; receive_imf( &t, @@ -1194,6 +1218,7 @@ async fn test_mailchimp_mailing_list() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_dhl_mailing_list() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; receive_imf( &t, @@ -1219,6 +1244,7 @@ async fn test_dhl_mailing_list() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_dpd_mailing_list() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; receive_imf( &t, @@ -1244,6 +1270,7 @@ async fn test_dpd_mailing_list() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_xt_local_mailing_list() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; receive_imf( &t, @@ -1277,6 +1304,7 @@ async fn test_xt_local_mailing_list() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_xing_mailing_list() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; receive_imf( &t, @@ -1299,6 +1327,7 @@ async fn test_xing_mailing_list() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_ttline_mailing_list() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; receive_imf( &t, @@ -1319,6 +1348,7 @@ async fn test_ttline_mailing_list() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mailing_list_with_mimepart_footer() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); // the mailing list message contains two top-level texts. // the second text is a footer that is added by some mailing list software @@ -1346,6 +1376,7 @@ async fn test_mailing_list_with_mimepart_footer() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mailing_list_with_mimepart_footer_signed() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf( &t, @@ -1370,6 +1401,7 @@ async fn test_mailing_list_with_mimepart_footer_signed() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_apply_mailinglist_changes_assigned_by_reply() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf(&t, GH_MAILINGLIST, false).await.unwrap(); @@ -1408,6 +1440,7 @@ async fn test_apply_mailinglist_changes_assigned_by_reply() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mailing_list_chat_message() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf( &t, @@ -1430,6 +1463,7 @@ async fn test_mailing_list_chat_message() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mailing_list_bot() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); t.set_config(Config::Bot, Some("1")).await.unwrap(); receive_imf( @@ -1462,6 +1496,8 @@ async fn test_dont_show_noreply_in_contacts_list() { async fn check_dont_show_in_contacts_list(addr: &str) { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); + receive_imf( &t, format!( @@ -1491,6 +1527,7 @@ YEAAAAAA!. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_pdf_filename_simple() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); let msg = load_imf_email( &t, include_bytes!("../../test-data/message/pdf_filename_simple.eml"), @@ -1511,6 +1548,7 @@ async fn test_pdf_filename_simple() { async fn test_pdf_filename_continuation() { // test filenames split across multiple header lines, see rfc 2231 let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); let msg = load_imf_email( &t, include_bytes!("../../test-data/message/pdf_filename_continuation.eml"), @@ -1536,6 +1574,7 @@ async fn test_pdf_filename_continuation() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_many_images() { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf( &t, @@ -1556,6 +1595,7 @@ async fn test_many_images() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_in_reply_to() { let t = TestContext::new().await; + t.allow_unencrypted().await.unwrap(); t.configure_addr("bob@example.com").await; // Receive message from Alice about group "foo". @@ -1631,6 +1671,7 @@ async fn test_save_mime_headers_off() -> anyhow::Result<()> { async fn check_alias_reply(from_dc: bool, chat_request: bool, group_request: bool) { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; + alice.allow_unencrypted().await.unwrap(); // Claire, a customer, sends a support request // to the alias address . @@ -1697,6 +1738,8 @@ async fn check_alias_reply(from_dc: bool, chat_request: bool, group_request: boo let claire = tcm.unconfigured().await; claire.configure_addr("claire@example.org").await; + claire.allow_unencrypted().await.unwrap(); + receive_imf(&claire, claire_request.as_bytes(), false) .await .unwrap(); @@ -1895,6 +1938,7 @@ async fn test_dont_show_all_outgoing_msgs_in_self_chat() { // be shown in the self-chat. let mut tcm = TestContextManager::new(); let t = &tcm.alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf( t, @@ -1922,6 +1966,7 @@ Message content", async fn test_unencrypted_doesnt_goto_self_chat() -> Result<()> { let mut tcm = TestContextManager::new(); let t = &tcm.alice().await; + t.allow_unencrypted().await?; let mut chat_id = None; for (i, to) in [ @@ -2003,6 +2048,7 @@ async fn test_no_smtp_job_for_self_chat() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_outgoing_classic_mail_creates_chat() { let alice = TestContext::new_alice().await; + alice.allow_unencrypted().await.unwrap(); // Alice downloads outgoing classic email. receive_imf( @@ -2028,6 +2074,7 @@ Message content", async fn test_duplicate_message() -> Result<()> { // Test that duplicate messages are ignored based on the Message-ID let alice = TestContext::new_alice().await; + alice.allow_unencrypted().await?; let bob_contact_id = Contact::add_or_lookup( &alice, @@ -2086,6 +2133,8 @@ Second signature"; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_ignore_footer_status_from_mailinglist() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; + let bob_id = Contact::add_or_lookup( &t, "", @@ -2165,6 +2214,8 @@ Original signature updated", #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_ignore_old_status_updates() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; + let bob_id = Contact::add_or_lookup( &t, "", @@ -2237,6 +2288,7 @@ async fn test_chat_assignment_private_classical_reply() { let mut tcm = TestContextManager::new(); for outgoing_is_classical in &[true, false] { let t = &tcm.alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf( t, @@ -2323,6 +2375,7 @@ async fn test_chat_assignment_private_chat_reply() { &[(true, true), (false, true), (false, false)] { let t = &tcm.alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf( t, @@ -2416,6 +2469,7 @@ async fn test_chat_assignment_nonprivate_classical_reply() { let mut tcm = TestContextManager::new(); for outgoing_is_classical in &[true, false] { let t = &tcm.alice().await; + t.allow_unencrypted().await.unwrap(); receive_imf( t, @@ -2526,6 +2580,9 @@ async fn test_chat_assignment_adhoc() -> Result<()> { let alice = tcm.alice().await; let bob = tcm.bob().await; let fiona = tcm.fiona().await; + alice.allow_unencrypted().await?; + bob.allow_unencrypted().await?; + fiona.allow_unencrypted().await?; let first_thread_mime = br#"Subject: First thread Message-ID: first@example.org @@ -2670,6 +2727,7 @@ async fn test_read_receipts_dont_unmark_bots() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_gmx_forwarded_msg() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; receive_imf( &t, @@ -3040,6 +3098,7 @@ async fn test_auto_accept_for_bots() -> Result<()> { async fn test_auto_accept_group_for_bots() -> Result<()> { let t = TestContext::new_alice().await; t.set_config_bool(Config::Bot, true).await.unwrap(); + t.allow_unencrypted().await.unwrap(); let msg = load_imf_email(&t, GRP_MAIL).await; let chat = chat::Chat::load_from_db(&t, msg.chat_id).await?; @@ -3268,6 +3327,7 @@ async fn test_blocked_contact_creates_group() -> Result<()> { async fn test_outgoing_undecryptable() -> Result<()> { let alice = &TestContext::new().await; alice.configure_addr("alice@example.org").await; + alice.allow_unencrypted().await?; let raw = include_bytes!("../../test-data/message/thunderbird_with_autocrypt.eml"); receive_imf(alice, raw, false).await?; @@ -3304,6 +3364,7 @@ async fn test_outgoing_undecryptable() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_thunderbird_autocrypt() -> Result<()> { let t = TestContext::new_bob().await; + t.allow_unencrypted().await?; let raw = include_bytes!("../../test-data/message/thunderbird_with_autocrypt.eml"); let received_msg = receive_imf(&t, raw, false).await?.unwrap(); @@ -3351,6 +3412,7 @@ async fn test_issuer_fingerprint() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_prefer_encrypt_mutual_if_encrypted() -> Result<()> { let t = TestContext::new_bob().await; + t.allow_unencrypted().await?; // The message has public key attached *and* Autocrypt header. // @@ -3403,6 +3465,7 @@ async fn test_prefer_encrypt_mutual_if_encrypted() -> Result<()> { async fn test_forged_from_and_no_valid_signatures() -> Result<()> { let mut tcm = TestContextManager::new(); let t = &tcm.bob().await; + t.allow_unencrypted().await?; let raw = include_bytes!("../../test-data/message/thunderbird_encrypted_signed.eml"); let received_msg = receive_imf(t, raw, false).await?.unwrap(); @@ -3413,6 +3476,7 @@ async fn test_forged_from_and_no_valid_signatures() -> Result<()> { assert!(!msg.get_showpadlock()); let t = &tcm.bob().await; + t.allow_unencrypted().await?; let raw = String::from_utf8(raw.to_vec())?.replace("alice@example.org", "clarice@example.org"); let received_msg = receive_imf(t, raw.as_bytes(), false).await?.unwrap(); assert!(received_msg.chat_id.is_trash()); @@ -3423,6 +3487,8 @@ async fn test_forged_from_and_no_valid_signatures() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_wrong_from_name_and_no_valid_signatures() -> Result<()> { let t = &TestContext::new_bob().await; + t.allow_unencrypted().await?; + let raw = include_bytes!("../../test-data/message/thunderbird_encrypted_signed.eml"); let raw = String::from_utf8(raw.to_vec())?.replace("From: Alice", "From: A"); receive_imf(t, raw.as_bytes(), false).await?.unwrap(); @@ -3437,6 +3503,7 @@ async fn test_wrong_from_name_and_no_valid_signatures() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_thunderbird_autocrypt_unencrypted() -> Result<()> { let bob = &TestContext::new_bob().await; + bob.allow_unencrypted().await?; // Thunderbird message with Autocrypt header and a signature, // but not encrypted. @@ -3475,6 +3542,8 @@ async fn test_thunderbird_autocrypt_unencrypted() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_thunderbird_unsigned() -> Result<()> { let alice = TestContext::new_alice().await; + // TODO: same test without process unencrypted should trash the message + alice.allow_unencrypted().await.unwrap(); // Alice receives an unsigned message from Bob. let raw = include_bytes!("../../test-data/message/thunderbird_encrypted_unsigned.eml"); @@ -3494,6 +3563,7 @@ async fn test_thunderbird_unsigned() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_thunderbird_unsigned_with_unencrypted_subject() -> Result<()> { let bob = TestContext::new_bob().await; + bob.allow_unencrypted().await.unwrap(); let raw = include_bytes!( "../../test-data/message/thunderbird_encrypted_unsigned_with_unencrypted_subject.eml" @@ -3586,6 +3656,7 @@ async fn test_big_forwarded_with_big_attachment() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mua_user_adds_member() -> Result<()> { let t = TestContext::new_alice().await; + t.allow_unencrypted().await?; receive_imf( &t, @@ -3637,6 +3708,7 @@ async fn test_mua_user_adds_member() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mua_user_adds_recipient_to_single_chat() -> Result<()> { let alice = TestContext::new_alice().await; + alice.allow_unencrypted().await?; // Alice sends a 1:1 message to Bob, creating a 1:1 chat. let msg = receive_imf( @@ -4069,6 +4141,7 @@ async fn test_dont_readd_with_normal_msg() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mua_cant_remove() -> Result<()> { let alice = TestContext::new_alice().await; + alice.allow_unencrypted().await?; let now = time(); @@ -4161,6 +4234,7 @@ async fn test_mua_cant_remove() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mua_can_add() -> Result<()> { let alice = TestContext::new_alice().await; + alice.allow_unencrypted().await?; let now = time(); @@ -4220,6 +4294,7 @@ async fn test_mua_can_add() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_mua_can_readd() -> Result<()> { let alice = TestContext::new_alice().await; + alice.allow_unencrypted().await?; // Alice creates chat with 3 contacts. let msg = receive_imf( @@ -4383,6 +4458,8 @@ async fn test_keep_member_list_if_possibly_nomember() -> Result<()> { async fn test_adhoc_grp_name_no_prefix() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; + alice.allow_unencrypted().await?; + let chat_id = receive_imf( alice, b"Subject: Re: Once upon a time this was with the only Re: here\n\ @@ -4530,6 +4607,7 @@ async fn test_protected_group_add_remove_member_missing_key() -> Result<()> { async fn test_older_message_from_2nd_device() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; + alice.allow_unencrypted().await?; let chat_id = alice .create_chat_with_contact("", "bob@example.net") .await @@ -4665,6 +4743,7 @@ async fn test_forged_from() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_multiline_iso_8859_1_subject() -> Result<()> { let t = &TestContext::new_alice().await; + t.allow_unencrypted().await?; let mail = b"Received: (Postfix, from userid 1000); Mon, 4 Dec 2006 14:51:39 +0100 (CET)\n\ From: bob@example.com\n\ To: alice@example.org, claire@example.com\n\ @@ -4729,6 +4808,7 @@ async fn test_references() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_list_from() -> Result<()> { let t = &TestContext::new_alice().await; + t.allow_unencrypted().await?; let raw = include_bytes!("../../test-data/message/list-from.eml"); let received = receive_imf(t, raw, false).await?.unwrap(); @@ -4858,6 +4938,7 @@ async fn test_make_n_send_vcard() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_unencrypted_group_id_no_recipients() -> Result<()> { let t = &TestContext::new_alice().await; + t.allow_unencrypted().await?; let raw = "From: alice@example.org Subject: Group Chat-Version: 1.0 @@ -5289,6 +5370,7 @@ async fn test_outgoing_unencrypted_chat_assignment() { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; let bob = &tcm.bob().await; + alice.allow_unencrypted().await.unwrap(); tcm.section("Alice receives unencrypted message from Bob"); receive_imf( @@ -5333,6 +5415,7 @@ async fn test_outgoing_unencrypted_chat_assignment() { async fn test_incoming_reply_with_date_in_past() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; + alice.allow_unencrypted().await?; let msg0 = receive_imf( alice, @@ -5474,6 +5557,8 @@ async fn test_small_unencrypted_group() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; let bob = &tcm.bob().await; + alice.allow_unencrypted().await?; + bob.allow_unencrypted().await?; let alice_chat_id = chat::create_group_unencrypted(alice, "Unencrypted group").await?; let alice_bob_id = alice.add_or_lookup_address_contact_id(bob).await; @@ -5506,6 +5591,7 @@ async fn test_small_unencrypted_group() -> Result<()> { async fn test_bcc_not_a_group() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; + alice.allow_unencrypted().await.unwrap(); let received = receive_imf( alice, @@ -5553,6 +5639,7 @@ async fn test_lookup_key_contact_by_address_self() -> Result<()> { async fn test_calendar_alternative() -> Result<()> { let mut tcm = TestContextManager::new(); let t = &tcm.alice().await; + t.allow_unencrypted().await?; let raw = include_bytes!("../../test-data/message/calendar-alternative.eml"); let msg = receive_imf(t, raw, false).await?.unwrap(); assert_eq!(msg.msg_ids.len(), 1); diff --git a/src/securejoin/securejoin_tests.rs b/src/securejoin/securejoin_tests.rs index 2543ad110..5423ae9f0 100644 --- a/src/securejoin/securejoin_tests.rs +++ b/src/securejoin/securejoin_tests.rs @@ -772,6 +772,7 @@ fn manipulate_qr(v3: bool, remove_invite: bool, qr: &mut String) { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_adhoc_group_no_qr() -> Result<()> { let alice = TestContext::new_alice().await; + alice.allow_unencrypted().await?; let mime = br#"Subject: First thread Message-ID: first@example.org @@ -1415,6 +1416,7 @@ async fn test_vc_request_encrypted_at_rest() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; let bob = &tcm.bob().await; + alice.allow_unencrypted().await?; let qr = get_securejoin_qr(alice, None).await?; diff --git a/src/stats/stats_tests.rs b/src/stats/stats_tests.rs index 3a385b604..2a07543be 100644 --- a/src/stats/stats_tests.rs +++ b/src/stats/stats_tests.rs @@ -151,6 +151,7 @@ async fn test_message_stats() -> Result<()> { alice .set_config_internal(Config::StatsSending, Some("1")) .await?; + alice.allow_unencrypted().await?; let email_chat = alice.create_email_chat(bob).await; let encrypted_chat = alice.create_chat(bob).await; diff --git a/src/test_utils.rs b/src/test_utils.rs index d158bc758..13493b162 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -1229,6 +1229,13 @@ ORDER BY id" .await .unwrap(); } + + /// Allow reception of unencrypted messages. + #[expect(clippy::unused_async)] + pub async fn allow_unencrypted(&self) -> Result<()> { + // Does nothing for now. + Ok(()) + } } pub async fn encrypt_raw_message( diff --git a/src/tests/verified_chats.rs b/src/tests/verified_chats.rs index 1ee6a0b48..46d25b554 100644 --- a/src/tests/verified_chats.rs +++ b/src/tests/verified_chats.rs @@ -175,6 +175,7 @@ async fn test_degrade_verified_oneonone_chat() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; let bob = &tcm.bob().await; + alice.allow_unencrypted().await?; mark_as_verified(alice, bob).await; @@ -272,6 +273,7 @@ async fn test_outgoing_mua_msg() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; let bob = &tcm.bob().await; + alice.allow_unencrypted().await?; mark_as_verified(alice, bob).await; mark_as_verified(bob, alice).await; @@ -333,6 +335,7 @@ async fn test_reply() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; let bob = tcm.bob().await; + alice.allow_unencrypted().await?; if verified { mark_as_verified(&alice, &bob).await; diff --git a/src/tools/tools_tests.rs b/src/tools/tools_tests.rs index 5f6367413..1aa8f0c96 100644 --- a/src/tools/tools_tests.rs +++ b/src/tools/tools_tests.rs @@ -60,6 +60,7 @@ Hop: From: hq5.example.org; By: hq5.example.org; Date: Mon, 27 Dec 2021 11:21:22 async fn check_parse_receive_headers_integration(raw: &[u8], expected: &str) { let t = TestContext::new_alice().await; + t.allow_unencrypted().await.unwrap(); let received = receive_imf(&t, raw, false).await.unwrap().unwrap(); assert_eq!(received.msg_ids.len(), 1); diff --git a/src/webxdc/webxdc_tests.rs b/src/webxdc/webxdc_tests.rs index 918f54f26..f28d10756 100644 --- a/src/webxdc/webxdc_tests.rs +++ b/src/webxdc/webxdc_tests.rs @@ -687,7 +687,9 @@ async fn test_send_webxdc_status_update() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; alice.set_config_bool(Config::BccSelf, true).await?; + alice.allow_unencrypted().await?; let bob = &tcm.bob().await; + bob.allow_unencrypted().await?; // Alice sends an webxdc instance and a status update let alice_chat = alice.create_email_chat(bob).await; @@ -753,6 +755,7 @@ async fn test_send_webxdc_status_update() -> Result<()> { // Alice has a second device and also receives messages there let alice2 = &tcm.alice().await; + alice2.allow_unencrypted().await?; alice2.recv_msg(sent1).await; alice2.recv_msg_trash(sent2).await; let alice2_instance = alice2.get_last_msg().await;