mirror of
https://github.com/chatmail/core.git
synced 2026-05-23 00:36:32 +03:00
test: fix test_encrypt_decrypt_broadcast()
This commit is contained in:
@@ -5226,7 +5226,7 @@ impl Context {
|
|||||||
Blocked::Not,
|
Blocked::Not,
|
||||||
ProtectionStatus::Unprotected,
|
ProtectionStatus::Unprotected,
|
||||||
None,
|
None,
|
||||||
create_smeared_timestamp(self),
|
smeared_time(self),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
save_broadcast_shared_secret(self, chat_id, shared_secret).await?;
|
save_broadcast_shared_secret(self, chat_id, shared_secret).await?;
|
||||||
|
|||||||
@@ -3099,13 +3099,14 @@ async fn test_leave_broadcast_multidevice() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_encrypt_decrypt_broadcast_integration() -> Result<()> {
|
async fn test_encrypt_decrypt_broadcast() -> Result<()> {
|
||||||
let mut tcm = TestContextManager::new();
|
let mut tcm = TestContextManager::new();
|
||||||
let alice = &tcm.alice().await;
|
let alice = &tcm.alice().await;
|
||||||
let bob = &tcm.bob().await;
|
let bob = &tcm.bob().await;
|
||||||
let bob_without_secret = &tcm.bob().await;
|
let bob_without_secret = &tcm.bob().await;
|
||||||
|
|
||||||
let secret = "secret";
|
let secret = "secret";
|
||||||
|
let grpid = "grpid";
|
||||||
|
|
||||||
let alice_bob_contact_id = alice.add_or_lookup_contact_id(bob).await;
|
let alice_bob_contact_id = alice.add_or_lookup_contact_id(bob).await;
|
||||||
|
|
||||||
@@ -3114,19 +3115,24 @@ async fn test_encrypt_decrypt_broadcast_integration() -> Result<()> {
|
|||||||
alice,
|
alice,
|
||||||
Sync,
|
Sync,
|
||||||
"My Channel".to_string(),
|
"My Channel".to_string(),
|
||||||
"grpid".to_string(),
|
grpid.to_string(),
|
||||||
secret.to_string(),
|
secret.to_string(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
add_contact_to_chat(alice, alice_chat_id, alice_bob_contact_id).await?;
|
add_to_chat_contacts_table(alice, time(), alice_chat_id, &[alice_bob_contact_id]).await?;
|
||||||
|
|
||||||
// TODO the chat_id 10 is magical here:
|
let bob_chat_id = ChatId::create_multiuser_record(
|
||||||
bob.sql
|
bob,
|
||||||
.execute(
|
Chattype::InBroadcast,
|
||||||
"INSERT INTO broadcasts_shared_secrets (chat_id, secret) VALUES (10, ?)",
|
grpid,
|
||||||
(secret,),
|
"My Channel",
|
||||||
)
|
Blocked::Not,
|
||||||
.await?;
|
ProtectionStatus::Unprotected,
|
||||||
|
None,
|
||||||
|
time(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
save_broadcast_shared_secret(bob, bob_chat_id, secret).await?;
|
||||||
|
|
||||||
let sent = alice
|
let sent = alice
|
||||||
.send_text(alice_chat_id, "Symmetrically encrypted message")
|
.send_text(alice_chat_id, "Symmetrically encrypted message")
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use crate::param::Param;
|
|||||||
use crate::securejoin::{ContactId, encrypted_and_signed, verify_sender_by_fingerprint};
|
use crate::securejoin::{ContactId, encrypted_and_signed, verify_sender_by_fingerprint};
|
||||||
use crate::stock_str;
|
use crate::stock_str;
|
||||||
use crate::sync::Sync::*;
|
use crate::sync::Sync::*;
|
||||||
use crate::tools::{create_smeared_timestamp, time};
|
use crate::tools::{smeared_time, time};
|
||||||
|
|
||||||
/// Starts the securejoin protocol with the QR `invite`.
|
/// Starts the securejoin protocol with the QR `invite`.
|
||||||
///
|
///
|
||||||
@@ -445,7 +445,7 @@ async fn joining_chat_id(
|
|||||||
Blocked::Not,
|
Blocked::Not,
|
||||||
ProtectionStatus::Unprotected, // protection is added later as needed
|
ProtectionStatus::Unprotected, // protection is added later as needed
|
||||||
None,
|
None,
|
||||||
create_smeared_timestamp(context),
|
smeared_time(context),
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user