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 <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
be1dec7648
commit
15ca95ca1d
3 changed files with 43 additions and 18 deletions
|
@ -108,7 +108,7 @@ sub set_public {
|
||||||
|
|
||||||
my $old_password = $body->{old_password};
|
my $old_password = $body->{old_password};
|
||||||
my $password = $body->{password};
|
my $password = $body->{password};
|
||||||
my $password_2 = $body->{password_2};
|
my $password_2 = $body->{password_repeated};
|
||||||
|
|
||||||
unless ( $password eq $password_2 ) {
|
unless ( $password eq $password_2 ) {
|
||||||
return $c->render( status => 400, openapi => { error => "Passwords don't match" } );
|
return $c->render( status => 400, openapi => { error => "Passwords don't match" } );
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
"description": "New password (plain text)",
|
"description": "New password (plain text)",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"password_2": {
|
"password_repeated": {
|
||||||
"description": "Repeated new password (plain text)",
|
"description": "Repeated new password (plain text)",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["password", "password_2", "old_password"]
|
"required": ["password", "password_repeated", "old_password"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -139,10 +139,15 @@ subtest 'set_public() (unprivileged user tests)' => sub {
|
||||||
|
|
||||||
my $new_password = 'abc';
|
my $new_password = 'abc';
|
||||||
|
|
||||||
my $tx
|
my $tx = $t->ua->build_tx(
|
||||||
= $t->ua->build_tx( POST => "/api/v1/public/patrons/"
|
POST => "/api/v1/public/patrons/"
|
||||||
. $other_patron->id
|
. $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->cookies( { name => 'CGISESSID', value => $session->id } );
|
||||||
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
|
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
|
||||||
|
@ -156,10 +161,15 @@ subtest 'set_public() (unprivileged user tests)' => sub {
|
||||||
|
|
||||||
my $password = 'holapassword';
|
my $password = 'holapassword';
|
||||||
$patron->set_password( $password );
|
$patron->set_password( $password );
|
||||||
$tx
|
$tx = $t->ua->build_tx(
|
||||||
= $t->ua->build_tx( POST => "/api/v1/public/patrons/"
|
POST => "/api/v1/public/patrons/"
|
||||||
. $other_patron->id
|
. $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->cookies( { name => 'CGISESSID', value => $session->id } );
|
||||||
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
|
$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"
|
error => "Changing other patron's password is forbidden"
|
||||||
});
|
});
|
||||||
|
|
||||||
$tx
|
$tx = $t->ua->build_tx(
|
||||||
= $t->ua->build_tx( POST => "/api/v1/public/patrons/"
|
POST => "/api/v1/public/patrons/"
|
||||||
. $patron->id
|
. $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->cookies( { name => 'CGISESSID', value => $session->id } );
|
||||||
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
|
$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"
|
error => "Passwords don't match"
|
||||||
});
|
});
|
||||||
|
|
||||||
$tx
|
$tx = $t->ua->build_tx(
|
||||||
= $t->ua->build_tx( POST => "/api/v1/public/patrons/"
|
POST => "/api/v1/public/patrons/"
|
||||||
. $patron->id
|
. $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->cookies( { name => 'CGISESSID', value => $session->id } );
|
||||||
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
|
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
|
||||||
|
@ -195,10 +215,15 @@ subtest 'set_public() (unprivileged user tests)' => sub {
|
||||||
error => "Invalid password"
|
error => "Invalid password"
|
||||||
});
|
});
|
||||||
|
|
||||||
$tx
|
$tx = $t->ua->build_tx(
|
||||||
= $t->ua->build_tx( POST => "/api/v1/public/patrons/"
|
POST => "/api/v1/public/patrons/"
|
||||||
. $patron->id
|
. $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->cookies( { name => 'CGISESSID', value => $session->id } );
|
||||||
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
|
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
|
||||||
|
|
Loading…
Reference in a new issue