mirror of
https://github.com/chatmail/core.git
synced 2026-10-03 03:30:36 +03:00
feat: add option to force encryption
This commit is contained in:
+24
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user