Bug 23329: Fix tests
- www.google.com vs https://www.google.com - Remove transaction otherwise data are not available from webserver - Use new C4::Output::output_error to avoid 302 (redirect) Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
7fa1cde78e
commit
20854939b4
2 changed files with 5 additions and 8 deletions
|
@ -22,6 +22,7 @@ use Modern::Perl;
|
|||
use C4::Context;
|
||||
use C4::Auth qw(checkauth);
|
||||
use C4::Biblio;
|
||||
use C4::Output;
|
||||
use Koha::Items;
|
||||
use Koha::Linktracker;
|
||||
use CGI qw ( -utf8 );
|
||||
|
@ -78,5 +79,5 @@ if ($uri && ($biblionumber || $itemnumber) ) {
|
|||
}
|
||||
}
|
||||
|
||||
print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
|
||||
output_error( $cgi, '404' );
|
||||
exit;
|
||||
|
|
|
@ -38,9 +38,7 @@ my $schema = Koha::Database->new->schema;
|
|||
my $builder = t::lib::TestBuilder->new;
|
||||
|
||||
subtest 'open redirection vulnerabilities in tracklinks' => sub {
|
||||
plan tests => 30;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
plan tests => 36;
|
||||
|
||||
# No URI's
|
||||
my $biblio = $builder->build_sample_biblio();
|
||||
|
@ -58,12 +56,12 @@ subtest 'open redirection vulnerabilities in tracklinks' => sub {
|
|||
$biblio = $builder->build_sample_biblio();
|
||||
my $biblionumber3 = $biblio->biblionumber;
|
||||
$record = $biblio->metadata->record;
|
||||
$new856 = MARC::Field->new( '856', '', '', u => "www.google.com" );
|
||||
$new856 = MARC::Field->new( '856', '', '', u => "http://www.google.com" );
|
||||
$record->insert_fields_ordered($new856);
|
||||
C4::Biblio::ModBiblio( $record, $biblionumber3 );
|
||||
|
||||
# URI at Item level
|
||||
my $item = $builder->build_sample_item( { uri => 'www.google.com' } );
|
||||
my $item = $builder->build_sample_item( { uri => 'http://www.google.com' } );
|
||||
my $itemnumber1 = $item->itemnumber;
|
||||
|
||||
# Incorrect URI at Item level
|
||||
|
@ -132,6 +130,4 @@ subtest 'open redirection vulnerabilities in tracklinks' => sub {
|
|||
->status_is( 404, "404 for itemnumber containing different URI" );
|
||||
$t->get_ok( $opac . $good_itemnumber )
|
||||
->status_is( 302, "302 for itemnumber with matching URI" );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue