1
+ // These tests currently fail on Dendrite, due to Dendrite bugs.
2
+ //go:build !dendrite_blacklist
3
+ // +build !dendrite_blacklist
4
+
1
5
package tests
2
6
3
7
import (
8
+ "encoding/json"
4
9
"testing"
5
10
6
11
"github.com/matrix-org/complement"
@@ -17,8 +22,17 @@ func TestFederationRoomsInvite(t *testing.T) {
17
22
deployment := complement .Deploy (t , 2 )
18
23
defer deployment .Destroy (t )
19
24
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 )
22
36
23
37
t .Run ("Parallel" , func (t * testing.T ) {
24
38
// sytest: Invited user can reject invite over federation
@@ -30,7 +44,7 @@ func TestFederationRoomsInvite(t *testing.T) {
30
44
})
31
45
bob .MustSyncUntil (t , client.SyncReq {}, client .SyncInvitedTo (bob .UserID , roomID ))
32
46
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 ))
34
48
})
35
49
36
50
// sytest: Invited user can reject invite over federation several times
@@ -43,7 +57,7 @@ func TestFederationRoomsInvite(t *testing.T) {
43
57
alice .MustInviteRoom (t , roomID , bob .UserID )
44
58
bob .MustSyncUntil (t , client.SyncReq {}, client .SyncInvitedTo (bob .UserID , roomID ))
45
59
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 ))
47
61
}
48
62
})
49
63
@@ -57,9 +71,9 @@ func TestFederationRoomsInvite(t *testing.T) {
57
71
aliceSince := alice .MustSyncUntil (t , client.SyncReq {}, client .SyncJoinedTo (alice .UserID , roomID ))
58
72
bobSince := bob .MustSyncUntil (t , client.SyncReq {}, client .SyncInvitedTo (bob .UserID , roomID ))
59
73
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 ))
61
75
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 ))
63
77
})
64
78
65
79
// sytest: Remote invited user can see room metadata
@@ -85,6 +99,50 @@ func TestFederationRoomsInvite(t *testing.T) {
85
99
verifyState (t , res , wantFields , wantValues , roomID , alice )
86
100
})
87
101
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
+
88
146
t .Run ("Invited user has 'is_direct' flag in prev_content after joining" , func (t * testing.T ) {
89
147
roomID := alice .MustCreateRoom (t , map [string ]interface {}{
90
148
"preset" : "private_chat" ,
0 commit comments