-
Notifications
You must be signed in to change notification settings - Fork 54
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
Make restricted room join tests clearer #752
Open
morguldir
wants to merge
3
commits into
matrix-org:main
Choose a base branch
from
morguldir:more-mustard
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ func checkRestrictedRoom(t *testing.T, alice *client.CSAPI, bob *client.CSAPI, a | |
|
||
t.Run("Join should succeed when joined to allowed room", func(t *testing.T) { | ||
// Join the allowed room. | ||
bob.JoinRoom(t, allowed_room, []string{"hs1"}) | ||
bob.MustJoinRoom(t, allowed_room, []string{"hs1"}) | ||
|
||
// Confirm that we joined the allowed room by changing displayname and | ||
// waiting for confirmation in the /sync response. (This is an attempt | ||
|
@@ -86,7 +86,7 @@ func checkRestrictedRoom(t *testing.T, alice *client.CSAPI, bob *client.CSAPI, a | |
) | ||
|
||
// We should now be able to join the restricted room. | ||
bob.JoinRoom(t, room, []string{"hs1"}) | ||
bob.MustJoinRoom(t, room, []string{"hs1"}) | ||
|
||
// Joining the same room again should work fine (e.g. to change your display name). | ||
bob.SendEventSynced( | ||
|
@@ -99,8 +99,8 @@ func checkRestrictedRoom(t *testing.T, alice *client.CSAPI, bob *client.CSAPI, a | |
Content: map[string]interface{}{ | ||
"membership": "join", | ||
"displayname": "Bobby", | ||
// This should be ignored since this is a join -> join transition. | ||
"join_authorised_via_users_server": "unused", | ||
// This should be ignored by the server since this is a join -> join transition | ||
"join_authorised_via_users_server": "@unused:unused.local", | ||
}, | ||
}, | ||
) | ||
|
@@ -114,6 +114,15 @@ func checkRestrictedRoom(t *testing.T, alice *client.CSAPI, bob *client.CSAPI, a | |
// Wait until Alice sees Bob leave the allowed room. This ensures that Alice's HS | ||
// has processed the leave before Bob tries rejoining, so that it rejects his | ||
// attempt to join the room. | ||
alice.MustSyncUntil(t, client.SyncReq{}, client.SyncTimelineHas( | ||
room, func(ev gjson.Result) bool { | ||
if ev.Get("type").Str != "m.room.member" || ev.Get("sender").Str != bob.UserID { | ||
return false | ||
} | ||
|
||
return ev.Get("content").Get("membership").Str == "leave" | ||
})) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a duplicate of the stuff underneath? Why add this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It makes sure the leave worked in both rooms now |
||
alice.MustSyncUntil(t, client.SyncReq{}, client.SyncTimelineHas( | ||
allowed_room, func(ev gjson.Result) bool { | ||
if ev.Get("type").Str != "m.room.member" || ev.Get("sender").Str != bob.UserID { | ||
|
@@ -130,11 +139,11 @@ func checkRestrictedRoom(t *testing.T, alice *client.CSAPI, bob *client.CSAPI, a | |
t.Run("Join should succeed when invited", func(t *testing.T) { | ||
// Invite the user and joining should work. | ||
alice.MustInviteRoom(t, room, bob.UserID) | ||
bob.JoinRoom(t, room, []string{"hs1"}) | ||
bob.MustJoinRoom(t, room, []string{"hs1"}) | ||
|
||
// Leave the room again, and join the allowed room. | ||
bob.MustLeaveRoom(t, room) | ||
bob.JoinRoom(t, allowed_room, []string{"hs1"}) | ||
bob.MustJoinRoom(t, allowed_room, []string{"hs1"}) | ||
}) | ||
|
||
t.Run("Join should fail with mangled join rules", func(t *testing.T) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What happens if a ruma-based server gets garbage here then? Does it still work?
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 can create the event then, but it won’t really work properly unless the server removes the field when handling the PUT like synapse does
So when verifying the signature of a federation event actually looking like that it won’t work still
This part i think is intended though, although seemingly synapse changed that behaviour at some point too 🧐
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'm not really following your comment, sorry. Shouldn't the field be removed no matter what? So what isn't working for ruma?
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.
Sorry yeah it should, but if another server forgets to remove it, then ruma still tries to check the signature, but synapse seems to still allow the event