@@ -529,7 +529,7 @@ func RunTestBackendServer_RoomDisinvite(ctx context.Context, t *testing.T) {
529529 testDefaultUserId ,
530530 },
531531 SessionIds : []api.RoomSessionId {
532- api .RoomSessionId (fmt .Sprintf ("%s-%s" + roomId , hello .Hello .SessionId )),
532+ api .RoomSessionId (fmt .Sprintf ("%s-%s" , roomId , hello .Hello .SessionId )),
533533 },
534534 Properties : roomProperties ,
535535 },
@@ -555,9 +555,16 @@ func RunTestBackendServer_RoomDisinvite(ctx context.Context, t *testing.T) {
555555 }
556556 if message , ok := client .RunUntilRoomlistDisinvite (ctx ); ok {
557557 assert .Equal (roomId , message .RoomId )
558+ assert .Equal (api .DisinviteReasonDisinvited , message .Reason )
559+ }
560+ if message , ok := client .RunUntilMessageOrClosed (ctx ); ok && message != nil {
561+ // The client might receive a second disinvite message as both the userid and the session id were disinvited.
562+ if message , ok := checkMessageRoomlistDisinvite (t , message ); ok {
563+ assert .Equal (roomId , message .RoomId )
564+ assert .Equal (api .DisinviteReasonDisinvited , message .Reason )
565+ }
566+ client .RunUntilClosed (ctx )
558567 }
559-
560- client .RunUntilClosed (ctx )
561568}
562569
563570func TestBackendServer_RoomDisinviteDifferentRooms (t * testing.T ) {
@@ -591,7 +598,7 @@ func TestBackendServer_RoomDisinviteDifferentRooms(t *testing.T) {
591598 testDefaultUserId ,
592599 },
593600 SessionIds : []api.RoomSessionId {
594- api .RoomSessionId (fmt .Sprintf ("%s-%s" + roomId1 , hello1 .Hello .SessionId )),
601+ api .RoomSessionId (fmt .Sprintf ("%s-%s" , roomId1 , hello1 .Hello .SessionId )),
595602 },
596603 },
597604 }
@@ -610,12 +617,20 @@ func TestBackendServer_RoomDisinviteDifferentRooms(t *testing.T) {
610617 }
611618 if message , ok := client1 .RunUntilRoomlistDisinvite (ctx ); ok {
612619 assert .Equal (roomId1 , message .RoomId )
620+ assert .Equal (api .DisinviteReasonDisinvited , message .Reason )
621+ }
622+ if message , ok := client1 .RunUntilMessageOrClosed (ctx ); ok && message != nil {
623+ // The client might receive a second disinvite message as both the userid and the session id were disinvited.
624+ if message , ok := checkMessageRoomlistDisinvite (t , message ); ok {
625+ assert .Equal (roomId1 , message .RoomId )
626+ assert .Equal (api .DisinviteReasonDisinvited , message .Reason )
627+ }
628+ client1 .RunUntilClosed (ctx )
613629 }
614-
615- client1 .RunUntilClosed (ctx )
616630
617631 if message , ok := client2 .RunUntilRoomlistDisinvite (ctx ); ok {
618632 assert .Equal (roomId1 , message .RoomId )
633+ assert .Equal (api .DisinviteReasonDisinvited , message .Reason )
619634 }
620635
621636 msg = & talk.BackendServerRoomRequest {
@@ -639,6 +654,62 @@ func TestBackendServer_RoomDisinviteDifferentRooms(t *testing.T) {
639654 }
640655}
641656
657+ func TestBackendServer_RoomDisinviteClustered (t * testing.T ) {
658+ t .Parallel ()
659+ logger := logtest .NewLoggerForTest (t )
660+ ctx := log .NewLoggerContext (t .Context (), logger )
661+ require := require .New (t )
662+ assert := assert .New (t )
663+ _ , _ , hub1 , hub2 , server1 , server2 := CreateBackendServerWithClusteringForTest (t )
664+
665+ ctx , cancel := context .WithTimeout (ctx , testTimeout )
666+ defer cancel ()
667+
668+ client1 , hello1 := NewTestClientWithHello (ctx , t , server1 , hub1 , testDefaultUserId + "1" )
669+ defer client1 .CloseWithBye ()
670+ client2 , hello2 := NewTestClientWithHello (ctx , t , server2 , hub2 , testDefaultUserId + "2" )
671+ defer client2 .CloseWithBye ()
672+
673+ // Join room by id.
674+ roomId := "test-room1"
675+ MustSucceed2 (t , client1 .JoinRoom , ctx , roomId )
676+ MustSucceed2 (t , client2 .JoinRoom , ctx , roomId )
677+ WaitForUsersJoined (ctx , t , client1 , hello1 , client2 , hello2 )
678+
679+ msg := & talk.BackendServerRoomRequest {
680+ Type : "disinvite" ,
681+ Disinvite : & talk.BackendRoomDisinviteRequest {
682+ SessionIds : []api.RoomSessionId {
683+ api .RoomSessionId (fmt .Sprintf ("%s-%s" , roomId , hello2 .Hello .SessionId )),
684+ },
685+ },
686+ }
687+
688+ data , err := json .Marshal (msg )
689+ require .NoError (err )
690+ res , err := performBackendRequest (server1 .URL + "/api/v1/room/" + roomId , data )
691+ require .NoError (err )
692+ defer res .Body .Close ()
693+ body , err := io .ReadAll (res .Body )
694+ assert .NoError (err )
695+ assert .Equal (http .StatusOK , res .StatusCode , "Expected successful request, got %s" , string (body ))
696+
697+ if message , ok := client1 .RunUntilRoomlistUpdate (ctx ); ok {
698+ assert .Equal (roomId , message .RoomId )
699+ }
700+
701+ if message , ok := client2 .RunUntilRoomlistUpdate (ctx ); ok {
702+ assert .Equal (roomId , message .RoomId )
703+ }
704+ if message , ok := client2 .RunUntilRoomlistDisinvite (ctx ); ok {
705+ assert .Equal (roomId , message .RoomId )
706+ assert .Equal (api .DisinviteReasonDisinvited , message .Reason )
707+ }
708+ client2 .RunUntilClosed (ctx )
709+
710+ client1 .RunUntilLeft (ctx , hello2 .Hello )
711+ }
712+
642713func TestBackendServer_RoomUpdate (t * testing.T ) {
643714 t .Parallel ()
644715 for _ , backend := range eventstest .EventBackendsForTest {
0 commit comments