Lines 139-148
subtest 'set_public() (unprivileged user tests)' => sub {
Link Here
|
139 |
|
139 |
|
140 |
my $new_password = 'abc'; |
140 |
my $new_password = 'abc'; |
141 |
|
141 |
|
142 |
my $tx |
142 |
my $tx = $t->ua->build_tx( |
143 |
= $t->ua->build_tx( POST => "/api/v1/public/patrons/" |
143 |
POST => "/api/v1/public/patrons/" |
144 |
. $other_patron->id |
144 |
. $other_patron->id |
145 |
. "/password" => json => { password => $new_password, password_2 => $new_password, old_password => 'blah' } ); |
145 |
. "/password" => json => { |
|
|
146 |
password => $new_password, |
147 |
password_repeated => $new_password, |
148 |
old_password => 'blah' |
149 |
} |
150 |
); |
146 |
|
151 |
|
147 |
$tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); |
152 |
$tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); |
148 |
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); |
153 |
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); |
Lines 156-165
subtest 'set_public() (unprivileged user tests)' => sub {
Link Here
|
156 |
|
161 |
|
157 |
my $password = 'holapassword'; |
162 |
my $password = 'holapassword'; |
158 |
$patron->set_password( $password ); |
163 |
$patron->set_password( $password ); |
159 |
$tx |
164 |
$tx = $t->ua->build_tx( |
160 |
= $t->ua->build_tx( POST => "/api/v1/public/patrons/" |
165 |
POST => "/api/v1/public/patrons/" |
161 |
. $other_patron->id |
166 |
. $other_patron->id |
162 |
. "/password" => json => { password => $new_password, password_2 => $new_password, old_password => $password } ); |
167 |
. "/password" => json => { |
|
|
168 |
password => $new_password, |
169 |
password_repeated => $new_password, |
170 |
old_password => $password |
171 |
} |
172 |
); |
163 |
|
173 |
|
164 |
$tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); |
174 |
$tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); |
165 |
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); |
175 |
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); |
Lines 169-178
subtest 'set_public() (unprivileged user tests)' => sub {
Link Here
|
169 |
error => "Changing other patron's password is forbidden" |
179 |
error => "Changing other patron's password is forbidden" |
170 |
}); |
180 |
}); |
171 |
|
181 |
|
172 |
$tx |
182 |
$tx = $t->ua->build_tx( |
173 |
= $t->ua->build_tx( POST => "/api/v1/public/patrons/" |
183 |
POST => "/api/v1/public/patrons/" |
174 |
. $patron->id |
184 |
. $patron->id |
175 |
. "/password" => json => { password => $new_password, password_2 => 'wrong_password', old_password => $password } ); |
185 |
. "/password" => json => { |
|
|
186 |
password => $new_password, |
187 |
password_repeated => 'wrong_password', |
188 |
old_password => $password |
189 |
} |
190 |
); |
176 |
|
191 |
|
177 |
$tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); |
192 |
$tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); |
178 |
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); |
193 |
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); |
Lines 182-191
subtest 'set_public() (unprivileged user tests)' => sub {
Link Here
|
182 |
error => "Passwords don't match" |
197 |
error => "Passwords don't match" |
183 |
}); |
198 |
}); |
184 |
|
199 |
|
185 |
$tx |
200 |
$tx = $t->ua->build_tx( |
186 |
= $t->ua->build_tx( POST => "/api/v1/public/patrons/" |
201 |
POST => "/api/v1/public/patrons/" |
187 |
. $patron->id |
202 |
. $patron->id |
188 |
. "/password" => json => { password => $new_password, password_2 => $new_password, old_password => 'badpassword' } ); |
203 |
. "/password" => json => { |
|
|
204 |
password => $new_password, |
205 |
password_repeated => $new_password, |
206 |
old_password => 'badpassword' |
207 |
} |
208 |
); |
189 |
|
209 |
|
190 |
$tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); |
210 |
$tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); |
191 |
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); |
211 |
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); |
Lines 195-204
subtest 'set_public() (unprivileged user tests)' => sub {
Link Here
|
195 |
error => "Invalid password" |
215 |
error => "Invalid password" |
196 |
}); |
216 |
}); |
197 |
|
217 |
|
198 |
$tx |
218 |
$tx = $t->ua->build_tx( |
199 |
= $t->ua->build_tx( POST => "/api/v1/public/patrons/" |
219 |
POST => "/api/v1/public/patrons/" |
200 |
. $patron->id |
220 |
. $patron->id |
201 |
. "/password" => json => { password => $new_password, password_2 => $new_password, old_password => $password } ); |
221 |
. "/password" => json => { |
|
|
222 |
password => $new_password, |
223 |
password_repeated => $new_password, |
224 |
old_password => $password |
225 |
} |
226 |
); |
202 |
|
227 |
|
203 |
$tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); |
228 |
$tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); |
204 |
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); |
229 |
$tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); |
205 |
- |
|
|