Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 43 additions & 10 deletions tests/msc2946_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func eventKey(srcRoomID, dstRoomID, evType string) string {
// _____|________
// | | |
// R1 SS1 R2
// |
// SS2
// | |
// SS2 R5
// |________
// | |
// R3 R4
Expand All @@ -41,7 +41,6 @@ func eventKey(srcRoomID, dstRoomID, evType string) string {
// - the user is joined to all rooms except R4.
// - R2 <---> Root is a two-way link.
// - The remaining links are just children links.
// - SS1 is marked as a "space", but SS2 is not.
//
// Tests that:
// - Querying the root returns the entire graph
Expand All @@ -61,6 +60,9 @@ func TestClientSpacesSummary(t *testing.T) {
root := alice.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "Root",
"creation_content": map[string]interface{}{
"type": "m.space",
},
})
roomNames[root] = "Root"
r1 := alice.CreateRoom(t, map[string]interface{}{
Expand All @@ -85,6 +87,9 @@ func TestClientSpacesSummary(t *testing.T) {
ss2 := alice.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "SS2",
"creation_content": map[string]interface{}{
"type": "m.space",
},
})
roomNames[ss2] = "SS2"
r3 := alice.CreateRoom(t, map[string]interface{}{
Expand All @@ -108,6 +113,10 @@ func TestClientSpacesSummary(t *testing.T) {
},
})
roomNames[r4] = "R4"
r5 := bob.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "R5",
})

// create the links
rootToR1 := eventKey(root, r1, spaceChildEventType)
Expand All @@ -134,6 +143,14 @@ func TestClientSpacesSummary(t *testing.T) {
"via": []string{"hs1"},
},
})
// Note that this link gets ignored since R2 is not a space.
alice.SendEventSynced(t, r2, b.Event{
Type: spaceChildEventType,
StateKey: &r5,
Content: map[string]interface{}{
"via": []string{"hs1"},
},
})
alice.SendEventSynced(t, r2, b.Event{ // parent link
Type: spaceParentEventType,
StateKey: &root,
Expand Down Expand Up @@ -283,6 +300,9 @@ func TestClientSpacesSummaryJoinRules(t *testing.T) {
root := alice.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "Root",
"creation_content": map[string]interface{}{
"type": "m.space",
},
})
r1 := alice.CreateRoom(t, map[string]interface{}{
"preset": "private_chat",
Expand Down Expand Up @@ -359,9 +379,7 @@ func TestClientSpacesSummaryJoinRules(t *testing.T) {
}, func(r gjson.Result) interface{} {
return r.Get("room_id").Str
}, nil),
match.JSONCheckOff("events", []interface{}{
rootToR1, rootToSS1,
}, func(r gjson.Result) interface{} {
match.JSONCheckOff("events", []interface{}{}, func(r gjson.Result) interface{} {
return eventKey(r.Get("room_id").Str, r.Get("state_key").Str, r.Get("type").Str)
}, nil),
},
Expand All @@ -380,7 +398,7 @@ func TestClientSpacesSummaryJoinRules(t *testing.T) {
return r.Get("room_id").Str
}, nil),
match.JSONCheckOff("events", []interface{}{
rootToR1, rootToSS1,
rootToR1,
}, func(r gjson.Result) interface{} {
return eventKey(r.Get("room_id").Str, r.Get("state_key").Str, r.Get("type").Str)
}, nil),
Expand Down Expand Up @@ -438,15 +456,30 @@ func TestFederatedClientSpaces(t *testing.T) {
},
},
}
worldReadableSpace := map[string]interface{}{
"preset": "public_chat",
"creation_content": map[string]interface{}{
"type": "m.space",
},
"initial_state": []map[string]interface{}{
{
"type": "m.room.history_visibility",
"state_key": "",
"content": map[string]string{
"history_visibility": "world_readable",
},
},
},
}
// create the rooms
alice := deployment.Client(t, "hs1", "@alice:hs1")
root := alice.CreateRoom(t, worldReadable)
root := alice.CreateRoom(t, worldReadableSpace)
r1 := alice.CreateRoom(t, worldReadable)
ss1 := alice.CreateRoom(t, worldReadable)
ss1 := alice.CreateRoom(t, worldReadableSpace)
r4 := alice.CreateRoom(t, worldReadable)
bob := deployment.Client(t, "hs2", "@bob:hs2")
r2 := bob.CreateRoom(t, worldReadable)
ss2 := bob.CreateRoom(t, worldReadable)
ss2 := bob.CreateRoom(t, worldReadableSpace)
r3 := bob.CreateRoom(t, worldReadable)

// create the links
Expand Down
9 changes: 9 additions & 0 deletions tests/msc3083_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ func setupRestrictedRoom(t *testing.T, deployment *docker.Deployment) (*client.C
space := alice.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "Space",
"creation_content": map[string]interface{}{
"type": "m.space",
},
})
// The room is an unstable room version which supports the restricted join_rule.
room := alice.CreateRoom(t, map[string]interface{}{
Expand Down Expand Up @@ -195,6 +198,9 @@ func TestRestrictedRoomsSpacesSummary(t *testing.T) {
space := alice.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "Space",
"creation_content": map[string]interface{}{
"type": "m.space",
},
// World readable to allow peeking without joining.
"initial_state": []map[string]interface{}{
{
Expand Down Expand Up @@ -272,6 +278,9 @@ func TestRestrictedRoomsSpacesSummaryFederation(t *testing.T) {
space := alice.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "Space",
"creation_content": map[string]interface{}{
"type": "m.space",
},
"initial_state": []map[string]interface{}{
{
"type": "m.room.history_visibility",
Expand Down