1
+ use std:: time:: Duration ;
2
+
1
3
use deltachat_contact_tools:: EmailAddress ;
2
4
3
5
use super :: * ;
@@ -7,6 +9,7 @@ use crate::constants::Chattype;
7
9
use crate :: key:: self_fingerprint;
8
10
use crate :: mimeparser:: GossipedKey ;
9
11
use crate :: receive_imf:: receive_imf;
12
+ use crate :: tools:: SystemTime ;
10
13
use crate :: stock_str:: { self , messages_e2e_encrypted} ;
11
14
use crate :: test_utils:: {
12
15
TestContext , TestContextManager , TimeShiftFalsePositiveNote , get_chat_msg,
@@ -800,3 +803,37 @@ async fn test_wrong_auth_token() -> Result<()> {
800
803
801
804
Ok ( ( ) )
802
805
}
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