@@ -18,8 +18,8 @@ use assert_matches2::{assert_let, assert_matches};
18
18
use futures_util:: { pin_mut, FutureExt , StreamExt } ;
19
19
use itertools:: Itertools ;
20
20
use matrix_sdk_common:: deserialized_responses:: {
21
- UnableToDecryptInfo , UnableToDecryptReason , UnsignedDecryptionResult , UnsignedEventLocation ,
22
- WithheldCode ,
21
+ AlgorithmInfo , UnableToDecryptInfo , UnableToDecryptReason , UnsignedDecryptionResult ,
22
+ UnsignedEventLocation , VerificationLevel , VerificationState , WithheldCode ,
23
23
} ;
24
24
use matrix_sdk_test:: { async_test, message_like_event_content, ruma_response_from_json, test_json} ;
25
25
use ruma:: {
@@ -418,6 +418,42 @@ async fn test_room_key_sharing() {
418
418
assert_eq ! ( room_key_updates[ 0 ] . session_id, alice_session. session_id( ) ) ;
419
419
}
420
420
421
+ #[ async_test]
422
+ async fn test_session_encryption_info_can_be_fetched ( ) {
423
+ // Given a megolm session has been established
424
+ let ( alice, bob) = get_machine_pair_with_session ( alice_id ( ) , user_id ( ) , false ) . await ;
425
+ let room_id = room_id ! ( "!test:example.org" ) ;
426
+
427
+ send_room_key_to_device ( & alice, & bob, room_id) . await . unwrap ( ) ;
428
+
429
+ let alice_session =
430
+ alice. inner . group_session_manager . get_outbound_group_session ( room_id) . unwrap ( ) ;
431
+
432
+ let session = bob
433
+ . store ( )
434
+ . get_inbound_group_session ( room_id, alice_session. session_id ( ) )
435
+ . await
436
+ . unwrap ( )
437
+ . unwrap ( ) ;
438
+
439
+ // When I request the encryption info about this session
440
+ let encryption_info =
441
+ bob. get_session_encryption_info ( room_id, session. session_id ( ) , alice_id ( ) ) . await . unwrap ( ) ;
442
+
443
+ // Then the expected info is returned
444
+ assert_eq ! ( encryption_info. sender, alice_id( ) ) ;
445
+ assert_eq ! ( encryption_info. sender_device. unwrap( ) , alice_device_id( ) ) ;
446
+ assert_matches ! (
447
+ encryption_info. algorithm_info,
448
+ AlgorithmInfo :: MegolmV1AesSha2 { curve25519_key, .. }
449
+ ) ;
450
+ assert_eq ! ( curve25519_key, alice_session. sender_key( ) . to_string( ) ) ;
451
+ assert_eq ! (
452
+ encryption_info. verification_state,
453
+ VerificationState :: Unverified ( VerificationLevel :: UnsignedDevice )
454
+ ) ;
455
+ }
456
+
421
457
#[ async_test]
422
458
async fn test_to_device_messages_from_dehydrated_devices_are_ignored ( ) {
423
459
// Given alice's device is dehydrated
0 commit comments