Skip to content

Commit 0310a22

Browse files
committed
Test that Bob is not verified if Auth token expired
1 parent dee5d11 commit 0310a22

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/securejoin/securejoin_tests.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::time::Duration;
2+
13
use deltachat_contact_tools::EmailAddress;
24

35
use super::*;
@@ -7,6 +9,7 @@ use crate::constants::Chattype;
79
use crate::key::self_fingerprint;
810
use crate::mimeparser::GossipedKey;
911
use crate::receive_imf::receive_imf;
12+
use crate::tools::SystemTime;
1013
use crate::stock_str::{self, messages_e2e_encrypted};
1114
use crate::test_utils::{
1215
TestContext, TestContextManager, TimeShiftFalsePositiveNote, get_chat_msg,
@@ -800,3 +803,37 @@ async fn test_wrong_auth_token() -> Result<()> {
800803

801804
Ok(())
802805
}
806+
807+
/// Tests that scanning a QR code week later
808+
/// allows Bob to establish a contact with Alice,
809+
/// but does not mark Bob as verified for Alice.
810+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
811+
async fn test_expired_auth_token() -> Result<()> {
812+
let mut tcm = TestContextManager::new();
813+
let alice = &tcm.alice().await;
814+
let bob = &tcm.bob().await;
815+
816+
// Alice creates a QR code.
817+
let alice_qr = get_securejoin_qr(alice, None).await?;
818+
819+
// One week passes, QR code expires.
820+
SystemTime::shift(Duration::from_secs(7 * 24 * 3600));
821+
822+
// Bob scans the QR code.
823+
join_securejoin(bob, &alice_qr).await?;
824+
825+
// vc-request
826+
alice.recv_msg_trash(&bob.pop_sent_msg().await).await;
827+
828+
// vc-auth-requried
829+
bob.recv_msg_trash(&alice.pop_sent_msg().await).await;
830+
831+
// vc-request-with-auth
832+
alice.recv_msg_trash(&bob.pop_sent_msg().await).await;
833+
834+
// Bob should not be verified for Alice.
835+
let contact_bob = alice.add_or_lookup_contact_no_key(&bob).await;
836+
assert_eq!(contact_bob.is_verified(&alice).await.unwrap(), false);
837+
838+
Ok(())
839+
}

0 commit comments

Comments
 (0)