diff --git a/lib/SyTest/Federation/Client.pm b/lib/SyTest/Federation/Client.pm index e71c5a354..6f670ced8 100644 --- a/lib/SyTest/Federation/Client.pm +++ b/lib/SyTest/Federation/Client.pm @@ -12,6 +12,8 @@ use HTTP::Headers::Util qw( join_header_words ); use SyTest::Assertions qw( :all ); +use URI::Escape qw( uri_escape ); + sub configure { my $self = shift; @@ -30,10 +32,12 @@ sub _fetch_key my $self = shift; my ( $server_name, $key_id ) = @_; + my $key_id_encoded = uri_escape($key_id); + $self->do_request_json( method => "GET", hostname => $server_name, - full_uri => "/_matrix/key/v2/server/$key_id", + full_uri => "/_matrix/key/v2/server/$key_id_encoded", )->then( sub { my ( $body ) = @_; diff --git a/lib/SyTest/Homeserver/Synapse.pm b/lib/SyTest/Homeserver/Synapse.pm index 273bd0a9e..d53c7c150 100644 --- a/lib/SyTest/Homeserver/Synapse.pm +++ b/lib/SyTest/Homeserver/Synapse.pm @@ -20,7 +20,7 @@ use POSIX qw( strftime WIFEXITED WEXITSTATUS ); use YAML (); -use SyTest::SSL qw( ensure_ssl_cert ); +use SyTest::SSL qw( ensure_ssl_key create_ssl_cert ); sub _init { @@ -150,7 +150,8 @@ sub start $self->{paths}{cert_file} = "$hs_dir/tls.crt"; $self->{paths}{key_file} = "$hs_dir/tls.key"; - ensure_ssl_cert( $self->{paths}{cert_file}, $self->{paths}{key_file}, $bind_host ); + ensure_ssl_key( $self->{paths}{key_file} ); + create_ssl_cert( $self->{paths}{cert_file}, $self->{paths}{key_file}, $bind_host ); my $config_path = $self->{paths}{config} = $self->write_yaml_file( "config.yaml" => { server_name => $self->server_name, @@ -195,6 +196,13 @@ sub start burst_count => 1000, } }, + + rc_federation => { + # allow 100 requests per sec instead of 10 + sleep_limit => 100, + window_size => 1000, + }, + enable_registration => "true", database => \%synapse_db_config, macaroon_secret_key => $macaroon_secret_key, diff --git a/lib/SyTest/Identity/Server.pm b/lib/SyTest/Identity/Server.pm index 4fe8a9687..2300689d7 100644 --- a/lib/SyTest/Identity/Server.pm +++ b/lib/SyTest/Identity/Server.pm @@ -92,7 +92,7 @@ sub on_request $req->respond_json( \%resp ); } elsif( $path eq "/_matrix/identity/api/v1/store-invite" ) { - my $body = $req->body_from_form; + my $body = $req->body_from_json; my $medium = $body->{medium}; my $address = $body->{address}; my $sender = $body->{sender}; diff --git a/lib/SyTest/SSL.pm b/lib/SyTest/SSL.pm index da4339086..1d67a7152 100644 --- a/lib/SyTest/SSL.pm +++ b/lib/SyTest/SSL.pm @@ -17,42 +17,53 @@ package SyTest::SSL; use Exporter 'import'; our @EXPORT_OK = qw( - ensure_ssl_cert + ensure_ssl_key + create_ssl_cert ); -=head2 ensure_ssl_cert +=head2 ensure_ssl_key - ensure_ssl_cert( $cert_file, $key_file, $server_name ); + ensure_ssl_key( $key_file ); -Ensure that an SSL certificate file and key file exist. If they do not, -generate a key and/or certificate. The certificate will be signed by the test CA. +Create an SSL key file, if it doesn't exist. =cut -sub ensure_ssl_cert +sub ensure_ssl_key { - my ( $cert_file, $key_file, $server_name ) = @_; + my ( $key_file ) = @_; if ( ! -e $key_file ) { # todo: we can do this in pure perl system("openssl", "genrsa", "-out", $key_file, "2048") == 0 or die "openssl genrsa failed $?"; } +} - if ( ! -e $cert_file ) { - # generate a CSR - my $csr_file = "$cert_file.csr"; - system( - "openssl", "req", "-new", "-key", $key_file, "-out", $csr_file, - "-subj", "/CN=$server_name", - ) == 0 or die "openssl req failed $?"; - - # sign it with the CA - system( - "openssl", "x509", "-req", "-in", $csr_file, - "-CA", "keys/ca.crt", "-CAkey", "keys/ca.key", "-set_serial", 1, - "-out", $cert_file, - ) == 0 or die "openssl x509 failed $?"; - } +=head2 create_ssl_cert + + create_ssl_cert( $cert_file, $key_file, $server_name ); + +Create a new SSL certificate file. The certificate will be signed by the test CA. + +=cut + +sub create_ssl_cert +{ + my ( $cert_file, $key_file, $server_name ) = @_; + + # generate a CSR + my $csr_file = "$cert_file.csr"; + system( + "openssl", "req", "-new", "-key", $key_file, "-out", $csr_file, + "-subj", "/CN=$server_name", + ) == 0 or die "openssl req failed $?"; + + # sign it with the CA + system( + "openssl", "x509", "-req", "-in", $csr_file, + "-CA", "keys/ca.crt", "-CAkey", "keys/ca.key", "-set_serial", 1, + "-out", $cert_file, + ) == 0 or die "openssl x509 failed $?"; } diff --git a/run-tests.pl b/run-tests.pl index ec15c4801..ee1ccf1f2 100755 --- a/run-tests.pl +++ b/run-tests.pl @@ -55,8 +55,6 @@ # and the like. our $TEST_RUN_ID = strftime( '%Y%m%d_%H%M%S', gmtime() ); -my %FIXED_BUGS; - my $STOP_ON_FAIL; my $SERVER_IMPL = undef; @@ -107,8 +105,6 @@ 'p|port-range=s' => \(my $PORT_RANGE = "8800:8899"), - 'F|fixed=s' => sub { $FIXED_BUGS{$_}++ for split m/,/, $_[1] }, - 'h|help' => sub { usage(0) }, ) or usage(1); @@ -175,9 +171,6 @@ sub usage -p, --port-range START:MAX - pool of TCP ports to allocate from - -F, --fixed BUGS - bug names that are expected to be fixed - (ignores 'bug' declarations with these names) - . write STDERR; @@ -583,10 +576,6 @@ sub _push_test { my ( $filename, $multi, $name, %params ) = @_; - # We expect this test to fail if it's declared to be dependent on a bug that - # is not yet fixed - $params{expect_fail}++ if $params{bug} and not $FIXED_BUGS{ $params{bug} }; - if( %only_files and not exists $only_files{$filename} ) { $proven{$_} = PRESUMED for @{ $params{proves} // [] }; return; diff --git a/tests/01http-server.pl b/tests/01http-server.pl index d5fb80648..8edd4d490 100644 --- a/tests/01http-server.pl +++ b/tests/01http-server.pl @@ -6,7 +6,7 @@ use SyTest::HTTPClient; use SyTest::HTTPServer::Request; -use SyTest::SSL qw( ensure_ssl_cert ); +use SyTest::SSL qw( ensure_ssl_key create_ssl_cert ); my $DIR = dirname( __FILE__ ); @@ -35,7 +35,8 @@ sub start_test_server_ssl { my $ssl_cert = "$test_server_dir/server.crt"; my $ssl_key = "$test_server_dir/server.key"; - ensure_ssl_cert( $ssl_cert, $ssl_key, $BIND_HOST ); + ensure_ssl_key( $ssl_key ); + create_ssl_cert( $ssl_cert, $ssl_key, $BIND_HOST ); return $server->listen( host => $BIND_HOST, diff --git a/tests/10apidoc/01register.pl b/tests/10apidoc/01register.pl index 6e53e5f60..f98b7b83f 100644 --- a/tests/10apidoc/01register.pl +++ b/tests/10apidoc/01register.pl @@ -220,7 +220,7 @@ sub matrix_register_user return $f->then_done( $user ) ->on_done( sub { - log_if_fail "Registered new user $uid"; + log_if_fail "Registered new user ". $user->user_id; }); }); } @@ -277,7 +277,7 @@ sub matrix_admin_register_user_via_secret return Future->done( $user ) ->on_done( sub { - log_if_fail "Registered new user (via secret) $uid"; + log_if_fail "Registered new user (via secret) " . $user->user_id; }); }); } diff --git a/tests/30rooms/04messages.pl b/tests/30rooms/04messages.pl index 3e2f37850..4e5ea04c8 100644 --- a/tests/30rooms/04messages.pl +++ b/tests/30rooms/04messages.pl @@ -154,9 +154,6 @@ requires => [ $senduser_fixture, $remote_fixture, $room_fixture, qw( can_receive_room_message_locally )], - # this test frequently times out for unknown reasons - bug => "synapse#1679", - do => sub { my ( $senduser, $remote_user, $room_id ) = @_; diff --git a/tests/30rooms/12thirdpartyinvite.pl b/tests/30rooms/12thirdpartyinvite.pl index d580bb05a..421a5c7cb 100644 --- a/tests/30rooms/12thirdpartyinvite.pl +++ b/tests/30rooms/12thirdpartyinvite.pl @@ -366,28 +366,6 @@ sub can_invite_unbound_3pid })->followed_by( assert_membership( "join" ) ); }; -test "Uses consistent guest_access_token across requests", - requires => [ local_user_and_room_fixtures(), local_user_and_room_fixtures(), - $main::HOMESERVER_INFO[1], id_server_fixture() ], - - do => sub { - my ( $inviter1, $room1, $inviter2, $room2, $info, $id_server ) = @_; - my $hs_uribase = $info->client_location; - - Future->needs_all( - do_3pid_invite( $inviter1, $room1, $id_server->name, $invitee_email ), - do_3pid_invite( $inviter2, $room2, $id_server->name, $invitee_email ), - )->then( sub { - my $invites = $id_server->invites_for( "email", $invitee_email ); - - log_if_fail "invites", $invites; - assert_eq( scalar( @$invites ), 2, "Invite count" ); - assert_eq( $invites->[0]{guest_access_token}, $invites->[1]{guest_access_token}, "guest_access_tokens" ); - - Future->done( 1 ); - }); - }; - test "3pid invite join with wrong but valid signature are rejected", requires => [ local_user_fixtures( 2 ), $main::HOMESERVER_INFO[0], id_server_fixture() ], diff --git a/tests/30rooms/13guestaccess.pl b/tests/30rooms/13guestaccess.pl index 0a7704299..fbecb9486 100644 --- a/tests/30rooms/13guestaccess.pl +++ b/tests/30rooms/13guestaccess.pl @@ -489,8 +489,6 @@ test "Guest users can accept invites to private rooms over federation", requires => [ remote_user_fixture(), guest_user_fixture() ], - bug => "synapse#2065", - do => sub { my ( $remote_user, $local_guest ) = @_; diff --git a/tests/30rooms/20typing.pl b/tests/30rooms/20typing.pl index 64bad82bb..27b49eaa3 100644 --- a/tests/30rooms/20typing.pl +++ b/tests/30rooms/20typing.pl @@ -133,70 +133,3 @@ sub matrix_typing } $typinguser, $local_user ); }); }; - - -multi_test "Typing notifications timeout and can be resent", - requires => [ $typing_user_fixture, $room_fixture, - qw( can_set_room_typing )], - - timeout => 100, - - bug => "DISABLED", - - do => sub { - my ( $user, $room_id ) = @_; - - die "This test has been disabled due to synapse no longer supporting small typing timeouts."; - - my $start_time = time(); - - flush_events_for( $user )->then( sub { - matrix_typing( $user, $room_id, - typing => 1, - timeout => 10000, # msec; i.e. very long - ); - })->then( sub { - pass( "Sent typing notification" ); - - # start typing - await_event_for( $user, filter => sub { - my ( $event ) = @_; - return unless $event->{type} eq "m.typing"; - return unless $event->{room_id} eq $room_id; - - return unless scalar @{ $event->{content}{user_ids} }; - - pass( "Received start notification" ); - return 1; - }); - })->then( sub { - matrix_typing( $user, $room_id, - typing => 1, - timeout => 100, # msec; i.e. very short - ); - })->then( sub { - # stop typing - await_event_for( $user, filter => sub { - my ( $event ) = @_; - return unless $event->{type} eq "m.typing"; - return unless $event->{room_id} eq $room_id; - - return if scalar @{ $event->{content}{user_ids} }; - - ( time() - $start_time ) < 0.5 or - die "Took too long to time out"; - - pass( "Received stop notification" ); - return 1; - }); - })->then( sub { - matrix_typing( $user, $room_id, - typing => 1, - timeout => 10000, - ); - })->then( sub { - pass( "Sent second notification" ); - - Future->done(1); - }); - }; diff --git a/tests/31sync/15lazy-members.pl b/tests/31sync/15lazy-members.pl index 5844063e4..ec1145c97 100644 --- a/tests/31sync/15lazy-members.pl +++ b/tests/31sync/15lazy-members.pl @@ -202,8 +202,6 @@ requires => [ local_user_fixtures( 4 ), qw( can_sync ) ], - bug => "vector-im/riot-web#7211", - check => sub { my ( $alice, $bob, $charlie, $dave ) = @_; diff --git a/tests/40presence.pl b/tests/40presence.pl index f1f165c66..d19dfc46a 100644 --- a/tests/40presence.pl +++ b/tests/40presence.pl @@ -124,9 +124,6 @@ requires => [ local_user_fixture(), qw( can_initial_sync )], - # this test fails sometimes. Disable it for now to avoid red-light fatigue. - bug => "synapse#1658", - do => sub { my ( $user ) = @_; diff --git a/tests/41end-to-end-keys/01-upload-key.pl b/tests/41end-to-end-keys/01-upload-key.pl index c7460db3b..0efb5f7d1 100644 --- a/tests/41end-to-end-keys/01-upload-key.pl +++ b/tests/41end-to-end-keys/01-upload-key.pl @@ -38,8 +38,6 @@ test "Should reject keys claiming to belong to a different user", requires => [ $fixture ], - bug => "synapse#1396", - do => sub { my ( $user ) = @_; diff --git a/tests/41end-to-end-keys/06-device-lists.pl b/tests/41end-to-end-keys/06-device-lists.pl index 4c43cfd6e..86c6a14be 100644 --- a/tests/41end-to-end-keys/06-device-lists.pl +++ b/tests/41end-to-end-keys/06-device-lists.pl @@ -25,7 +25,7 @@ sub sync_until_user_in_device_list # my $trace = Devel::StackTrace->new(no_args => 1); # log_if_fail $trace->frame(1)->as_string(); - $msg = "$msg: waiting for $wait_for_id in $device_list"; + log_if_fail "$msg: waiting for $wait_for_id in $device_list"; return repeat_until_true { matrix_sync_again( $syncing_user, timeout => 1000 ) @@ -34,11 +34,15 @@ sub sync_until_user_in_device_list log_if_fail "$msg: body", $body; - my $res = $body->{device_lists} && + if( + $body->{device_lists} && $body->{device_lists}{$device_list} && - any { $_ eq $wait_for_id } @{ $body->{device_lists}{$device_list} }; - - Future->done( $res && $body ); + any { $_ eq $wait_for_id } @{ $body->{device_lists}{$device_list} } + ) { + log_if_fail "$msg: found $wait_for_id in $device_list"; + return Future->done( $body ); + } + return Future->done(0); }); }; } @@ -371,14 +375,18 @@ sub sync_until_user_in_device_list })->then( sub { matrix_set_device_display_name( $remote_leaver, $remote_leaver->device_id, "test display name" ), })->then( sub { + log_if_fail "Remote_leaver " . $remote_leaver->user_id . " set display name"; sync_until_user_in_device_list( $creator, $remote_leaver ); })->then( sub { matrix_leave_room_synced( $remote_leaver, $room_id ) })->then( sub { + log_if_fail "Remote_leaver " . $remote_leaver->user_id . " left room"; matrix_put_e2e_keys( $remote_leaver, device_keys => { updated => "keys" } ) })->then( sub { + log_if_fail "Remote_leaver " . $remote_leaver->user_id . " updated keys"; matrix_put_e2e_keys( $remote2, device_keys => { updated => "keys" } ) })->then( sub { + log_if_fail "Remote user 2 " . $remote2->user_id . " updated keys"; sync_until_user_in_device_list( $creator, $remote2 ); })->then( sub { my ( $body ) = @_; diff --git a/tests/50federation/30room-join.pl b/tests/50federation/30room-join.pl index c59154018..a6bc56b9a 100644 --- a/tests/50federation/30room-join.pl +++ b/tests/50federation/30room-join.pl @@ -39,14 +39,11 @@ sub assert_is_valid_pdu { # for event types which are known to be state events, check that they # have the relevant keys if ( $STATE_EVENT_TYPES{ $event->{type} }) { - # XXX richvdh: I'm unconvinced prev_state is required here - I think - # it's deprecated. It's certainly not mentioned in the spec. assert_json_keys( $event, qw( - state_key prev_state + state_key )); assert_json_string( $event->{state_key} ); - assert_json_list( $event->{prev_state} ); } # TODO: Check signatures and hashes @@ -233,7 +230,7 @@ sub assert_is_valid_pdu { my $protoevent = $body->{event}; assert_json_keys( $protoevent, qw( - auth_events content depth prev_state room_id sender state_key type + auth_events content depth room_id sender state_key type )); assert_json_nonempty_list( my $auth_events = $protoevent->{auth_events} ); @@ -265,7 +262,7 @@ sub assert_is_valid_pdu { my %event = ( ( map { $_ => $protoevent->{$_} } qw( - auth_events content depth prev_events prev_state room_id sender + auth_events content depth prev_events room_id sender state_key type ) ), event_id => $datastore->next_event_id, diff --git a/tests/50federation/35room-invite.pl b/tests/50federation/35room-invite.pl index 78854cd3b..f17f87abc 100644 --- a/tests/50federation/35room-invite.pl +++ b/tests/50federation/35room-invite.pl @@ -27,7 +27,7 @@ assert_eq( $body->{sender}, $user->user_id, 'event sender' ); - assert_json_keys( $body, qw( content state_key prev_state )); + assert_json_keys( $body, qw( content state_key )); assert_eq( $body->{content}{membership}, "invite", 'event content membership' ); diff --git a/tests/52user-directory/01public.pl b/tests/52user-directory/01public.pl index 588264747..584304bb6 100644 --- a/tests/52user-directory/01public.pl +++ b/tests/52user-directory/01public.pl @@ -151,9 +151,6 @@ multi_test "Users appear/disappear from directory when $type are changed", requires => [ local_user_fixtures( 2 ) ], - # this test is currently flaky due to a synapse bug - bug => "synapse#2306", - check => sub { my ( $creator, $user ) = @_; @@ -249,9 +246,6 @@ multi_test "Users stay in directory when join_rules are changed but history_visibility is world_readable", requires => [ local_user_fixtures( 2 ) ], - # this test is currently flaky due to a synapse bug - bug => "synapse#2306", - check => sub { my ( $creator, $user ) = @_; diff --git a/tests/61push/07_set_enabled.pl b/tests/61push/07_set_enabled.pl index ef35d55da..c5916f31f 100644 --- a/tests/61push/07_set_enabled.pl +++ b/tests/61push/07_set_enabled.pl @@ -60,8 +60,6 @@ sub check_enable_disable_rule { test "Enabling an unknown default rule fails with 404", requires => [ local_user_fixture() ], - bug => "SYN-676", - check => sub { my ( $user ) = @_; matrix_set_push_rule_enabled( diff --git a/tests/90jira/SYN-115.pl b/tests/90jira/SYN-115.pl index 029d3ae21..28a639500 100644 --- a/tests/90jira/SYN-115.pl +++ b/tests/90jira/SYN-115.pl @@ -4,10 +4,6 @@ requires => [ local_user_fixture(), remote_user_fixture( with_events => 1 ), qw( can_create_private_room )], - # this test fails intermittently on dendron-fronted builds, for unknown - # reasons. - bug => 'synapse#1663', - do => sub { my ( $alice, $bob ) = @_;