aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-12-22 13:05:59 +0100
committerGitHub <noreply@github.com>2022-12-22 13:05:59 +0100
commit5eed31fea330f5f0500384c98272b9a75a44fba4 (patch)
tree8f968c15c3d49e6626ef762e5f3a6e3e4e1ab74d /test
parent09dff951d6be1fee1cc7c6872e98eb27e81fc778 (diff)
Handle guest access [1/2?] (#2872)
Needs https://github.com/matrix-org/sytest/pull/1315, as otherwise the membership events aren't persisted yet when hitting `/state` after kicking guest users. Makes the following tests pass: ``` Guest users denied access over federation if guest access prohibited Guest users are kicked from guest_access rooms on revocation of guest_access Guest users are kicked from guest_access rooms on revocation of guest_access over federation ``` Todo (in a follow up PR): - Restrict access to CS API Endpoints as per https://spec.matrix.org/v1.4/client-server-api/#client-behaviour-14 Co-authored-by: kegsay <kegan@matrix.org>
Diffstat (limited to 'test')
-rw-r--r--test/room.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/test/room.go b/test/room.go
index 4328bf84..685876cb 100644
--- a/test/room.go
+++ b/test/room.go
@@ -38,11 +38,12 @@ var (
)
type Room struct {
- ID string
- Version gomatrixserverlib.RoomVersion
- preset Preset
- visibility gomatrixserverlib.HistoryVisibility
- creator *User
+ ID string
+ Version gomatrixserverlib.RoomVersion
+ preset Preset
+ guestCanJoin bool
+ visibility gomatrixserverlib.HistoryVisibility
+ creator *User
authEvents gomatrixserverlib.AuthEvents
currentState map[string]*gomatrixserverlib.HeaderedEvent
@@ -120,6 +121,11 @@ func (r *Room) insertCreateEvents(t *testing.T) {
r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomPowerLevels, plContent, WithStateKey(""))
r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomJoinRules, joinRule, WithStateKey(""))
r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomHistoryVisibility, hisVis, WithStateKey(""))
+ if r.guestCanJoin {
+ r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomGuestAccess, map[string]string{
+ "guest_access": "can_join",
+ }, WithStateKey(""))
+ }
}
// Create an event in this room but do not insert it. Does not modify the room in any way (depth, fwd extremities, etc) so is thread-safe.
@@ -268,3 +274,9 @@ func RoomVersion(ver gomatrixserverlib.RoomVersion) roomModifier {
r.Version = ver
}
}
+
+func GuestsCanJoin(canJoin bool) roomModifier {
+ return func(t *testing.T, r *Room) {
+ r.guestCanJoin = canJoin
+ }
+}