<commit_before>my $password = "<PASSWORD>";

sub matrix_deactivate_account
{
   my ( $user, $password ) = @_;

   do_request_json_for( $user,
      method => "POST",
      uri    => "/r0/account/deactivate",
      content => {
         auth => {
            type => "m.login.password",
            user     => $user->user_id,
            password => <PASSWORD>,
         },
      },
   );
}

test "Can deactivate account",
   requires => [ local_user_fixture( password => <PASSWORD> ) ],

   check => sub {
      my ( $user ) = @_;

      matrix_deactivate_account( $user, $password );
   };

test "Can't deactivate account with wrong password",
   requires => [ local_user_fixture( password => <PASSWORD> ) ],

   check => sub {
      my ( $user ) = @_;

      matrix_deactivate_account( $user, "wrong password" )
      ->main::expect_http_403;
   };

test "After deactivating account, can't log in with password",
   requires => [ local_user_fixture( password => $password ) ],

   check => sub {
      my ( $user ) = @_;

      matrix_deactivate_account( $user, $password )
      ->then( sub {
         do_request_json_for( $user,
            method => "POST",
            uri    => "/r0/login",

            content => {
               type     => "m.login.password",
               user     => $user->user_id,
               password => $password,
            }
         # We don't mandate the exact failure code here
         # (that should be done in the login test if
         # anywhere), any 4xx code is fine as far as
         # this test is concerned.
         )->main::expect_http_4xx;
      });
   };
<commit_msg>Alignment<commit_after>my $password = "<PASSWORD>";

sub matrix_deactivate_account
{
   my ( $user, $password ) = @_;

   do_request_json_for( $user,
      method  => "POST",
      uri     => "/r0/account/deactivate",
      content => {
         auth => {
            type     => "m.login.password",
            user     => $user->user_id,
            password => $password,
         },
      },
   );
}

test "Can deactivate account",
   requires => [ local_user_fixture( password => <PASSWORD> ) ],

   check => sub {
      my ( $user ) = @_;

      matrix_deactivate_account( $user, $password );
   };

test "Can't deactivate account with wrong password",
   requires => [ local_user_fixture( password => <PASSWORD> ) ],

   check => sub {
      my ( $user ) = @_;

      matrix_deactivate_account( $user, "wrong password" )
      ->main::expect_http_403;
   };

test "After deactivating account, can't log in with password",
   requires => [ local_user_fixture( password => <PASSWORD> ) ],

   check => sub {
      my ( $user ) = @_;

      matrix_deactivate_account( $user, $password )
      ->then( sub {
         do_request_json_for( $user,
            method  => "POST",
            uri     => "/r0/login",
            content => {
               type     => "m.login.password",
               user     => $user->user_id,
               password => <PASSWORD>,
            }
         # We don't mandate the exact failure code here
         # (that should be done in the login test if
         # anywhere), any 4xx code is fine as far as
         # this test is concerned.
         )->main::expect_http_4xx;
      });
   };

{'fraction_non_alphanumeric': 0.13720073664825047, 'fraction_numerical': 0.004297114794352364, 'mean_word_length': 1.9150268336314848, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 66, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5085926', 'n_tokens_mistral': 995, 'n_tokens_neox': 961, 'n_words': 246}