-
Notifications
You must be signed in to change notification settings - Fork 62
Add TestRestrictedRoomsLocalJoinNoCreatorsUsesPowerLevels
#836
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: timedout <git@nexy7574.co.uk>
| doTestRestrictedRoomsLocalJoinNoCreatorsUsesPowerLevels(t, "12", "restricted") | ||
| } | ||
|
|
||
| func doTestRestrictedRoomsLocalJoinNoCreatorsUsesPowerLevels(t *testing.T, roomVersion string, joinRule string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the reason other tests are written this way is so that it can be shared with tests/knock_restricted_test.go. I'm guessing we should also have knock_restricted test there.
| // | ||
| // ref: https://github.com/element-hq/synapse/issues/19120 | ||
| func TestRestrictedRoomsLocalJoinNoCreatorsUsesPowerLevels(t *testing.T) { | ||
| doTestRestrictedRoomsLocalJoinNoCreatorsUsesPowerLevels(t, "12", "restricted") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also test with a room version before 12
| // A server will attempt to perform a local join to a room with creators (v12), | ||
| // using a creator as the authorising user, but falling back to power levels if | ||
| // an appropriate creator cannot be found. | ||
| // | ||
| // ref: https://github.com/element-hq/synapse/issues/19120 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is explaining too many specifics of the Synapse implementation. Unless this is explained somewhere in the spec?
Here is an iteration:
| // A server will attempt to perform a local join to a room with creators (v12), | |
| // using a creator as the authorising user, but falling back to power levels if | |
| // an appropriate creator cannot be found. | |
| // | |
| // ref: https://github.com/element-hq/synapse/issues/19120 | |
| // A homeserver should be able to do a local join (when someone else from the same | |
| // homeserver is already joined to the room) to a room using any local user who has | |
| // invite power levels. | |
| // | |
| // In the test case, there are no local room creators on hs2, so hs2 will need to use | |
| // one of the local people listed in the power levels who can invite. While hs2, could | |
| // do another remote join to get charlie in the room, we assert it was a local join by | |
| // checking the `join_authorised_via_users_server` (homeservers should prefer a local | |
| // join). | |
| // | |
| // This is a regression test for Synapse as it previously only looked for local room | |
| // creators in v12 rooms, https://github.com/element-hq/synapse/issues/19120 |
| // Ensure the join was authorised by bob. The join should not be | ||
| // authorised by alice as hs2 should not have attempted a remote | ||
| // join given bob is a local user that can authorise the join. | ||
| bob.MustSyncUntil(t, client.SyncReq{}, client.SyncJoinedTo(charlie.UserID, room, func(ev gjson.Result) bool { | ||
| must.MatchGJSON(t, ev, | ||
| match.JSONKeyEqual("content.join_authorised_via_users_server", bob.UserID), | ||
| ) | ||
| return true | ||
| })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great comment/assertion 👍
| // Charlie attempts to join the restricted room. | ||
| // hs2 should attempt to find a creator to authorise the room join, | ||
| // but can't as the only creator is remote. It should then fall back | ||
| // to checking the power levels for a user that can authorise the join. | ||
| // The end result should be that charlie is allowed to join. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably needs a slight adjustment like the main test description comment above.
| // an appropriate creator cannot be found. | ||
| // | ||
| // ref: https://github.com/element-hq/synapse/issues/19120 | ||
| func TestRestrictedRoomsLocalJoinNoCreatorsUsesPowerLevels(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to write a test! It looks great overall 🤩
| // an appropriate creator cannot be found. | ||
| // | ||
| // ref: https://github.com/element-hq/synapse/issues/19120 | ||
| func TestRestrictedRoomsLocalJoinNoCreatorsUsesPowerLevels(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested to make sure it fails with the latest develop with Synapse and passes with element-hq/synapse#19321 ✅
Adds a test to prevent regressions fixed by element-hq/synapse#19321.
Reproduce element-hq/synapse#19120
Pull Request Checklist