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

Add test for PDU limit on transactions API #555

Merged
merged 3 commits into from
Jan 31, 2019
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
53 changes: 53 additions & 0 deletions tests/50federation/51transactions.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
test "Server correctly handles transactions that break edu limits",
requires => [ $main::OUTBOUND_CLIENT, $main::INBOUND_SERVER, $main::HOMESERVER_INFO[0],
local_user_and_room_fixtures(), room_alias_name_fixture() ],

do => sub {
my ( $outbound_client, $inbound_server, $info, $creator, $room_id, $room_alias_name ) = @_;

my $local_server_name = $info->server_name;

my $remote_server_name = $inbound_server->server_name;

my $room_alias = "#$room_alias_name:$remote_server_name";

$outbound_client->join_room(
server_name => $local_server_name,
room_id => $room_id,
user_id => $creator->user_id,
)->then( sub {
my ( $room ) = @_;

my $new_event = $room->create_and_insert_event(
type => "m.room.message",

sender => $creator->user_id,
content => {
body => "Message 1",
},
);

# Generate two transactions, one that breaks the 50 PDU limit and one
# that does not
my @bad_pdus = ( $new_event ) x 51;
my @good_pdus = ( $new_event ) x 10;

Future->needs_all(
# Send the transaction to the client and expect a fail
$outbound_client->send_transaction(
pdus => \@bad_pdus,
destination => $local_server_name,
)->main::expect_http_400(),

# Send the transaction to the client and expect a succeed
$outbound_client->send_transaction(
pdus => \@good_pdus,
destination => $local_server_name,
)->then( sub {
my ( $response ) = @_;

Future->done( 1 );
}),
);
});
richvdh marked this conversation as resolved.
Show resolved Hide resolved
};