Fix up "Test that invites can be rescinded over federation"#803
Open
erikjohnston wants to merge 2 commits intomainfrom
Open
Fix up "Test that invites can be rescinded over federation"#803erikjohnston wants to merge 2 commits intomainfrom
erikjohnston wants to merge 2 commits intomainfrom
Conversation
MadLittleMods
approved these changes
Sep 9, 2025
|
|
||
| // Check bob is still invited by doing an initial sync | ||
| bob.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(bob.UserID, roomID2)) | ||
| }) |
Collaborator
There was a problem hiding this comment.
Suggestion:
t.Run("Non-inviter user cannot rescind invite over federation", func(t *testing.T) {
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` invites bob
alice2.MustInviteRoom(t, roomID2, bob.UserID)
bob.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(bob.UserID, roomID2))
// `alice`, not the original inviter (`alice2`), kicks bob.
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
// `roomID1` (on the same homeserver as `roomID2`) and checking that once Bob
// receives that new message in `roomID1` he still hasn't seen the leave for `roomID2`.
//
// Ideally, bob could see the rescission, but currently we have no way to auth
// that over federation.
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 to `roomID2` by doing an initial sync
bob.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(bob.UserID, roomID2))
})
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follows on from #797, which I merged Too Soon
c.f. element-hq/synapse#18823