From 33607b6c85b4ae275248330ffc6d9876261448e8 Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Thu, 31 Jan 2019 11:43:50 +0000 Subject: [PATCH] Add test for PDU limit on transactions API (#555) * Add test for PDU limit on transactions API * Fixes and additional check for under-limit transactions * Remove --- tests/50federation/51transactions.pl | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/50federation/51transactions.pl diff --git a/tests/50federation/51transactions.pl b/tests/50federation/51transactions.pl new file mode 100644 index 000000000..637da1387 --- /dev/null +++ b/tests/50federation/51transactions.pl @@ -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 ); + }), + ); + }); + };