From 390028847495f5ad8d24d10eee77fdadaffe72d5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 14 Aug 2019 14:56:48 -0400 Subject: [PATCH] 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 Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- opac/tracklinks.pl | 3 ++- t/db_dependent/www/regressions.t | 10 +++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/opac/tracklinks.pl b/opac/tracklinks.pl index 26b8a12a87..809037ad4e 100755 --- a/opac/tracklinks.pl +++ b/opac/tracklinks.pl @@ -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; diff --git a/t/db_dependent/www/regressions.t b/t/db_dependent/www/regressions.t index 788e1bb13b..4d9a1e06a9 100644 --- a/t/db_dependent/www/regressions.t +++ b/t/db_dependent/www/regressions.t @@ -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; }; -- 2.39.5