@@ -8,7 +8,8 @@ use crate::key::self_fingerprint;
8
8
use crate :: receive_imf:: receive_imf;
9
9
use crate :: stock_str:: { self , chat_protection_enabled} ;
10
10
use crate :: test_utils:: {
11
- TestContext , TestContextManager , TimeShiftFalsePositiveNote , get_chat_msg,
11
+ AVATAR_64x64_BYTES , AVATAR_64x64_DEDUPLICATED , TestContext , TestContextManager ,
12
+ TimeShiftFalsePositiveNote , get_chat_msg,
12
13
} ;
13
14
use crate :: tools:: SystemTime ;
14
15
use std:: time:: Duration ;
@@ -819,3 +820,50 @@ async fn test_wrong_auth_token() -> Result<()> {
819
820
820
821
Ok ( ( ) )
821
822
}
823
+
824
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
825
+ async fn test_send_avatar_in_securejoin ( ) -> Result < ( ) > {
826
+ async fn exec_securejoin_group (
827
+ tcm : & TestContextManager ,
828
+ scanner : & TestContext ,
829
+ scanned : & TestContext ,
830
+ ) {
831
+ let chat_id = chat:: create_group_chat ( scanned, ProtectionStatus :: Protected , "group" )
832
+ . await
833
+ . unwrap ( ) ;
834
+ let qr = get_securejoin_qr ( scanned, Some ( chat_id) ) . await . unwrap ( ) ;
835
+ tcm. exec_securejoin_qr ( scanner, scanned, & qr) . await ;
836
+ }
837
+
838
+ for alice_scans in [ true , false ] {
839
+ let mut tcm = TestContextManager :: new ( ) ;
840
+ let alice = & tcm. alice ( ) . await ;
841
+ let bob = & tcm. bob ( ) . await ;
842
+
843
+ let file = alice. dir . path ( ) . join ( "avatar.png" ) ;
844
+ tokio:: fs:: write ( & file, AVATAR_64x64_BYTES ) . await ?;
845
+ alice
846
+ . set_config ( Config :: Selfavatar , Some ( file. to_str ( ) . unwrap ( ) ) )
847
+ . await ?;
848
+
849
+ if alice_scans {
850
+ tcm. execute_securejoin ( alice, bob) . await ;
851
+ //exec_securejoin_group(&tcm, alice, bob).await;
852
+ //exec_securejoin_broadcast(&tcm, alice, bob).await;
853
+ // TODO also test these
854
+ } else {
855
+ tcm. execute_securejoin ( bob, alice) . await ;
856
+ //exec_securejoin_group(&tcm, bob, alice).await;
857
+ //exec_securejoin_broadcast(&tcm, alice, bob).await;
858
+ }
859
+
860
+ let alice_on_bob = bob. add_or_lookup_contact_no_key ( & alice) . await ;
861
+ let avatar = alice_on_bob. get_profile_image ( & bob) . await ?. unwrap ( ) ;
862
+ assert_eq ! (
863
+ avatar. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) ,
864
+ AVATAR_64x64_DEDUPLICATED
865
+ ) ;
866
+ }
867
+
868
+ Ok ( ( ) )
869
+ }
0 commit comments