From 15ca95ca1d9b32bf15656ce34de04d3995be1e4d Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 18 Jan 2019 13:34:55 -0300 Subject: [PATCH] Bug 22061: (QA follow-up) Rename password_2 => password_repeated As voted when the RFC was discussed, the attribute gets renamed. The tests are adjusted accordingly. To test: - Run: $ kshell k$ prove t/db_dependent/api/v1/patrons_password.t => SUCCESS: Tests pass! Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall Signed-off-by: Nick Clemens --- Koha/REST/V1/Patrons/Password.pm | 2 +- api/v1/swagger/paths/public_patrons.json | 4 +- t/db_dependent/api/v1/patrons_password.t | 55 +++++++++++++++++------- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/Koha/REST/V1/Patrons/Password.pm b/Koha/REST/V1/Patrons/Password.pm index 8a1868ee51..08103bedbf 100644 --- a/Koha/REST/V1/Patrons/Password.pm +++ b/Koha/REST/V1/Patrons/Password.pm @@ -108,7 +108,7 @@ sub set_public { my $old_password = $body->{old_password}; my $password = $body->{password}; - my $password_2 = $body->{password_2}; + my $password_2 = $body->{password_repeated}; unless ( $password eq $password_2 ) { return $c->render( status => 400, openapi => { error => "Passwords don't match" } ); diff --git a/api/v1/swagger/paths/public_patrons.json b/api/v1/swagger/paths/public_patrons.json index 29ce642d83..74838a078b 100644 --- a/api/v1/swagger/paths/public_patrons.json +++ b/api/v1/swagger/paths/public_patrons.json @@ -21,7 +21,7 @@ "description": "New password (plain text)", "type": "string" }, - "password_2": { + "password_repeated": { "description": "Repeated new password (plain text)", "type": "string" }, @@ -30,7 +30,7 @@ "type": "string" } }, - "required": ["password", "password_2", "old_password"] + "required": ["password", "password_repeated", "old_password"] } } ], diff --git a/t/db_dependent/api/v1/patrons_password.t b/t/db_dependent/api/v1/patrons_password.t index e3213db7f4..2585018229 100644 --- a/t/db_dependent/api/v1/patrons_password.t +++ b/t/db_dependent/api/v1/patrons_password.t @@ -139,10 +139,15 @@ subtest 'set_public() (unprivileged user tests)' => sub { my $new_password = 'abc'; - my $tx - = $t->ua->build_tx( POST => "/api/v1/public/patrons/" + my $tx = $t->ua->build_tx( + POST => "/api/v1/public/patrons/" . $other_patron->id - . "/password" => json => { password => $new_password, password_2 => $new_password, old_password => 'blah' } ); + . "/password" => json => { + password => $new_password, + password_repeated => $new_password, + old_password => 'blah' + } + ); $tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); @@ -156,10 +161,15 @@ subtest 'set_public() (unprivileged user tests)' => sub { my $password = 'holapassword'; $patron->set_password( $password ); - $tx - = $t->ua->build_tx( POST => "/api/v1/public/patrons/" + $tx = $t->ua->build_tx( + POST => "/api/v1/public/patrons/" . $other_patron->id - . "/password" => json => { password => $new_password, password_2 => $new_password, old_password => $password } ); + . "/password" => json => { + password => $new_password, + password_repeated => $new_password, + old_password => $password + } + ); $tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); @@ -169,10 +179,15 @@ subtest 'set_public() (unprivileged user tests)' => sub { error => "Changing other patron's password is forbidden" }); - $tx - = $t->ua->build_tx( POST => "/api/v1/public/patrons/" + $tx = $t->ua->build_tx( + POST => "/api/v1/public/patrons/" . $patron->id - . "/password" => json => { password => $new_password, password_2 => 'wrong_password', old_password => $password } ); + . "/password" => json => { + password => $new_password, + password_repeated => 'wrong_password', + old_password => $password + } + ); $tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); @@ -182,10 +197,15 @@ subtest 'set_public() (unprivileged user tests)' => sub { error => "Passwords don't match" }); - $tx - = $t->ua->build_tx( POST => "/api/v1/public/patrons/" + $tx = $t->ua->build_tx( + POST => "/api/v1/public/patrons/" . $patron->id - . "/password" => json => { password => $new_password, password_2 => $new_password, old_password => 'badpassword' } ); + . "/password" => json => { + password => $new_password, + password_repeated => $new_password, + old_password => 'badpassword' + } + ); $tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); @@ -195,10 +215,15 @@ subtest 'set_public() (unprivileged user tests)' => sub { error => "Invalid password" }); - $tx - = $t->ua->build_tx( POST => "/api/v1/public/patrons/" + $tx = $t->ua->build_tx( + POST => "/api/v1/public/patrons/" . $patron->id - . "/password" => json => { password => $new_password, password_2 => $new_password, old_password => $password } ); + . "/password" => json => { + password => $new_password, + password_repeated => $new_password, + old_password => $password + } + ); $tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); -- 2.39.5