Lines 43-49
my $remote_address = '127.0.0.1';
Link Here
|
43 |
my $t = Test::Mojo->new('Koha::REST::V1'); |
43 |
my $t = Test::Mojo->new('Koha::REST::V1'); |
44 |
|
44 |
|
45 |
subtest 'recovery() tests' => sub { |
45 |
subtest 'recovery() tests' => sub { |
46 |
plan tests => 29; |
46 |
plan tests => 31; |
47 |
|
47 |
|
48 |
$schema->storage->txn_begin; |
48 |
$schema->storage->txn_begin; |
49 |
|
49 |
|
Lines 143-148
subtest 'recovery() tests' => sub {
Link Here
|
143 |
'Password modification request found in database' |
143 |
'Password modification request found in database' |
144 |
); |
144 |
); |
145 |
|
145 |
|
|
|
146 |
my $notice_content = Koha::Notice::Messages->search({ |
147 |
borrowernumber => $patron->borrowernumber, |
148 |
letter_code => 'PASSWORD_RESET', |
149 |
message_transport_type => 'email' |
150 |
}, { |
151 |
order_by => { '-desc' => 'message_id' } |
152 |
})->next->content; |
153 |
like($notice_content, |
154 |
qr/cgi-bin\/koha\/opac-password-recovery\.pl\?uniqueKey=/, |
155 |
'Found Koha OPAC link in email' |
156 |
); |
157 |
|
146 |
$tx = $t->ua->build_tx(POST => $url => json => { |
158 |
$tx = $t->ua->build_tx(POST => $url => json => { |
147 |
email => $patron->email, |
159 |
email => $patron->email, |
148 |
userid => $patron->userid |
160 |
userid => $patron->userid |
Lines 181-186
subtest 'recovery() tests' => sub {
Link Here
|
181 |
})->count; |
193 |
})->count; |
182 |
is($notice, 3, 'Found password reset letters in message queue.'); |
194 |
is($notice, 3, 'Found password reset letters in message queue.'); |
183 |
|
195 |
|
|
|
196 |
subtest 'custom reset link' => sub { |
197 |
plan tests => 5; |
198 |
|
199 |
t::lib::Mocks::mock_preference( |
200 |
'OpacResetPasswordHostWhitelist', '' |
201 |
); |
202 |
|
203 |
$tx = $t->ua->build_tx(POST => $url => json => { |
204 |
email => $patron->email, |
205 |
userid => $patron->userid, |
206 |
custom_link => 'https://notallowed' |
207 |
}); |
208 |
$tx->req->cookies({name => 'CGISESSID', value => $session->id}); |
209 |
$tx->req->env({REMOTE_ADDR => '127.0.0.1'}); |
210 |
$t->request_ok($tx) |
211 |
->status_is(400); |
212 |
|
213 |
t::lib::Mocks::mock_preference( |
214 |
'OpacResetPasswordHostWhitelist', 'allowed' |
215 |
); |
216 |
|
217 |
$tx = $t->ua->build_tx(POST => $url => json => { |
218 |
email => $patron->email, |
219 |
userid => $patron->userid, |
220 |
custom_link => 'https://allowed/reset-password.pl?uniqueKey={uuid}' |
221 |
}); |
222 |
$tx->req->cookies({name => 'CGISESSID', value => $session->id}); |
223 |
$tx->req->env({REMOTE_ADDR => '127.0.0.1'}); |
224 |
$t->request_ok($tx) |
225 |
->status_is(201); |
226 |
|
227 |
my $rs = Koha::Database->new->schema->resultset('BorrowerPasswordRecovery'); |
228 |
my $uuid = quotemeta $rs->search({ |
229 |
borrowernumber => $patron->borrowernumber |
230 |
}, { |
231 |
order_by => { '-desc' => 'valid_until' } |
232 |
})->next->uuid; |
233 |
my $notice_to_external_service = Koha::Notice::Messages->search({ |
234 |
borrowernumber => $patron->borrowernumber, |
235 |
letter_code => 'PASSWORD_RESET', |
236 |
message_transport_type => 'email' |
237 |
}, { |
238 |
order_by => { '-desc' => 'message_id' } |
239 |
})->next; |
240 |
my $content = $notice_to_external_service->content; |
241 |
like( |
242 |
$content, |
243 |
qr/https:\/\/allowed\/reset-password\.pl\?uniqueKey=$uuid/, |
244 |
'Found custom link in email' |
245 |
); |
246 |
}; |
247 |
|
184 |
$schema->storage->txn_rollback; |
248 |
$schema->storage->txn_rollback; |
185 |
}; |
249 |
}; |
186 |
|
250 |
|
187 |
- |
|
|