@@ -630,6 +630,27 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
630
630
expect ( ev . decryptionFailureReason ) . toEqual ( DecryptionFailureCode . HISTORICAL_MESSAGE_USER_NOT_JOINED ) ;
631
631
} ) ;
632
632
633
+ newBackendOnly (
634
+ "fails with NOT_JOINED if user is not member of room (MSC4115 unstable prefix)" ,
635
+ async ( ) => {
636
+ fetchMock . get ( "path:/_matrix/client/v3/room_keys/version" , {
637
+ status : 404 ,
638
+ body : { errcode : "M_NOT_FOUND" , error : "No current backup version." } ,
639
+ } ) ;
640
+ expectAliceKeyQuery ( { device_keys : { "@alice:localhost" : { } } , failures : { } } ) ;
641
+ await startClientAndAwaitFirstSync ( ) ;
642
+
643
+ const ev = await sendEventAndAwaitDecryption ( {
644
+ unsigned : {
645
+ [ UNSIGNED_MEMBERSHIP_FIELD . altName ! ] : "leave" ,
646
+ } ,
647
+ } ) ;
648
+ expect ( ev . decryptionFailureReason ) . toEqual (
649
+ DecryptionFailureCode . HISTORICAL_MESSAGE_USER_NOT_JOINED ,
650
+ ) ;
651
+ } ,
652
+ ) ;
653
+
633
654
newBackendOnly (
634
655
"fails with another error when the server reports user was a member of the room" ,
635
656
async ( ) => {
@@ -654,6 +675,30 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
654
675
} ,
655
676
) ;
656
677
678
+ newBackendOnly (
679
+ "fails with another error when the server reports user was a member of the room (MSC4115 unstable prefix)" ,
680
+ async ( ) => {
681
+ // This tests that when the server reports that the user
682
+ // was invited at the time the event was sent, then we
683
+ // don't get a HISTORICAL_MESSAGE_USER_NOT_JOINED error,
684
+ // and instead get some other error, since the user should
685
+ // have gotten the key for the event.
686
+ fetchMock . get ( "path:/_matrix/client/v3/room_keys/version" , {
687
+ status : 404 ,
688
+ body : { errcode : "M_NOT_FOUND" , error : "No current backup version." } ,
689
+ } ) ;
690
+ expectAliceKeyQuery ( { device_keys : { "@alice:localhost" : { } } , failures : { } } ) ;
691
+ await startClientAndAwaitFirstSync ( ) ;
692
+
693
+ const ev = await sendEventAndAwaitDecryption ( {
694
+ unsigned : {
695
+ [ UNSIGNED_MEMBERSHIP_FIELD . altName ! ] : "invite" ,
696
+ } ,
697
+ } ) ;
698
+ expect ( ev . decryptionFailureReason ) . toEqual ( DecryptionFailureCode . HISTORICAL_MESSAGE_NO_KEY_BACKUP ) ;
699
+ } ,
700
+ ) ;
701
+
657
702
newBackendOnly (
658
703
"fails with another error when the server reports user was a member of the room" ,
659
704
async ( ) => {
@@ -676,6 +721,29 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
676
721
expect ( ev . decryptionFailureReason ) . toEqual ( DecryptionFailureCode . HISTORICAL_MESSAGE_NO_KEY_BACKUP ) ;
677
722
} ,
678
723
) ;
724
+
725
+ newBackendOnly (
726
+ "fails with another error when the server reports user was a member of the room (MSC4115 unstable prefix)" ,
727
+ async ( ) => {
728
+ // This tests that when the server reports the user's
729
+ // membership, and reports that the user was joined, then we
730
+ // don't get a HISTORICAL_MESSAGE_USER_NOT_JOINED error, and
731
+ // instead get some other error.
732
+ fetchMock . get ( "path:/_matrix/client/v3/room_keys/version" , {
733
+ status : 404 ,
734
+ body : { errcode : "M_NOT_FOUND" , error : "No current backup version." } ,
735
+ } ) ;
736
+ expectAliceKeyQuery ( { device_keys : { "@alice:localhost" : { } } , failures : { } } ) ;
737
+ await startClientAndAwaitFirstSync ( ) ;
738
+
739
+ const ev = await sendEventAndAwaitDecryption ( {
740
+ unsigned : {
741
+ [ UNSIGNED_MEMBERSHIP_FIELD . altName ! ] : "join" ,
742
+ } ,
743
+ } ) ;
744
+ expect ( ev . decryptionFailureReason ) . toEqual ( DecryptionFailureCode . HISTORICAL_MESSAGE_NO_KEY_BACKUP ) ;
745
+ } ,
746
+ ) ;
679
747
} ) ;
680
748
681
749
it ( "Decryption fails with Unable to decrypt for other errors" , async ( ) => {
0 commit comments