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