Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestRoomState: use non-default power levels to test powerlevels event retrieval #600

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
42 changes: 34 additions & 8 deletions tests/csapi/apidoc_room_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,45 @@ func TestRoomState(t *testing.T) {
"visibility": "public",
"preset": "public_chat",
"room_alias_name": "room_alias",

// Add power level overrides so that it doesn't create the
// default power levels and forces the fields to exist.
"power_level_content_override": map[string]interface{}{
"ban": 51,
"events": map[string]interface{}{
"m.room.name": 59,
},
"events_default": 1,
"invite": 2,
"kick": 52,
"notifications": map[string]interface{}{
"room": 53,
},
"redact": 54,
"state_default": 55,
// An empty users map should get merged with the default
// events map which will include the creator as an admin.
"users": map[string]interface{}{},
Comment on lines +83 to +85
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synapse is not doing any merging and failing the test as a result. If I remember rightly, the spec is a little unclear about whether merging should happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I mentioned that here: matrix-org/matrix-spec#492 (comment)

Synapse only merges one level deep.

"users_default": 3,
},
})
res := authedClient.MustDoFunc(t, "GET", []string{"_matrix", "client", "v3", "rooms", roomID, "state", "m.room.power_levels"})

must.MatchResponse(t, res, match.HTTPResponse{
JSON: []match.JSON{
match.JSONKeyPresent("ban"),
match.JSONKeyPresent("kick"),
match.JSONKeyPresent("redact"),
match.JSONKeyPresent("users_default"),
match.JSONKeyPresent("state_default"),
match.JSONKeyPresent("events_default"),
match.JSONKeyPresent("users"),
match.JSONKeyPresent("events"),
match.JSONKeyEqual("ban", 51),
match.JSONKeyEqual("events.m\\.room\\.name", 59),
match.JSONKeyEqual("events.m\\.room\\.power_levels", 100),
match.JSONKeyEqual("events_default", 1),
match.JSONKeyEqual("invite", 2),
match.JSONKeyEqual("kick", 52),
match.JSONKeyEqual("notifications.room", 53),
match.JSONKeyEqual("redact", 54),
match.JSONKeyEqual("state_default", 55),

// Verify that Alice got added as an admin.
match.JSONKeyEqual("users.@alice:hs1", 100),
match.JSONKeyEqual("users_default", 3),
},
})
})
Expand Down