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