mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 21:06:31 +03:00
address link2xt review comments, simplify/improve test
This commit is contained in:
@@ -13,9 +13,10 @@ use crate::constants::DC_GCL_FOR_FORWARDING;
|
|||||||
use crate::contact;
|
use crate::contact;
|
||||||
use crate::imap::prefetch_should_download;
|
use crate::imap::prefetch_should_download;
|
||||||
use crate::imex::{ImexMode, imex};
|
use crate::imex::{ImexMode, imex};
|
||||||
|
use crate::key;
|
||||||
use crate::securejoin::get_securejoin_qr;
|
use crate::securejoin::get_securejoin_qr;
|
||||||
use crate::test_utils::{
|
use crate::test_utils::{
|
||||||
E2EE_INFO_MSGS, TestContext, TestContextManager, get_chat_msg, mark_as_verified,
|
E2EE_INFO_MSGS, TestContext, TestContextManager, alice_keypair, get_chat_msg, mark_as_verified,
|
||||||
};
|
};
|
||||||
use crate::tools::{SystemTime, time};
|
use crate::tools::{SystemTime, time};
|
||||||
|
|
||||||
@@ -5562,43 +5563,26 @@ async fn test_calendar_alternative() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test that self-sent encrypted messages are detected as outgoing
|
/// Tests that outgoing encrypted messages are detected
|
||||||
/// via signature fingerprint, independently from From address.
|
/// by verifying own signature, completely ignoring From address.
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_outgoing_by_signature_unknown_self_addr() -> Result<()> {
|
async fn test_outgoing_determined_by_signature() -> Result<()> {
|
||||||
let mut tcm = TestContextManager::new();
|
let mut tcm = TestContextManager::new();
|
||||||
let export_dir = tempfile::tempdir().unwrap();
|
|
||||||
let alice = &tcm.alice().await;
|
let alice = &tcm.alice().await;
|
||||||
let bob = &tcm.bob().await;
|
let bob = &tcm.bob().await;
|
||||||
|
|
||||||
let msg = tcm.send_recv_accept(alice, bob, "hi bob").await;
|
|
||||||
msg.chat_id.accept(bob).await?;
|
|
||||||
tcm.send_recv(bob, alice, "hi alice").await;
|
|
||||||
|
|
||||||
imex(alice, ImexMode::ExportSelfKeys, export_dir.path(), None).await?;
|
|
||||||
|
|
||||||
// alice_dev2: same key, different address.
|
// alice_dev2: same key, different address.
|
||||||
let different_from = "very@different.from";
|
let different_from = "very@different.from";
|
||||||
assert!(!alice.is_self_addr(different_from).await?);
|
assert!(!alice.is_self_addr(different_from).await?);
|
||||||
|
let alice_dev2 = &tcm.unconfigured().await;
|
||||||
let alice_dev2 = &TestContext::new().await;
|
|
||||||
alice_dev2.configure_addr(different_from).await;
|
alice_dev2.configure_addr(different_from).await;
|
||||||
imex(
|
key::store_self_keypair(alice_dev2, &alice_keypair()).await?;
|
||||||
alice_dev2,
|
|
||||||
ImexMode::ImportSelfKeys,
|
|
||||||
export_dir.path(),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
assert!(alice.get_config(Config::Addr).await?.unwrap() != different_from);
|
assert!(alice.get_config(Config::Addr).await?.unwrap() != different_from);
|
||||||
|
|
||||||
let msg = tcm.send_recv_accept(bob, alice_dev2, "hi alice_dev2").await;
|
// Sent message from alice_dev2 and check alice sees it as outgoing
|
||||||
let sent_msg = alice_dev2
|
let chat_id = alice_dev2.create_chat_id(bob).await;
|
||||||
.send_text(msg.chat_id, "hello from new device")
|
let sent_msg = alice_dev2.send_text(chat_id, "hello from new device").await;
|
||||||
.await;
|
|
||||||
let msg = alice.recv_msg(&sent_msg).await;
|
let msg = alice.recv_msg(&sent_msg).await;
|
||||||
// despite different from it's still recognized as an outgoing message
|
|
||||||
assert_eq!(msg.state, MessageState::OutDelivered);
|
assert_eq!(msg.state, MessageState::OutDelivered);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user