Lines 117-127
subtest 'set() (authorized user tests)' => sub {
Link Here
|
117 |
|
117 |
|
118 |
subtest 'set_public() (unprivileged user tests)' => sub { |
118 |
subtest 'set_public() (unprivileged user tests)' => sub { |
119 |
|
119 |
|
120 |
plan tests => 15; |
120 |
plan tests => 18; |
121 |
|
121 |
|
122 |
$schema->storage->txn_begin; |
122 |
$schema->storage->txn_begin; |
123 |
|
123 |
|
124 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
124 |
my $category = $builder->build_object( |
|
|
125 |
{ |
126 |
class => 'Koha::Patron::Categories', |
127 |
value => { change_password => 0 } # disallow changing password for the patron category |
128 |
} |
129 |
); |
130 |
my $patron = $builder->build_object( |
131 |
{ |
132 |
class => 'Koha::Patrons', |
133 |
value => { categorycode => $category->id } |
134 |
} |
135 |
); |
136 |
|
125 |
my $password = 'thePassword123'; |
137 |
my $password = 'thePassword123'; |
126 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
138 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
127 |
my $userid = $patron->userid; |
139 |
my $userid = $patron->userid; |
Lines 165-170
subtest 'set_public() (unprivileged user tests)' => sub {
Link Here
|
165 |
->json_is( '/error', |
177 |
->json_is( '/error', |
166 |
"Authorization failure. Missing required permission(s)." ); |
178 |
"Authorization failure. Missing required permission(s)." ); |
167 |
|
179 |
|
|
|
180 |
$t->post_ok( |
181 |
"//$userid:$password@/api/v1/public/patrons/" |
182 |
. $patron->id |
183 |
. "/password" => json => { |
184 |
password => $new_password, |
185 |
password_repeated => $new_password, |
186 |
old_password => $password |
187 |
} |
188 |
)->status_is(403)->json_is({ error => 'Changing password is forbidden' }); |
189 |
|
190 |
# Allow password changing to the patron category |
191 |
$category->change_password(1)->store; |
192 |
|
168 |
$t->post_ok( |
193 |
$t->post_ok( |
169 |
"//$userid:$password@/api/v1/public/patrons/" |
194 |
"//$userid:$password@/api/v1/public/patrons/" |
170 |
. $patron->id |
195 |
. $patron->id |
171 |
- |
|
|