mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
test: port test_forward_encrypted_to_unencrypted from legacy Python to Rust
This commit is contained in:
@@ -487,26 +487,6 @@ def test_forward_messages(acfactory, lp):
|
||||
assert not chat3.get_messages()
|
||||
|
||||
|
||||
def test_forward_encrypted_to_unencrypted(acfactory, lp):
|
||||
ac1, ac2, ac3 = acfactory.get_online_accounts(3)
|
||||
chat = acfactory.get_protected_chat(ac1, ac2)
|
||||
|
||||
lp.sec("ac1: send encrypted message to ac2")
|
||||
txt = "This should be encrypted"
|
||||
chat.send_text(txt)
|
||||
msg = ac2._evtracker.wait_next_incoming_message()
|
||||
assert msg.text == txt
|
||||
assert msg.is_encrypted()
|
||||
|
||||
lp.sec("ac2: forward message to ac3 unencrypted")
|
||||
unencrypted_chat = ac2.create_chat(ac3)
|
||||
msg_id = msg.id
|
||||
msg2 = unencrypted_chat.send_msg(msg)
|
||||
assert msg2 == msg
|
||||
assert msg.id != msg_id
|
||||
assert not msg.is_encrypted()
|
||||
|
||||
|
||||
def test_forward_own_message(acfactory, lp):
|
||||
ac1, ac2 = acfactory.get_online_accounts(2)
|
||||
chat = acfactory.get_accepted_chat(ac1, ac2)
|
||||
|
||||
@@ -2294,6 +2294,29 @@ async fn test_forward_from_saved_to_saved() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_forward_encrypted_to_unencrypted() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
let alice = &tcm.alice().await;
|
||||
let bob = &tcm.bob().await;
|
||||
let charlie = &tcm.charlie().await;
|
||||
|
||||
let txt = "This should be encrypted";
|
||||
let sent = alice.send_text(alice.create_chat(bob).await.id, txt).await;
|
||||
let msg = bob.recv_msg(&sent).await;
|
||||
assert_eq!(msg.text, txt);
|
||||
assert!(msg.get_showpadlock());
|
||||
|
||||
let unencrypted_chat = bob.create_email_chat(charlie).await;
|
||||
forward_msgs(bob, &[msg.id], unencrypted_chat.id).await?;
|
||||
let msg2 = bob.get_last_msg().await;
|
||||
assert_eq!(msg2.text, txt);
|
||||
assert_ne!(msg.id, msg2.id);
|
||||
assert!(!msg2.get_showpadlock());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_save_from_saved_to_saved_failing() -> Result<()> {
|
||||
let alice = TestContext::new_alice().await;
|
||||
|
||||
Reference in New Issue
Block a user