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 ) ],