1+ // These tests currently fail on Dendrite, due to Dendrite bugs.
2+ //go:build !dendrite_blacklist
3+ // +build !dendrite_blacklist
4+
15package tests
26
37import (
8+ "encoding/json"
49 "testing"
510
611 "github.com/matrix-org/complement"
@@ -17,8 +22,17 @@ func TestFederationRoomsInvite(t *testing.T) {
1722 deployment := complement .Deploy (t , 2 )
1823 defer deployment .Destroy (t )
1924
20- alice := deployment .Register (t , "hs1" , helpers.RegistrationOpts {})
21- bob := deployment .Register (t , "hs2" , helpers.RegistrationOpts {})
25+ alice := deployment .Register (t , "hs1" , helpers.RegistrationOpts {LocalpartSuffix : "alice" })
26+ bob := deployment .Register (t , "hs2" , helpers.RegistrationOpts {LocalpartSuffix : "bob" })
27+ bob2 := deployment .Register (t , "hs2" , helpers.RegistrationOpts {LocalpartSuffix : "bob2" })
28+
29+ includeLeaveSyncFilterBytes , err := json .Marshal (map [string ]interface {}{
30+ "room" : map [string ]interface {}{
31+ "include_leave" : true ,
32+ },
33+ })
34+ must .NotError (t , "failed to marshal include_leave filter" , err )
35+ includeLeaveSyncFilter := string (includeLeaveSyncFilterBytes )
2236
2337 t .Run ("Parallel" , func (t * testing.T ) {
2438 // sytest: Invited user can reject invite over federation
@@ -30,7 +44,7 @@ func TestFederationRoomsInvite(t *testing.T) {
3044 })
3145 bob .MustSyncUntil (t , client.SyncReq {}, client .SyncInvitedTo (bob .UserID , roomID ))
3246 bob .MustLeaveRoom (t , roomID )
33- alice .MustSyncUntil (t , client.SyncReq {}, client .SyncLeftFrom (bob .UserID , roomID ))
47+ alice .MustSyncUntil (t , client.SyncReq {Filter : includeLeaveSyncFilter }, client .SyncLeftFrom (bob .UserID , roomID ))
3448 })
3549
3650 // sytest: Invited user can reject invite over federation several times
@@ -43,7 +57,7 @@ func TestFederationRoomsInvite(t *testing.T) {
4357 alice .MustInviteRoom (t , roomID , bob .UserID )
4458 bob .MustSyncUntil (t , client.SyncReq {}, client .SyncInvitedTo (bob .UserID , roomID ))
4559 bob .MustLeaveRoom (t , roomID )
46- alice .MustSyncUntil (t , client.SyncReq {}, client .SyncLeftFrom (bob .UserID , roomID ))
60+ alice .MustSyncUntil (t , client.SyncReq {Filter : includeLeaveSyncFilter }, client .SyncLeftFrom (bob .UserID , roomID ))
4761 }
4862 })
4963
@@ -57,9 +71,9 @@ func TestFederationRoomsInvite(t *testing.T) {
5771 aliceSince := alice .MustSyncUntil (t , client.SyncReq {}, client .SyncJoinedTo (alice .UserID , roomID ))
5872 bobSince := bob .MustSyncUntil (t , client.SyncReq {}, client .SyncInvitedTo (bob .UserID , roomID ))
5973 alice .MustLeaveRoom (t , roomID )
60- alice .MustSyncUntil (t , client.SyncReq {Since : aliceSince }, client .SyncLeftFrom (alice .UserID , roomID ))
74+ alice .MustSyncUntil (t , client.SyncReq {Since : aliceSince , Filter : includeLeaveSyncFilter }, client .SyncLeftFrom (alice .UserID , roomID ))
6175 bob .MustLeaveRoom (t , roomID )
62- bob .MustSyncUntil (t , client.SyncReq {Since : bobSince }, client .SyncLeftFrom (bob .UserID , roomID ))
76+ bob .MustSyncUntil (t , client.SyncReq {Since : bobSince , Filter : includeLeaveSyncFilter }, client .SyncLeftFrom (bob .UserID , roomID ))
6377 })
6478
6579 // sytest: Remote invited user can see room metadata
@@ -85,6 +99,50 @@ func TestFederationRoomsInvite(t *testing.T) {
8599 verifyState (t , res , wantFields , wantValues , roomID , alice )
86100 })
87101
102+ t .Run ("Remote invited user can join the room when homeserver is already participating in the room" , func (t * testing.T ) {
103+ t .Parallel ()
104+ roomID := alice .MustCreateRoom (t , map [string ]interface {}{
105+ "preset" : "private_chat" ,
106+ })
107+ alice .MustSyncUntil (t , client.SyncReq {}, client .SyncJoinedTo (alice .UserID , roomID ))
108+
109+ // bob1 is invited and can join the room (hs2 is now participating of the room)
110+ alice .MustInviteRoom (t , roomID , bob .UserID )
111+ bob .MustSyncUntil (t , client.SyncReq {}, client .SyncInvitedTo (bob .UserID , roomID ))
112+ bob .MustJoinRoom (t , roomID , []string {"hs1" })
113+ // Make sure alice can see bob in the room
114+ alice .MustSyncUntil (t , client.SyncReq {}, client .SyncJoinedTo (bob .UserID , roomID ))
115+
116+ // bob2 is invited and can also join the room
117+ alice .MustInviteRoom (t , roomID , bob2 .UserID )
118+ bob2 .MustSyncUntil (t , client.SyncReq {}, client .SyncInvitedTo (bob2 .UserID , roomID ))
119+ bob2 .MustJoinRoom (t , roomID , []string {"hs1" })
120+ // Make sure alice can see bob2 in the room
121+ alice .MustSyncUntil (t , client.SyncReq {}, client .SyncJoinedTo (bob2 .UserID , roomID ))
122+ })
123+
124+ t .Run ("Remote invited user can reject invite when homeserver is already participating in the room" , func (t * testing.T ) {
125+ t .Parallel ()
126+ roomID := alice .MustCreateRoom (t , map [string ]interface {}{
127+ "preset" : "private_chat" ,
128+ })
129+ alice .MustSyncUntil (t , client.SyncReq {}, client .SyncJoinedTo (alice .UserID , roomID ))
130+
131+ // bob1 is invited and can join the room (hs2 is now participating of the room)
132+ alice .MustInviteRoom (t , roomID , bob .UserID )
133+ bob .MustSyncUntil (t , client.SyncReq {}, client .SyncInvitedTo (bob .UserID , roomID ))
134+ bob .MustJoinRoom (t , roomID , []string {"hs1" })
135+ // Make sure alice can see bob in the room
136+ alice .MustSyncUntil (t , client.SyncReq {}, client .SyncJoinedTo (bob .UserID , roomID ))
137+
138+ // bob2 is invited and can reject the invite (leave the room)
139+ alice .MustInviteRoom (t , roomID , bob2 .UserID )
140+ bob2 .MustSyncUntil (t , client.SyncReq {}, client .SyncInvitedTo (bob2 .UserID , roomID ))
141+ bob2 .MustLeaveRoom (t , roomID )
142+ // Make sure alice can see bob2 left the room
143+ alice .MustSyncUntil (t , client.SyncReq {Filter : includeLeaveSyncFilter }, client .SyncLeftFrom (bob2 .UserID , roomID ))
144+ })
145+
88146 t .Run ("Invited user has 'is_direct' flag in prev_content after joining" , func (t * testing.T ) {
89147 roomID := alice .MustCreateRoom (t , map [string ]interface {}{
90148 "preset" : "private_chat" ,
0 commit comments