Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
iequidoo committed Jan 15, 2024
1 parent 0e81709 commit 18d0fa2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 42 deletions.
12 changes: 6 additions & 6 deletions src/receive_imf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -974,12 +974,12 @@ async fn add_parts(
.await?;
let now = tools::time();
let update_config = if last_time.saturating_add(24 * 60 * 60) <= now {
let mut msg = Message::new(Viewtype::Text);
msg.text = stock_str::cant_decrypt_outgoing_msgs(context).await;
chat::add_device_msg(context, None, Some(&mut msg))
.await
.log_err(context)
.ok();
// let mut msg = Message::new(Viewtype::Text);
// msg.text = stock_str::cant_decrypt_outgoing_msgs(context).await;
// chat::add_device_msg(context, None, Some(&mut msg))
// .await
// .log_err(context)
// .ok();
true
} else {
last_time > now
Expand Down
70 changes: 35 additions & 35 deletions src/receive_imf/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3152,41 +3152,41 @@ async fn test_blocked_contact_creates_group() -> Result<()> {
Ok(())
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_outgoing_undecryptable() -> Result<()> {
let alice = &TestContext::new().await;
alice.configure_addr("[email protected]").await;

let raw = include_bytes!("../../test-data/message/thunderbird_with_autocrypt.eml");
receive_imf(alice, raw, false).await?;

let bob_contact_id = Contact::lookup_id_by_addr(alice, "[email protected]", Origin::OutgoingTo)
.await?
.unwrap();
assert!(ChatId::lookup_by_contact(alice, bob_contact_id)
.await?
.is_none());

let dev_chat_id = ChatId::lookup_by_contact(alice, ContactId::DEVICE)
.await?
.unwrap();
let dev_msg = alice.get_last_msg_in(dev_chat_id).await;
assert!(dev_msg.error().is_none());
assert!(dev_msg
.text
.contains(&stock_str::cant_decrypt_outgoing_msgs(alice).await));

let raw = include_bytes!("../../test-data/message/thunderbird_encrypted_signed.eml");
receive_imf(alice, raw, false).await?;

assert!(ChatId::lookup_by_contact(alice, bob_contact_id)
.await?
.is_none());
// The device message mustn't be added too frequently.
assert_eq!(alice.get_last_msg_in(dev_chat_id).await.id, dev_msg.id);

Ok(())
}
// #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
// async fn test_outgoing_undecryptable() -> Result<()> {
// let alice = &TestContext::new().await;
// alice.configure_addr("[email protected]").await;

// let raw = include_bytes!("../../test-data/message/thunderbird_with_autocrypt.eml");
// receive_imf(alice, raw, false).await?;

// let bob_contact_id = Contact::lookup_id_by_addr(alice, "[email protected]", Origin::OutgoingTo)
// .await?
// .unwrap();
// assert!(ChatId::lookup_by_contact(alice, bob_contact_id)
// .await?
// .is_none());

// let dev_chat_id = ChatId::lookup_by_contact(alice, ContactId::DEVICE)
// .await?
// .unwrap();
// let dev_msg = alice.get_last_msg_in(dev_chat_id).await;
// assert!(dev_msg.error().is_none());
// assert!(dev_msg
// .text
// .contains(&stock_str::cant_decrypt_outgoing_msgs(alice).await));

// let raw = include_bytes!("../../test-data/message/thunderbird_encrypted_signed.eml");
// receive_imf(alice, raw, false).await?;

// assert!(ChatId::lookup_by_contact(alice, bob_contact_id)
// .await?
// .is_none());
// // The device message mustn't be added too frequently.
// assert_eq!(alice.get_last_msg_in(dev_chat_id).await.id, dev_msg.id);

// Ok(())
// }

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_thunderbird_autocrypt() -> Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/stock_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ pub(crate) async fn cant_decrypt_msg_body(context: &Context) -> String {
}

/// Stock string:`Got outgoing message(s) encrypted for another setup...`.
pub(crate) async fn cant_decrypt_outgoing_msgs(context: &Context) -> String {
pub async fn cant_decrypt_outgoing_msgs(context: &Context) -> String {
translated(context, StockMessage::CantDecryptOutgoingMsgs).await
}

Expand Down

0 comments on commit 18d0fa2

Please sign in to comment.