feat: add option to force encryption

This commit is contained in:
link2xt
2026-05-19 22:40:28 +00:00
committed by l
parent 32e4a74050
commit d0696504d1
15 changed files with 179 additions and 23 deletions
+24
View File
@@ -109,9 +109,11 @@ pub async fn ensure_secret_key_exists(context: &Context) -> Result<()> {
#[cfg(test)]
mod tests {
use super::*;
use crate::chat;
use crate::chat::send_text_msg;
use crate::config::Config;
use crate::message::Message;
use crate::mimeparser::SystemMessage;
use crate::receive_imf::receive_imf;
use crate::test_utils::{TestContext, TestContextManager};
@@ -155,6 +157,28 @@ Sent with my Delta Chat Messenger: https://delta.chat";
);
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_cannot_send_unencrypted_by_default() -> Result<()> {
let mut tcm = TestContextManager::new();
let alice = &tcm.alice().await;
let bob = &tcm.bob().await;
let chat = alice.create_email_chat(bob).await;
let mut msg = Message::new_text("Hello!".to_string());
assert!(chat::send_msg(alice, chat.id, &mut msg).await.is_err());
assert_eq!(
msg.error().unwrap(),
"\u{26a0}\u{fe0f} Your email provider example.org requires end-to-end encryption which is not setup yet."
);
let info_msg = alice.get_last_msg().await;
assert_eq!(
info_msg.get_info_type(),
SystemMessage::InvalidUnencryptedMail
);
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_chatmail_can_send_unencrypted() -> Result<()> {
let mut tcm = TestContextManager::new();