mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
test: return chat ID from TestContext.exec_securejoin_qr()
This commit is contained in:
@@ -167,7 +167,10 @@ impl TestContextManager {
|
||||
);
|
||||
}
|
||||
|
||||
pub async fn execute_securejoin(&self, scanner: &TestContext, scanned: &TestContext) {
|
||||
/// Executes SecureJoin protocol between `scanner` and `scanned`.
|
||||
///
|
||||
/// Returns chat ID of the 1:1 chat for `scanner`.
|
||||
pub async fn execute_securejoin(&self, scanner: &TestContext, scanned: &TestContext) -> ChatId {
|
||||
self.section(&format!(
|
||||
"{} scans {}'s QR code",
|
||||
scanner.name(),
|
||||
@@ -175,12 +178,20 @@ impl TestContextManager {
|
||||
));
|
||||
|
||||
let qr = get_securejoin_qr(&scanned.ctx, None).await.unwrap();
|
||||
self.exec_securejoin_qr(scanner, scanned, &qr).await;
|
||||
self.exec_securejoin_qr(scanner, scanned, &qr).await
|
||||
}
|
||||
|
||||
/// Executes SecureJoin initiated by `scanner` scanning `qr` generated by `scanned`.
|
||||
pub async fn exec_securejoin_qr(&self, scanner: &TestContext, scanned: &TestContext, qr: &str) {
|
||||
join_securejoin(&scanner.ctx, qr).await.unwrap();
|
||||
///
|
||||
/// The [`ChatId`] of the created chat is returned, for a SetupContact QR this is the 1:1
|
||||
/// chat with `scanned`, for a SecureJoin QR this is the group chat.
|
||||
pub async fn exec_securejoin_qr(
|
||||
&self,
|
||||
scanner: &TestContext,
|
||||
scanned: &TestContext,
|
||||
qr: &str,
|
||||
) -> ChatId {
|
||||
let chat_id = join_securejoin(&scanner.ctx, qr).await.unwrap();
|
||||
|
||||
loop {
|
||||
if let Some(sent) = scanner.pop_sent_msg_opt(Duration::ZERO).await {
|
||||
@@ -191,6 +202,7 @@ impl TestContextManager {
|
||||
break;
|
||||
}
|
||||
}
|
||||
chat_id
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -186,14 +186,14 @@ async fn test_missing_peerstate_reexecute_securejoin() -> Result<()> {
|
||||
let alice_addr = alice.get_config(Config::Addr).await?.unwrap();
|
||||
let bob = &tcm.bob().await;
|
||||
enable_verified_oneonone_chats(&[alice, bob]).await;
|
||||
tcm.execute_securejoin(bob, alice).await;
|
||||
let chat = bob.get_chat(alice).await;
|
||||
let chat_id = tcm.execute_securejoin(bob, alice).await;
|
||||
let chat = Chat::load_from_db(bob, chat_id).await?;
|
||||
assert!(chat.is_protected());
|
||||
bob.sql
|
||||
.execute("DELETE FROM acpeerstates WHERE addr=?", (&alice_addr,))
|
||||
.await?;
|
||||
tcm.execute_securejoin(bob, alice).await;
|
||||
let chat = bob.get_chat(alice).await;
|
||||
let chat_id = tcm.execute_securejoin(bob, alice).await;
|
||||
let chat = Chat::load_from_db(bob, chat_id).await?;
|
||||
assert!(chat.is_protected());
|
||||
assert!(!chat.is_protection_broken());
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user