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 remote invites are correctly pushed #1356

Merged
merged 2 commits into from
Jul 12, 2023
Merged
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
100 changes: 100 additions & 0 deletions tests/61push/01message-pushed.pl
Original file line number Diff line number Diff line change
Expand Up @@ -630,3 +630,103 @@ sub check_received_push_with_name
);
});
};

test "Invites over federation are correctly pushed",
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we making more Sytest tests because there isn't a good way to test push gateway stuff in Complement?

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
test "Invites over federation are correctly pushed",
test "Invites over federation are correctly pushed (without room_name)",

requires => [
local_user_fixtures( 2, with_events => 0 ),
remote_user_fixture(),
$main::TEST_SERVER_INFO
],

check => sub {
my ( $alice, $bob, $charlie, $test_server_info ) = @_;
my $room_id;

setup_push( $alice, $bob, $test_server_info )
->then( sub {
matrix_create_room_synced( $charlie );
})->then( sub {
( $room_id ) = @_;

Future->needs_all(
await_http_request( $PUSH_LOCATION, sub {
my ( $request ) = @_;
my $body = $request->body_from_json;

# Respond to all requests, even if we filiter them out
$request->respond_json( {} );

return unless $body->{notification}{type};
return unless $body->{notification}{type} eq "m.room.member";
return 1;
}),
matrix_invite_user_to_room( $charlie, $alice, $room_id )
)
})->then( sub {
my ( $request ) = @_;
my $body = $request->body_from_json;

log_if_fail "Message push request body", $body;

assert_json_keys( my $notification = $body->{notification}, qw(
id room_id type sender content devices counts
));

assert_eq( $notification->{room_id}, $room_id, "room_id");
assert_eq( $notification->{sender}, $charlie->user_id, "sender");

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


test "Invites over federation are correctly pushed with name",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
test "Invites over federation are correctly pushed with name",
test "Invites over federation are correctly pushed (with room_name)",

requires => [
local_user_fixtures( 2, with_events => 0 ),
remote_user_fixture(),
$main::TEST_SERVER_INFO
],

check => sub {
my ( $alice, $bob, $charlie, $test_server_info ) = @_;
my $room_id;

my $name = "Test Name";

setup_push( $alice, $bob, $test_server_info )
->then( sub {
matrix_create_room_synced( $charlie, name => $name );
})->then( sub {
( $room_id ) = @_;

Future->needs_all(
await_http_request( $PUSH_LOCATION, sub {
my ( $request ) = @_;
my $body = $request->body_from_json;

# Respond to all requests, even if we filiter them out
$request->respond_json( {} );

return unless $body->{notification}{type};
return unless $body->{notification}{type} eq "m.room.member";
return 1;
}),
matrix_invite_user_to_room( $charlie, $alice, $room_id )
)
})->then( sub {
my ( $request ) = @_;
my $body = $request->body_from_json;

log_if_fail "Message push request body", $body;

assert_json_keys( my $notification = $body->{notification}, qw(
id room_id type sender content devices counts
));

assert_eq( $notification->{room_id}, $room_id, "room_id");
assert_eq( $notification->{sender}, $charlie->user_id, "sender");
assert_eq( $notification->{room_name}, $name, "room_name");

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