From 4be68cde6c9098c606703a54efb7c6d6d494402a Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 30 Mar 2020 07:29:49 -0400 Subject: [PATCH 01/10] Add tests for SSO + user interactive authentication. --- tests/10apidoc/12device_management.pl | 58 ------ tests/10apidoc/13ui-auth.pl | 271 ++++++++++++++++++++++++++ 2 files changed, 271 insertions(+), 58 deletions(-) create mode 100644 tests/10apidoc/13ui-auth.pl diff --git a/tests/10apidoc/12device_management.pl b/tests/10apidoc/12device_management.pl index 2ce9ac87c..e9f35248d 100644 --- a/tests/10apidoc/12device_management.pl +++ b/tests/10apidoc/12device_management.pl @@ -335,61 +335,3 @@ sub matrix_delete_device { matrix_delete_device( $user, $DEVICE_ID, undef ); })->main::expect_http_401; }; - - -test "The deleted device must be consistent through an interactive auth session", - requires => [ local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $user ) = @_; - - my $DEVICE_ID = "login_device"; - my $SECOND_DEVICE_ID = "second_device"; - - # Create two devices. - matrix_login_again_with_user( - $user, - device_id => $DEVICE_ID, - initial_device_display_name => "device display", - )->then( sub { - matrix_login_again_with_user( - $user, - device_id => $SECOND_DEVICE_ID, - initial_device_display_name => "device display", - ) - })->then( sub { - # Initiate the interactive authentication session with the first device. - matrix_delete_device( $user, $DEVICE_ID, {} ); - })->main::expect_http_401->then( sub { - my ( $resp ) = @_; - - my $body = decode_json $resp->content; - - log_if_fail( "Response to empty body", $body ); - - assert_json_keys( $body, qw( session params flows )); - - # Continue the interactive authentication session (by providing - # credentials), but attempt to delete the second device. - matrix_delete_device( $user, $SECOND_DEVICE_ID, { - auth => { - type => "m.login.password", - user => $user->user_id, - password => $user->password, - session => $body->{session}, - } - })->main::expect_http_403; - })->then( sub { - # The device delete was rejected (the device should still exist). - matrix_get_device( $user, $SECOND_DEVICE_ID ); - })->then( sub { - my ( $device ) = @_; - assert_json_keys( - $device, - qw( device_id user_id display_name ), - ); - assert_eq( $device->{device_id}, $SECOND_DEVICE_ID ); - assert_eq( $device->{display_name}, "device display" ); - Future->done( 1 ); - }); - }; diff --git a/tests/10apidoc/13ui-auth.pl b/tests/10apidoc/13ui-auth.pl new file mode 100644 index 000000000..c56019772 --- /dev/null +++ b/tests/10apidoc/13ui-auth.pl @@ -0,0 +1,271 @@ +use JSON qw( decode_json ); +use URI::Escape; + +# TODO This code is copied from tests/12login/02cas.pl. +sub wait_for_cas_request +{ + my ( $expected_path, %params ) = @_; + + await_http_request( $expected_path, sub { + return 1; + })->then( sub { + my ( $request ) = @_; + + my $response = HTTP::Response->new( 200 ); + $response->add_content( $params{response} // "" ); + $response->content_type( "text/plain" ); + $response->content_length( length $response->content ); + $request->respond( $response ); + + Future->done( $request ); + }); +} + +test "Interactive authentication types include SSO", + requires => [ local_user_fixture( with_events => 0 ), $main::API_CLIENTS[0] ], + + do => sub { + my ( $user, $http ) = @_; + + my $DEVICE_ID = "login_device"; + + matrix_login_again_with_user( + $user, + device_id => $DEVICE_ID, + initial_device_display_name => "device display", + )->then( sub { + # Initiate the interactive authentication session with the first device. + matrix_delete_device( $user, $DEVICE_ID, {} ); + })->main::expect_http_401->then( sub { + my ($resp) = @_; + + my $body = decode_json $resp->content; + + log_if_fail("Response to empty body", $body); + + assert_json_keys($body, qw(session params flows)); + ref $body->{flows} eq "ARRAY" or die "Expected 'flows' as a list"; + + # Note that this uses the unstable value. + die "org.matrix.login.sso was not listed" unless + any { $_->{stages}[0] eq "org.matrix.login.sso" } @{ $body->{flows} }; + + Future->done( 1 ); + }); + }; + +test "Can perform interactive authentication with SSO", + requires => [ + local_user_fixture( with_events => 0 ), + $main::API_CLIENTS[0], + $main::HOMESERVER_INFO[0], + ], + + do => sub { + my ( $user, $http, $homeserver_info ) = @_; + + my $DEVICE_ID = "login_device"; + + my ($user_localpart) = $user->user_id =~ m/@([^:]*):/; + my $CAS_SUCCESS = <<"EOF"; + + + $user_localpart + + + +EOF + + # the ticket our mocked-up CAS server "generates" + my $CAS_TICKET = "goldenticket"; + my $session; + + # Create a device. + matrix_login_again_with_user( + $user, + device_id => $DEVICE_ID, + initial_device_display_name => "device display", + )->then( sub { + # Initiate the interactive authentication session via device deletion. + matrix_delete_device( $user, $DEVICE_ID, {} ); + })->main::expect_http_401->then( sub { + my ( $resp ) = @_; + + my $body = decode_json $resp->content; + + log_if_fail( "Response to empty body", $body ); + + assert_json_keys( $body, qw( session params flows )); + + $session = $body->{session}; + + # Note that we skip almost all of the CAS flow since it isn't important + # for this test. The user just needs to end up back at the homeserver + # with a valid ticket (and the original UI Auth session ID). + my $login_uri = $homeserver_info->client_location . "/_matrix/client/r0/auth/cas/ticket?session=$session&ticket=$CAS_TICKET"; + + Future->needs_all( + wait_for_cas_request( + "/cas/proxyValidate", + response => $CAS_SUCCESS, + ), + $http->do_request_json( + method => "GET", + full_uri => $login_uri, + max_redirects => 0, # don't follow the redirect + ), + ); + })->then( sub { + # Repeat the device deletion, which should now complete. + matrix_delete_device( $user, $DEVICE_ID, { + auth => { + session => $session, + }, + }); + })->then( sub { + # the device should be deleted. + matrix_get_device( $user, $DEVICE_ID )->main::expect_http_404; + }); + }; + +test "The user must be consistent through an interactive authentication session with SSO", + requires => [ + local_user_fixture( with_events => 0 ), + $main::API_CLIENTS[0], + $main::HOMESERVER_INFO[0], + ], + + do => sub { + my ( $user, $http, $homeserver_info ) = @_; + + my $DEVICE_ID = "login_device"; + + # The user below is what is returned from SSO and does not match the user + # being logged into the homeserver. + my $CAS_SUCCESS = <<'EOF'; + + + cas_user + + + +EOF + + # the ticket our mocked-up CAS server "generates" + my $CAS_TICKET = "goldenticket"; + my $session; + + # Create a device. + matrix_login_again_with_user( + $user, + device_id => $DEVICE_ID, + initial_device_display_name => "device display", + )->then( sub { + # Initiate the interactive authentication session via device deletion. + matrix_delete_device( $user, $DEVICE_ID, {} ); + })->main::expect_http_401->then( sub { + my ( $resp ) = @_; + + my $body = decode_json $resp->content; + + log_if_fail( "Response to empty body", $body ); + + assert_json_keys( $body, qw( session params flows )); + + $session = $body->{session}; + + # Note that we skip almost all of the CAS flow since it isn't important + # for this test. The user just needs to end up back at the homeserver + # with a valid ticket (and the original UI Auth session ID). + my $login_uri = $homeserver_info->client_location . "/_matrix/client/r0/auth/cas/ticket?session=$session&ticket=$CAS_TICKET"; + + Future->needs_all( + wait_for_cas_request( + "/cas/proxyValidate", + response => $CAS_SUCCESS, + ), + $http->do_request_json( + method => "GET", + full_uri => $login_uri, + max_redirects => 0, # don't follow the redirect + ), + ); + })->then( sub { + # Repeat the device deletion, which should now complete. + matrix_delete_device( $user, $DEVICE_ID, { + auth => { + session => $session, + }, + })->main::expect_http_403; + })->then( sub { + # The device delete was rejected (the device should still exist). + matrix_get_device( $user, $DEVICE_ID ); + })->then( sub { + my ( $device ) = @_; + assert_json_keys( + $device, + qw( device_id user_id display_name ), + ); + assert_eq( $device->{device_id}, $DEVICE_ID ); + assert_eq( $device->{display_name}, "device display" ); + Future->done( 1 ); + }); + }; + + +test "The operation must be consistent through an interactive authentication session", + requires => [ local_user_fixture( with_events => 0 ) ], + + do => sub { + my ( $user ) = @_; + + my $DEVICE_ID = "login_device"; + my $SECOND_DEVICE_ID = "second_device"; + + # Create two devices. + matrix_login_again_with_user( + $user, + device_id => $DEVICE_ID, + initial_device_display_name => "device display", + )->then( sub { + matrix_login_again_with_user( + $user, + device_id => $SECOND_DEVICE_ID, + initial_device_display_name => "device display", + ) + })->then( sub { + # Initiate the interactive authentication session with the first device. + matrix_delete_device( $user, $DEVICE_ID, {} ); + })->main::expect_http_401->then( sub { + my ( $resp ) = @_; + + my $body = decode_json $resp->content; + + log_if_fail( "Response to empty body", $body ); + + assert_json_keys( $body, qw( session params flows )); + + # Continue the interactive authentication session (by providing + # credentials), but attempt to delete the second device. + matrix_delete_device( $user, $SECOND_DEVICE_ID, { + auth => { + type => "m.login.password", + user => $user->user_id, + password => $user->password, + session => $body->{session}, + } + })->main::expect_http_403; + })->then( sub { + # The device delete was rejected (the device should still exist). + matrix_get_device( $user, $SECOND_DEVICE_ID ); + })->then( sub { + my ( $device ) = @_; + assert_json_keys( + $device, + qw( device_id user_id display_name ), + ); + assert_eq( $device->{device_id}, $SECOND_DEVICE_ID ); + assert_eq( $device->{display_name}, "device display" ); + Future->done( 1 ); + }); + }; From 1f6282fa246c17e950eb738a9cab2cb7a8e0dd79 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 1 Apr 2020 15:09:06 -0400 Subject: [PATCH 02/10] Updates per changes to the Synapse PR. --- tests/10apidoc/13ui-auth.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/10apidoc/13ui-auth.pl b/tests/10apidoc/13ui-auth.pl index c56019772..af4131867 100644 --- a/tests/10apidoc/13ui-auth.pl +++ b/tests/10apidoc/13ui-auth.pl @@ -102,7 +102,7 @@ sub wait_for_cas_request # Note that we skip almost all of the CAS flow since it isn't important # for this test. The user just needs to end up back at the homeserver # with a valid ticket (and the original UI Auth session ID). - my $login_uri = $homeserver_info->client_location . "/_matrix/client/r0/auth/cas/ticket?session=$session&ticket=$CAS_TICKET"; + my $login_uri = $homeserver_info->client_location . "/_matrix/client/r0/login/cas/ticket?session=$session&ticket=$CAS_TICKET"; Future->needs_all( wait_for_cas_request( @@ -177,7 +177,7 @@ sub wait_for_cas_request # Note that we skip almost all of the CAS flow since it isn't important # for this test. The user just needs to end up back at the homeserver # with a valid ticket (and the original UI Auth session ID). - my $login_uri = $homeserver_info->client_location . "/_matrix/client/r0/auth/cas/ticket?session=$session&ticket=$CAS_TICKET"; + my $login_uri = $homeserver_info->client_location . "/_matrix/client/r0/login/cas/ticket?session=$session&ticket=$CAS_TICKET"; Future->needs_all( wait_for_cas_request( From 9727768fa8a3823d9839d561202858e60d0d9a90 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 1 Apr 2020 15:17:30 -0400 Subject: [PATCH 03/10] Basic review comments. --- tests/10apidoc/13ui-auth.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/10apidoc/13ui-auth.pl b/tests/10apidoc/13ui-auth.pl index af4131867..6674df7ea 100644 --- a/tests/10apidoc/13ui-auth.pl +++ b/tests/10apidoc/13ui-auth.pl @@ -22,10 +22,10 @@ sub wait_for_cas_request } test "Interactive authentication types include SSO", - requires => [ local_user_fixture( with_events => 0 ), $main::API_CLIENTS[0] ], + requires => [ local_user_fixture( with_events => 0 ) ], do => sub { - my ( $user, $http ) = @_; + my ( $user ) = @_; my $DEVICE_ID = "login_device"; @@ -34,7 +34,7 @@ sub wait_for_cas_request device_id => $DEVICE_ID, initial_device_display_name => "device display", )->then( sub { - # Initiate the interactive authentication session with the first device. + # Initiate the interactive authentication session. matrix_delete_device( $user, $DEVICE_ID, {} ); })->main::expect_http_401->then( sub { my ($resp) = @_; @@ -191,7 +191,7 @@ sub wait_for_cas_request ), ); })->then( sub { - # Repeat the device deletion, which should now complete. + # Repeat the device deletion, which should now give an auth error. matrix_delete_device( $user, $DEVICE_ID, { auth => { session => $session, From 275738e0014ad555fd9472523a1a8797770c2528 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 3 Apr 2020 08:33:03 -0400 Subject: [PATCH 04/10] Fix formatting. --- tests/10apidoc/13ui-auth.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/10apidoc/13ui-auth.pl b/tests/10apidoc/13ui-auth.pl index 6674df7ea..4bf4feb97 100644 --- a/tests/10apidoc/13ui-auth.pl +++ b/tests/10apidoc/13ui-auth.pl @@ -41,7 +41,7 @@ sub wait_for_cas_request my $body = decode_json $resp->content; - log_if_fail("Response to empty body", $body); + log_if_fail "Response to empty body", $body; assert_json_keys($body, qw(session params flows)); ref $body->{flows} eq "ARRAY" or die "Expected 'flows' as a list"; @@ -93,7 +93,7 @@ sub wait_for_cas_request my $body = decode_json $resp->content; - log_if_fail( "Response to empty body", $body ); + log_if_fail "Response to empty body", $body; assert_json_keys( $body, qw( session params flows )); @@ -168,7 +168,7 @@ sub wait_for_cas_request my $body = decode_json $resp->content; - log_if_fail( "Response to empty body", $body ); + log_if_fail "Response to empty body", $body; assert_json_keys( $body, qw( session params flows )); @@ -241,7 +241,7 @@ sub wait_for_cas_request my $body = decode_json $resp->content; - log_if_fail( "Response to empty body", $body ); + log_if_fail "Response to empty body", $body; assert_json_keys( $body, qw( session params flows )); From ef495d1a9182af2b845fa34bc2250020b45040d3 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 3 Apr 2020 08:57:54 -0400 Subject: [PATCH 05/10] Use assert_json_list. --- tests/10apidoc/13ui-auth.pl | 2 +- tests/12login/02cas.pl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/10apidoc/13ui-auth.pl b/tests/10apidoc/13ui-auth.pl index 4bf4feb97..c076b3c45 100644 --- a/tests/10apidoc/13ui-auth.pl +++ b/tests/10apidoc/13ui-auth.pl @@ -44,7 +44,7 @@ sub wait_for_cas_request log_if_fail "Response to empty body", $body; assert_json_keys($body, qw(session params flows)); - ref $body->{flows} eq "ARRAY" or die "Expected 'flows' as a list"; + assert_json_list $body->{flows}; # Note that this uses the unstable value. die "org.matrix.login.sso was not listed" unless diff --git a/tests/12login/02cas.pl b/tests/12login/02cas.pl index 56e7173bc..8febda37a 100644 --- a/tests/12login/02cas.pl +++ b/tests/12login/02cas.pl @@ -41,7 +41,7 @@ sub wait_for_cas_request my ( $body ) = @_; assert_json_keys( $body, qw( flows )); - ref $body->{flows} eq "ARRAY" or die "Expected 'flows' as a list"; + assert_json_list $body->{flows}; die "m.login.sso was not listed" unless any { $_->{type} eq "m.login.sso" } @{ $body->{flows} }; @@ -64,7 +64,7 @@ sub wait_for_cas_request my ( $body ) = @_; assert_json_keys( $body, qw( flows )); - ref $body->{flows} eq "ARRAY" or die "Expected 'flows' as a list"; + assert_json_list $body->{flows}; die "SKIP: no m.login.cas" unless any { $_->{type} eq "m.login.cas" } @{ $body->{flows} }; From f1c511a0969ff2992df8df73971fe5584f74db1d Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 3 Apr 2020 09:34:46 -0400 Subject: [PATCH 06/10] Remove duplicated wait_for_cas_request function. --- tests/10apidoc/13ui-auth.pl | 5 ++++- tests/12login/02cas.pl | 19 ------------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/tests/10apidoc/13ui-auth.pl b/tests/10apidoc/13ui-auth.pl index c076b3c45..329986a05 100644 --- a/tests/10apidoc/13ui-auth.pl +++ b/tests/10apidoc/13ui-auth.pl @@ -1,7 +1,10 @@ use JSON qw( decode_json ); use URI::Escape; -# TODO This code is copied from tests/12login/02cas.pl. +our @EXPORT = qw( wait_for_cas_request ); + +# A convenience function which wraps await_http_request. It returns a successful +# CAS response when queried for a particular path. sub wait_for_cas_request { my ( $expected_path, %params ) = @_; diff --git a/tests/12login/02cas.pl b/tests/12login/02cas.pl index 8febda37a..429c63b5d 100644 --- a/tests/12login/02cas.pl +++ b/tests/12login/02cas.pl @@ -1,24 +1,5 @@ use URI::Escape; -sub wait_for_cas_request -{ - my ( $expected_path, %params ) = @_; - - await_http_request( $expected_path, sub { - return 1; - })->then( sub { - my ( $request ) = @_; - - my $response = HTTP::Response->new( 200 ); - $response->add_content( $params{response} // "" ); - $response->content_type( "text/plain" ); - $response->content_length( length $response->content ); - $request->respond( $response ); - - Future->done( $request ); - }); -} - my $CAS_SUCCESS = <<'EOF'; From 99ad057d09c0b89f21e2a25d7c1461971d9f2a0b Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 3 Apr 2020 11:44:02 -0400 Subject: [PATCH 07/10] Move duplicated code to a function. --- tests/10apidoc/13ui-auth.pl | 58 +++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/tests/10apidoc/13ui-auth.pl b/tests/10apidoc/13ui-auth.pl index 329986a05..f0aefa4ef 100644 --- a/tests/10apidoc/13ui-auth.pl +++ b/tests/10apidoc/13ui-auth.pl @@ -24,6 +24,30 @@ sub wait_for_cas_request }); } +# Generate a ticket request from the client to the homeserver (and "validate" +# it with the CAS server). +sub make_ticket_request +{ + my ( $http, $homeserver_info, $session, $ticket, $response ) = @_; + + # Note that we skip almost all of the CAS flow since it isn't important + # for this test. The user just needs to end up back at the homeserver + # with a valid ticket (and the original UI Auth session ID). + my $login_uri = $homeserver_info->client_location . "/_matrix/client/r0/login/cas/ticket?session=$session&ticket=$ticket"; + + Future->needs_all( + wait_for_cas_request( + "/cas/proxyValidate", + response => $response, + ), + $http->do_request_json( + method => "GET", + full_uri => $login_uri, + max_redirects => 0, # don't follow the redirect + ), + ); +} + test "Interactive authentication types include SSO", requires => [ local_user_fixture( with_events => 0 ) ], @@ -102,22 +126,7 @@ sub wait_for_cas_request $session = $body->{session}; - # Note that we skip almost all of the CAS flow since it isn't important - # for this test. The user just needs to end up back at the homeserver - # with a valid ticket (and the original UI Auth session ID). - my $login_uri = $homeserver_info->client_location . "/_matrix/client/r0/login/cas/ticket?session=$session&ticket=$CAS_TICKET"; - - Future->needs_all( - wait_for_cas_request( - "/cas/proxyValidate", - response => $CAS_SUCCESS, - ), - $http->do_request_json( - method => "GET", - full_uri => $login_uri, - max_redirects => 0, # don't follow the redirect - ), - ); + make_ticket_request( $http, $homeserver_info, $session, $CAS_TICKET, $CAS_SUCCESS ); })->then( sub { # Repeat the device deletion, which should now complete. matrix_delete_device( $user, $DEVICE_ID, { @@ -177,22 +186,7 @@ sub wait_for_cas_request $session = $body->{session}; - # Note that we skip almost all of the CAS flow since it isn't important - # for this test. The user just needs to end up back at the homeserver - # with a valid ticket (and the original UI Auth session ID). - my $login_uri = $homeserver_info->client_location . "/_matrix/client/r0/login/cas/ticket?session=$session&ticket=$CAS_TICKET"; - - Future->needs_all( - wait_for_cas_request( - "/cas/proxyValidate", - response => $CAS_SUCCESS, - ), - $http->do_request_json( - method => "GET", - full_uri => $login_uri, - max_redirects => 0, # don't follow the redirect - ), - ); + make_ticket_request( $http, $homeserver_info, $session, $CAS_TICKET, $CAS_SUCCESS ); })->then( sub { # Repeat the device deletion, which should now give an auth error. matrix_delete_device( $user, $DEVICE_ID, { From f47494d0dbde21e33c18648fc7032fb3d1e909c5 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 9 Apr 2020 14:02:43 -0400 Subject: [PATCH 08/10] Update description of make_ticket_request function. Co-Authored-By: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- tests/10apidoc/13ui-auth.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/10apidoc/13ui-auth.pl b/tests/10apidoc/13ui-auth.pl index f0aefa4ef..52b497cb3 100644 --- a/tests/10apidoc/13ui-auth.pl +++ b/tests/10apidoc/13ui-auth.pl @@ -24,8 +24,9 @@ sub wait_for_cas_request }); } -# Generate a ticket request from the client to the homeserver (and "validate" -# it with the CAS server). +# Generate a ticket-submission request from the client to the homeserver. +# +# Waits for the validation request from the homeserver, and returns the given response. sub make_ticket_request { my ( $http, $homeserver_info, $session, $ticket, $response ) = @_; From cb5991e060ad774cc4762d790403d914ed890872 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 9 Apr 2020 13:59:24 -0400 Subject: [PATCH 09/10] Do not pass in a default value. --- tests/10apidoc/12device_management.pl | 18 +++++++++--------- tests/10apidoc/13ui-auth.pl | 8 ++++---- tests/30rooms/05aliases.pl | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/10apidoc/12device_management.pl b/tests/10apidoc/12device_management.pl index e9f35248d..88b0e8ce4 100644 --- a/tests/10apidoc/12device_management.pl +++ b/tests/10apidoc/12device_management.pl @@ -37,7 +37,7 @@ sub matrix_delete_device { } test "GET /device/{deviceId}", - requires => [ local_user_fixture( with_events => 0 ) ], + requires => [ local_user_fixture() ], do => sub { my ( $user ) = @_; @@ -64,7 +64,7 @@ sub matrix_delete_device { }; test "GET /device/{deviceId} gives a 404 for unknown devices", - requires => [ local_user_fixture( with_events => 0 ) ], + requires => [ local_user_fixture() ], do => sub { my ( $user ) = @_; @@ -78,7 +78,7 @@ sub matrix_delete_device { test "GET /devices", - requires => [ local_user_fixture( with_events => 0 ) ], + requires => [ local_user_fixture() ], do => sub { my ( $user ) = @_; @@ -136,7 +136,7 @@ sub matrix_delete_device { }; test "PUT /device/{deviceId} updates device fields", - requires => [ local_user_fixture( with_events => 0 ) ], + requires => [ local_user_fixture() ], do => sub { my ( $user ) = @_; @@ -172,7 +172,7 @@ sub matrix_delete_device { }; test "PUT /device/{deviceId} gives a 404 for unknown devices", - requires => [ local_user_fixture( with_events => 0 ) ], + requires => [ local_user_fixture() ], do => sub { my ( $user ) = @_; @@ -188,7 +188,7 @@ sub matrix_delete_device { }; test "DELETE /device/{deviceId}", - requires => [ local_user_fixture( with_events => 0 ) ], + requires => [ local_user_fixture() ], do => sub { my ( $user ) = @_; @@ -273,8 +273,8 @@ sub matrix_delete_device { # test "DELETE /device/{deviceId} requires UI auth user to match device owner", requires => [ - local_user_fixture( with_events => 0 ), - local_user_fixture( with_events => 0 ), + local_user_fixture(), + local_user_fixture(), ], do => sub { @@ -317,7 +317,7 @@ sub matrix_delete_device { test "DELETE /device/{deviceId} with no body gives a 401", - requires => [ local_user_fixture( with_events => 0 ) ], + requires => [ local_user_fixture() ], do => sub { my ( $user ) = @_; diff --git a/tests/10apidoc/13ui-auth.pl b/tests/10apidoc/13ui-auth.pl index 52b497cb3..ec4ad419b 100644 --- a/tests/10apidoc/13ui-auth.pl +++ b/tests/10apidoc/13ui-auth.pl @@ -50,7 +50,7 @@ sub make_ticket_request } test "Interactive authentication types include SSO", - requires => [ local_user_fixture( with_events => 0 ) ], + requires => [ local_user_fixture() ], do => sub { my ( $user ) = @_; @@ -84,7 +84,7 @@ sub make_ticket_request test "Can perform interactive authentication with SSO", requires => [ - local_user_fixture( with_events => 0 ), + local_user_fixture(), $main::API_CLIENTS[0], $main::HOMESERVER_INFO[0], ], @@ -143,7 +143,7 @@ sub make_ticket_request test "The user must be consistent through an interactive authentication session with SSO", requires => [ - local_user_fixture( with_events => 0 ), + local_user_fixture(), $main::API_CLIENTS[0], $main::HOMESERVER_INFO[0], ], @@ -212,7 +212,7 @@ sub make_ticket_request test "The operation must be consistent through an interactive authentication session", - requires => [ local_user_fixture( with_events => 0 ) ], + requires => [ local_user_fixture() ], do => sub { my ( $user ) = @_; diff --git a/tests/30rooms/05aliases.pl b/tests/30rooms/05aliases.pl index 8234ef3bc..2f3cb5bf2 100644 --- a/tests/30rooms/05aliases.pl +++ b/tests/30rooms/05aliases.pl @@ -345,7 +345,7 @@ sub _test_can_create_and_delete_alias { }; test "Can delete canonical alias", - requires => [ local_user_fixture( with_events => 0 ), room_alias_fixture(), + requires => [ local_user_fixture(), room_alias_fixture(), qw( can_create_room_alias )], do => sub { From 80e01fb9569319fa613d07d8082332113cefce70 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 17 Apr 2020 07:28:04 -0400 Subject: [PATCH 10/10] Add comments about parameters of the wait_for_cas_request function. --- tests/10apidoc/13ui-auth.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/10apidoc/13ui-auth.pl b/tests/10apidoc/13ui-auth.pl index ec4ad419b..40d831a79 100644 --- a/tests/10apidoc/13ui-auth.pl +++ b/tests/10apidoc/13ui-auth.pl @@ -5,6 +5,11 @@ # A convenience function which wraps await_http_request. It returns a successful # CAS response when queried for a particular path. +# +# This takes two parameters: +# * The expected path of the request the homeserver makes to the CAS server. +# * A hash of parameters with the following (optional) keys: +# * response: The HTTP response body to return to the homeserver request. sub wait_for_cas_request { my ( $expected_path, %params ) = @_;