From ddc482e30665eda2b5bf7f5b7b73b533e2d7103c Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 12 Feb 2020 15:11:07 -0500 Subject: [PATCH] Update tests to match removal of Synapse sending events when creating or deleting aliases. --- .gitignore | 3 +- tests/30rooms/05aliases.pl | 99 ----------------------------- tests/60app-services/01as-create.pl | 45 ++----------- tests/60app-services/03passive.pl | 21 ------ tests/61push/01message-pushed.pl | 36 +++-------- 5 files changed, 17 insertions(+), 187 deletions(-) diff --git a/.gitignore b/.gitignore index 9053061b3..07194712c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ /var \#* .vscode -.coverage* \ No newline at end of file +.coverage* +.idea diff --git a/tests/30rooms/05aliases.pl b/tests/30rooms/05aliases.pl index 5cc46d70b..6fb63e0af 100644 --- a/tests/30rooms/05aliases.pl +++ b/tests/30rooms/05aliases.pl @@ -177,20 +177,6 @@ sub _test_can_create_and_delete_alias { content => { room_id => $room_id }, )->then( sub { - matrix_get_room_state( $user, $room_id, - type => "m.room.aliases", - state_key => $server_name, - ) - })->then( sub { - my ( $body ) = @_; - - log_if_fail "Aliases after adding alias", $body; - - assert_json_keys( $body, qw( aliases ) ); - assert_json_list( my $aliases = $body->{aliases} ); - - any { $_ eq $alias } @$aliases or die "Expected alias to be in list"; - do_request_json_for( $user, method => "DELETE", uri => "/r0/directory/room/$alias", @@ -198,19 +184,6 @@ sub _test_can_create_and_delete_alias { content => {}, ) })->then( sub { - matrix_get_room_state( $user, $room_id, - type => "m.room.aliases", - state_key => $server_name, - ) - })->then( sub { - my ( $body ) = @_; - - log_if_fail "Aliases after deleting alias", $body; - assert_json_keys( $body, qw( aliases ) ); - assert_json_list( my $aliases = $body->{aliases} ); - - none { $_ eq $alias } @$aliases or die "Expected alias to not be in list"; - Future->done; }); } @@ -278,18 +251,6 @@ sub _test_can_create_and_delete_alias { content => { alias => $room_alias } ) })->then( sub { - matrix_get_room_state( $creator, $room_id, - type => "m.room.aliases", - state_key => $server_name, - ) - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( aliases ) ); - assert_json_list( my $aliases = $body->{aliases} ); - - any { $_ eq $room_alias } @$aliases or die "Expected alias to be in list"; - do_request_json_for( $creator, method => "DELETE", uri => "/r0/directory/room/$room_alias", @@ -297,18 +258,6 @@ sub _test_can_create_and_delete_alias { content => {}, ) })->then( sub { - matrix_get_room_state( $creator, $room_id, - type => "m.room.aliases", - state_key => $server_name, - ) - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( aliases ) ); - assert_json_list( my $aliases = $body->{aliases} ); - - none { $_ eq $room_alias } @$aliases or die "Expected alias to not be in list"; - matrix_get_room_state( $creator, $room_id, type => "m.room.canonical_alias", ) @@ -340,18 +289,6 @@ sub _test_can_create_and_delete_alias { content => { room_id => $room_id }, ) })->then( sub { - matrix_get_room_state( $creator, $room_id, - type => "m.room.aliases", - state_key => $server_name, - ) - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( aliases ) ); - assert_json_list( my $aliases = $body->{aliases} ); - - any { $_ eq $room_alias } @$aliases or die "Expected alias to be in list"; - do_request_json_for( $other_user, method => "DELETE", uri => "/r0/directory/room/$room_alias", @@ -359,18 +296,6 @@ sub _test_can_create_and_delete_alias { content => {}, ) })->then( sub { - matrix_get_room_state( $creator, $room_id, - type => "m.room.aliases", - state_key => $server_name, - ) - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( aliases ) ); - assert_json_list( my $aliases = $body->{aliases} ); - - none { $_ eq $room_alias } @$aliases or die "Expected alias to not be in list"; - Future->done(1); }) }; @@ -399,18 +324,6 @@ sub _test_can_create_and_delete_alias { content => { alias => $room_alias } ) })->then( sub { - matrix_get_room_state( $creator, $room_id, - type => "m.room.aliases", - state_key => $server_name, - ) - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( aliases ) ); - assert_json_list( my $aliases = $body->{aliases} ); - - any { $_ eq $room_alias } @$aliases or die "Expected alias to be in list"; - do_request_json_for( $other_user, method => "DELETE", uri => "/r0/directory/room/$room_alias", @@ -418,18 +331,6 @@ sub _test_can_create_and_delete_alias { content => {}, ) })->then( sub { - matrix_get_room_state( $creator, $room_id, - type => "m.room.aliases", - state_key => $server_name, - ) - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( aliases ) ); - assert_json_list( my $aliases = $body->{aliases} ); - - none { $_ eq $room_alias } @$aliases or die "Expected alias to not be in list"; - Future->done(1); }) }; diff --git a/tests/60app-services/01as-create.pl b/tests/60app-services/01as-create.pl index 39df7c49f..973ad5306 100644 --- a/tests/60app-services/01as-create.pl +++ b/tests/60app-services/01as-create.pl @@ -115,46 +115,13 @@ do => sub { my ( $as_user, $appserv, $room_id, $room_alias ) = @_; - Future->needs_all( - $appserv->await_event( "m.room.aliases" )->then( sub { - my ( $event, $request ) = @_; - - # As this is the first AS event we've received, lets check that the - # token matches, to give that coverage. - - my $access_token = $request->query_param( "access_token" ); - - assert_ok( defined $access_token, - "HS provides an access_token" ); - assert_eq( $access_token, $appserv->info->hs2as_token, - "HS provides the correct token" ); - - log_if_fail "Event", $event; - - assert_json_keys( $event, qw( content room_id user_id )); - - $event->{room_id} eq $room_id or - die "Expected room_id to be $room_id"; - $event->{user_id} eq $as_user->user_id or - die "Expected user_id to be ${\$as_user->user_id}"; - - assert_json_keys( my $content = $event->{content}, qw( aliases )); - assert_json_list( my $aliases = $content->{aliases} ); - - grep { $_ eq $room_alias } @$aliases or - die "Expected to find our alias in the aliases list"; - - Future->done; - }), - - do_request_json_for( $as_user, - method => "PUT", - uri => "/r0/directory/room/$room_alias", + do_request_json_for( $as_user, + method => "PUT", + uri => "/r0/directory/room/$room_alias", - content => { - room_id => $room_id, - }, - ) + content => { + room_id => $room_id, + }, )->then( sub { # Nothing interesting in the body diff --git a/tests/60app-services/03passive.pl b/tests/60app-services/03passive.pl index d7f126c1a..98e0bf94e 100644 --- a/tests/60app-services/03passive.pl +++ b/tests/60app-services/03passive.pl @@ -89,27 +89,6 @@ Future->done; }), - $appserv->await_event( "m.room.aliases" )->then( sub { - my ( $event ) = @_; - - log_if_fail "Event", $event; - - assert_json_keys( $event, qw( content room_id user_id )); - - $event->{room_id} eq $room_id or - die "Expected room_id to be $room_id"; - $event->{user_id} eq $as_user->user_id or - die "Expected user_id to be ${\$as_user->user_id}"; - - assert_json_keys( my $content = $event->{content}, qw( aliases )); - assert_json_list( my $aliases = $content->{aliases} ); - - grep { $_ eq $room_alias } @$aliases or - die "Expected to find our alias in the aliases list"; - - Future->done; - }), - do_request_json_for( $local_user, method => "POST", uri => "/r0/join/$room_alias", diff --git a/tests/61push/01message-pushed.pl b/tests/61push/01message-pushed.pl index e5800b121..daf389689 100644 --- a/tests/61push/01message-pushed.pl +++ b/tests/61push/01message-pushed.pl @@ -280,31 +280,6 @@ sub check_received_push_with_name }); } -test "Rooms with aliases are correctly named in pushed", - requires => [ - local_user_fixtures( 2, with_events => 0 ), room_alias_fixture(), - $main::TEST_SERVER_INFO - ], - - check => sub { - my ( $alice, $bob, $room_alias, $test_server_info ) = @_; - my $room_id; - - setup_push( $alice, $bob, $test_server_info, "/alice_push" ) - ->then( sub { - ( $room_id ) = @_; - - do_request_json_for( $bob, - method => "PUT", - uri => "/r0/directory/room/$room_alias", - - content => { room_id => $room_id }, - ) - })->then( sub { - check_received_push_with_name( $bob, $room_id, "/alice_push", $room_alias ) - }); - }; - test "Rooms with names are correctly named in pushed", requires => [ local_user_fixtures( 2, with_events => 0 ), @@ -370,10 +345,17 @@ sub check_received_push_with_name my ( $alice, $bob, $charlie, $room_alias, $test_server_info ) = @_; my $room_id; + my $name = "Test Name"; + setup_push( $alice, $bob, $test_server_info, "/alice_push" ) ->then( sub { - ( $room_id ) = @_; + ($room_id) = @_; + matrix_put_room_state($bob, $room_id, + type => "m.room.name", + content => { name => $name }, + ); + })->then( sub { matrix_join_room( $charlie, $room_id) })->then( sub { do_request_json_for( $bob, @@ -383,7 +365,7 @@ sub check_received_push_with_name content => { room_id => $room_id }, ) })->then( sub { - check_received_push_with_name( $bob, $room_id, "/alice_push", $room_alias ) + check_received_push_with_name( $bob, $room_id, "/alice_push", $name ) }); };