From b36720135b50fbbe324a364f69de0d93be49b432 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 15 Aug 2019 08:54:59 +0100 Subject: [PATCH] Bug 23329: (RM follow-up) Restore DB after test Test plan: 1) Dump your DB before the tests is run 2) Run the test 3) Dumper your DB again and compare to the first dump Success if there are no differences (other than the timestamp of the dump) Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- t/db_dependent/www/regressions.t | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/t/db_dependent/www/regressions.t b/t/db_dependent/www/regressions.t index 4d9a1e06a9..521a1204aa 100644 --- a/t/db_dependent/www/regressions.t +++ b/t/db_dependent/www/regressions.t @@ -33,6 +33,14 @@ my $intranet = $ENV{KOHA_INTRANET_URL} || C4::Context->preference("staffClientBaseURL"); my $opac = $ENV{KOHA_OPAC_URL} || C4::Context->preference("OPACBaseURL"); +my $context = C4::Context->new(); +my $db_name = $context->config("database"); +my $db_host = $context->config("hostname"); +my $db_port = $context->config("port") || ''; +my $db_user = $context->config("user"); +my $db_passwd = $context->config("pass"); +`mysqldump --add-drop-table -u $db_user --password="$db_passwd" -h $db_host -P $db_port $db_name > dumpfile.sql`; + my $t = Test::Mojo->new(); my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; @@ -131,3 +139,6 @@ subtest 'open redirection vulnerabilities in tracklinks' => sub { $t->get_ok( $opac . $good_itemnumber ) ->status_is( 302, "302 for itemnumber with matching URI" ); }; + +`mysql -u $db_user --password="$db_passwd" -h $db_host -P $db_port --database="$db_name" < dumpfile.sql`; +`rm dumpfile.sql`; -- 2.20.1