Lines 16-25
Link Here
|
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
|
|
19 |
use utf8; |
19 |
|
20 |
|
20 |
use C4::Context; |
21 |
use C4::Context; |
21 |
|
22 |
|
22 |
use Test::More tests => 6; |
23 |
use Test::More tests => 7; |
23 |
use Test::MockModule; |
24 |
use Test::MockModule; |
24 |
|
25 |
|
25 |
use C4::Context; |
26 |
use C4::Context; |
Lines 32-38
use t::lib::TestBuilder;
Link Here
|
32 |
use t::lib::Mocks; |
33 |
use t::lib::Mocks; |
33 |
|
34 |
|
34 |
eval { require Selenium::Remote::Driver; }; |
35 |
eval { require Selenium::Remote::Driver; }; |
35 |
skip "Selenium::Remote::Driver is needed for selenium tests.", 1 if $@; |
36 |
skip "Selenium::Remote::Driver is needed for selenium tests.", 7 if $@; |
36 |
|
37 |
|
37 |
my $s = t::lib::Selenium->new; |
38 |
my $s = t::lib::Selenium->new; |
38 |
|
39 |
|
Lines 254-262
subtest 'XSS vulnerabilities in pagination' => sub {
Link Here
|
254 |
|
255 |
|
255 |
push @cleanup, $patron, $patron->category, $patron->library; |
256 |
push @cleanup, $patron, $patron->category, $patron->library; |
256 |
|
257 |
|
257 |
$driver->quit(); |
|
|
258 |
}; |
258 |
}; |
259 |
|
259 |
|
|
|
260 |
subtest 'Encoding in session variables' => sub { |
261 |
plan tests => 18; |
262 |
|
263 |
my $builder = t::lib::TestBuilder->new; |
264 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
265 |
my $patron = $builder->build_object( |
266 |
{ |
267 |
class => 'Koha::Patrons', |
268 |
value => { branchcode => $library->branchcode, flags => 0 } |
269 |
} |
270 |
); |
271 |
|
272 |
my $biblio = $builder->build_sample_biblio; |
273 |
my $item = $builder->build_sample_item( |
274 |
{ |
275 |
biblionumber => $biblio->biblionumber, |
276 |
library => $library->branchcode, |
277 |
} |
278 |
); |
279 |
|
280 |
my $original_SessionStorage = C4::Context->preference('SessionStorage'); |
281 |
for my $SessionStorage ( qw( memcached mysql tmp ) ) { |
282 |
C4::Context->set_preference( 'SessionStorage', $SessionStorage ); |
283 |
for my $branchname (qw( Test1 Test2❤️ Test3ä )) { |
284 |
my $library = |
285 |
Koha::Libraries->find($branchname) || $builder->build_object( |
286 |
{ |
287 |
class => 'Koha::Libraries', |
288 |
value => { |
289 |
branchcode => $branchname, |
290 |
branchname => $branchname, |
291 |
} |
292 |
} |
293 |
); |
294 |
# Make sure we are logged in |
295 |
$driver->get( $base_url . q|mainpage.pl?logout.x=1| ); |
296 |
$s->auth; |
297 |
# Switch to the new library |
298 |
$driver->get( $base_url . 'circ/set-library.pl' ); |
299 |
$s->fill_form( { branch => $branchname } ); |
300 |
$s->submit_form; |
301 |
# Check an item out |
302 |
$driver->get( $base_url |
303 |
. 'circ/circulation.pl?borrowernumber=' |
304 |
. $patron->borrowernumber ); |
305 |
# We must have the logged-in-branch-name displayed, or we got a 500 |
306 |
is( |
307 |
$driver->find_element( '//span[@class="logged-in-branch-name"]')->get_text(), |
308 |
$branchname, |
309 |
sprintf( "logged-in-branch-name set - SessionStorage=%s, branchname=%s", $SessionStorage, $branchname |
310 |
) |
311 |
); |
312 |
|
313 |
$driver->find_element('//input[@id="barcode"]')->send_keys( $item->barcode ); |
314 |
$driver->find_element('//fieldset[@id="circ_circulation_issue"]/button[@type="submit"]')->click; |
315 |
|
316 |
# Display the table clicking on the "Show checkouts" button |
317 |
$driver->find_element('//a[@id="issues-table-load-now-button"]') |
318 |
->click; |
319 |
|
320 |
my @tds = $driver->find_elements( |
321 |
'//table[@id="issues-table"]/tbody/tr[2]/td'); |
322 |
|
323 |
# Select the td for "Checked out from" (FIXME this is not robust and could be improved |
324 |
my $td_checked_out_from = $tds[8]; |
325 |
is( |
326 |
$td_checked_out_from->get_text(), |
327 |
$branchname, |
328 |
sprintf( "'Checked out from' column should contain the branchname - SessionStorage=%s, branchname=%s", $SessionStorage, $branchname ) |
329 |
); |
330 |
|
331 |
# Check the item in |
332 |
AddReturn( $item->barcode, $library->branchcode ); |
333 |
} |
334 |
} |
335 |
|
336 |
C4::Context->set_preference('SessionStorage', $original_SessionStorage); |
337 |
push @cleanup, $item, $biblio, $patron, $patron->category, $patron->library; |
338 |
|
339 |
}; |
340 |
|
341 |
$driver->quit(); |
342 |
|
260 |
END { |
343 |
END { |
261 |
C4::Context->set_preference('SearchEngine', $SearchEngine_value); |
344 |
C4::Context->set_preference('SearchEngine', $SearchEngine_value); |
262 |
C4::Context->set_preference('AudioAlerts', $AudioAlerts_value); |
345 |
C4::Context->set_preference('AudioAlerts', $AudioAlerts_value); |
263 |
- |
|
|