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

Test that can reject federated invites #1239

Merged
merged 3 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions tests/30rooms/06invite.pl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ sub inviteonly_room_fixture
)
}

push our @EXPORT, qw( inviteonly_room_fixture );

multi_test "Can invite users to invite-only rooms",
# TODO: deprecated endpoint used in this test
requires => do {
Expand Down
48 changes: 48 additions & 0 deletions tests/31sync/15lazy-members.pl
Original file line number Diff line number Diff line change
Expand Up @@ -807,3 +807,51 @@ sub check_filler_event {
Future->done(1);
});
};


test "Rejecting invite over federation doesn't break incremental /sync",
requires => [ remote_user_fixture(),
do {
my $creator = local_user_fixture();
$creator, inviteonly_room_fixture( creator => $creator );
}
],

check => sub {
my ( $invitee, $creator, $room_id ) = @_;

my ( $filter_id );

matrix_create_filter( $invitee, {
room => {
state => {
lazy_load_members => JSON::true,
Copy link
Member

Choose a reason for hiding this comment

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

Does this really require lazy loading? I'm not really sure I'm following that bit.

Copy link
Member Author

Choose a reason for hiding this comment

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

During lazy loading we pull out state a second time to get the membership event of the sender of the outlier event, so we stick lazy loading on to hit more of the /sync code paths

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! 👍

include_redundant_members => JSON::true,
},
timeline => {
limit => 10
},
}
})->then( sub {
( $filter_id ) = @_;

matrix_sync( $invitee, filter => $filter_id )
})->then( sub {
matrix_invite_user_to_room_synced( $creator, $invitee, $room_id )
})->then( sub {
matrix_leave_room_synced( $invitee, $room_id )
})->then( sub {
matrix_sync_again( $invitee, filter => $filter_id )
})->then( sub {
my ( $body ) = @_;

# Check that invitee no longer sees the invite

if( exists $body->{rooms} and exists $body->{rooms}{invite} ) {
assert_json_object( $body->{rooms}{invite} );
keys %{ $body->{rooms}{invite} } and die "Expected empty dictionary";
}

Future->done( 1 );
});
};