-
Notifications
You must be signed in to change notification settings - Fork 60
Test that invites can be rescinded over federation #797
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
Open
erikjohnston
wants to merge
4
commits into
main
Choose a base branch
from
erikj/revoke_invite_fed
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
4 commits
Select commit
Hold shift + click to select a range
9e9c545
Test that invites can be rescinded over federation
erikjohnston 70625fc
Update tests/federation_rooms_invite_test.go
erikjohnston 54bf25c
Update tests/federation_rooms_invite_test.go
erikjohnston b9416f2
Check that non-invitee cannot rescind invite over federation
erikjohnston 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 hidden or 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 | ||||
---|---|---|---|---|---|---|
|
@@ -12,6 +12,7 @@ import ( | |||||
"github.com/matrix-org/gomatrixserverlib/spec" | ||||||
"github.com/tidwall/gjson" | ||||||
|
||||||
"github.com/matrix-org/complement/b" | ||||||
"github.com/matrix-org/complement/client" | ||||||
"github.com/matrix-org/complement/helpers" | ||||||
"github.com/matrix-org/complement/match" | ||||||
|
@@ -23,6 +24,7 @@ func TestFederationRoomsInvite(t *testing.T) { | |||||
defer deployment.Destroy(t) | ||||||
|
||||||
alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{LocalpartSuffix: "alice"}) | ||||||
alice2 := deployment.Register(t, "hs1", helpers.RegistrationOpts{LocalpartSuffix: "alice2"}) | ||||||
bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{LocalpartSuffix: "bob"}) | ||||||
bob2 := deployment.Register(t, "hs2", helpers.RegistrationOpts{LocalpartSuffix: "bob2"}) | ||||||
|
||||||
|
@@ -149,6 +151,73 @@ func TestFederationRoomsInvite(t *testing.T) { | |||||
alice.MustSyncUntil(t, client.SyncReq{Filter: includeLeaveSyncFilter}, client.SyncLeftFrom(bob2.UserID, roomID)) | ||||||
}) | ||||||
|
||||||
t.Run("Inviter user can rescind invite over federation", func(t *testing.T) { | ||||||
t.Parallel() | ||||||
roomID := alice.MustCreateRoom(t, map[string]interface{}{ | ||||||
"preset": "private_chat", | ||||||
"invite": []string{bob.UserID}, | ||||||
}) | ||||||
bob.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(bob.UserID, roomID)) | ||||||
alice.MustDo(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "kick"}, | ||||||
client.WithJSONBody(t, map[string]interface{}{ | ||||||
"user_id": bob.UserID, | ||||||
"reason": "testing", | ||||||
}), | ||||||
) | ||||||
|
||||||
bob.MustSyncUntil(t, client.SyncReq{Filter: includeLeaveSyncFilter}, client.SyncLeftFrom(bob.UserID, roomID)) | ||||||
}) | ||||||
|
||||||
t.Run("Non-invitee user cannot rescind invite over federation", func(t *testing.T) { | ||||||
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.
Suggested change
|
||||||
t.Parallel() | ||||||
|
||||||
// First create a room that Bob is in. This is so that later we can | ||||||
// send a message to test that Bob doesn't see the rescission. | ||||||
roomID1 := alice.MustCreateRoom(t, map[string]interface{}{ | ||||||
"preset": "private_chat", | ||||||
"invite": []string{bob.UserID}, | ||||||
}) | ||||||
since := bob.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(bob.UserID, roomID1)) | ||||||
bob.MustJoinRoom(t, roomID1, []spec.ServerName{}) | ||||||
|
||||||
// Second room which Alice and Alice2 join, Alice2 invites Bob and | ||||||
// then Alice kicks him. | ||||||
roomID2 := alice.MustCreateRoom(t, map[string]interface{}{ | ||||||
"preset": "private_chat", | ||||||
"invite": []string{alice2.UserID}, | ||||||
}) | ||||||
alice2.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(alice2.UserID, roomID2)) | ||||||
alice2.MustJoinRoom(t, roomID2, []spec.ServerName{}) | ||||||
|
||||||
alice2.MustInviteRoom(t, roomID2, bob.UserID) | ||||||
bob.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(bob.UserID, roomID2)) | ||||||
|
||||||
// Alice, not the original inviter, kicks bob. This does not result | ||||||
// in bob seeing the rescission. | ||||||
Comment on lines
+195
to
+196
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. We should comment that it would be fine for bob to see the rescission but they have no way to auth it because of X so they can't take it into account |
||||||
alice.MustDo(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID2, "kick"}, | ||||||
client.WithJSONBody(t, map[string]interface{}{ | ||||||
"user_id": bob.UserID, | ||||||
"reason": "testing", | ||||||
}), | ||||||
) | ||||||
|
||||||
// Check bob *doesn't* see the rescission. We do this by sending a | ||||||
// message in room1 and checking that once Bob receives that message | ||||||
// he still hasn't seen the leave. | ||||||
eventID := alice.SendEventSynced(t, roomID1, b.Event{ | ||||||
Type: "m.room.message", | ||||||
Content: map[string]interface{}{ | ||||||
"body": "1", | ||||||
"msgtype": "m.text", | ||||||
}, | ||||||
Sender: alice.UserID, | ||||||
}) | ||||||
bob.MustSyncUntil(t, client.SyncReq{Since: since}, client.SyncTimelineHasEventID(roomID1, eventID)) | ||||||
|
||||||
// Check bob is still invited by doing an initial sync | ||||||
bob.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(bob.UserID, roomID2)) | ||||||
}) | ||||||
|
||||||
t.Run("Invited user has 'is_direct' flag in prev_content after joining", func(t *testing.T) { | ||||||
roomID := alice.MustCreateRoom(t, map[string]interface{}{ | ||||||
"preset": "private_chat", | ||||||
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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 would be good to have a test where someone else rescinds the invite (someone different than the inviter)
Also a test for someone else from another server in the room
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.
Test was added for the first case but not the second for someone else from another server in the room