From 9ec7ae6c3753f77a6c39af307cdcad2d9c42c744 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 16 Mar 2020 09:17:24 -0400 Subject: [PATCH] Add test to optionally keep other sessions. --- tests/14account/01change-password.pl | 34 +++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tests/14account/01change-password.pl b/tests/14account/01change-password.pl index 48dab76c5..7bfab0d8e 100644 --- a/tests/14account/01change-password.pl +++ b/tests/14account/01change-password.pl @@ -82,7 +82,7 @@ sub matrix_set_password })->then_done(1); }; -test "After changing password, a different session no longer works", +test "After changing password, a different session no longer works by default", requires => [ local_user_fixture( password => $password ) ], check => sub { @@ -107,6 +107,38 @@ sub matrix_set_password })->then_done(1); }; +test "After changing password, different sessions can optionally be kept", + requires => [ local_user_fixture( password => $password ) ], + + check => sub { + my ( $user ) = @_; + + my $other_login; + + matrix_login_again_with_user( $user )->then( sub { + ( $other_login ) = @_; + # ensure other login works to start with + matrix_sync( $other_login ); + })->then( sub { + do_request_json_for( $user, + method => "POST", + uri => "/r0/account/password", + content => { + auth => { + type => "m.login.password", + user => $user->user_id, + password => $password, + }, + new_password => "my new password", + logout_devices => JSON::false, + }, + ); + })->then( sub { + # The access token should still be valid. + matrix_sync( $other_login ); + })->then_done(1); + }; + test "Pushers created with a different access token are deleted on password change", requires => [ local_user_fixture( password => $password ) ],