From 79f57cf303924ef96b8b55169e0290ef15dd3835 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 5 May 2022 08:39:50 -0300 Subject: [PATCH] Bug 28998: (QA follow-up) Silence some useless warnings This patch fixes the tests and also silences some useless warnings about REMOTE_ADDRESS not being defined. A test is added for a legit warning that is thrown. Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Auth.t | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t index 0ec2570bb9..46ad64ecff 100755 --- a/t/db_dependent/Auth.t +++ b/t/db_dependent/Auth.t @@ -35,6 +35,9 @@ my $dbh = C4::Context->dbh; t::lib::Mocks::mock_preference( 'SessionStorage', 'tmp' ); t::lib::Mocks::mock_preference( 'GDPR_Policy', '' ); # Disabled +# To silence useless warnings +$ENV{REMOTE_ADDR} = '127.0.0.1'; + $schema->storage->txn_begin; subtest 'checkauth() tests' => sub { @@ -148,7 +151,7 @@ subtest 'checkauth() tests' => sub { } t::lib::Mocks::mock_preference( 'TwoFactorAuthentication', 0 ); - $patron->secret('one_secret'); + $patron->encode_secret('one_secret'); $patron->auth_method('password'); $patron->store; ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired', undef, 'intranet' ); @@ -509,7 +512,8 @@ subtest 'Check value of login_attempts in checkpw' => sub { }; subtest '_timeout_syspref' => sub { - plan tests => 5; + + plan tests => 6; t::lib::Mocks::mock_preference('timeout', "100"); is( C4::Auth::_timeout_syspref, 100, ); @@ -524,7 +528,10 @@ subtest '_timeout_syspref' => sub { is( C4::Auth::_timeout_syspref, 10*3600, ); t::lib::Mocks::mock_preference('timeout', "10x"); - is( C4::Auth::_timeout_syspref, 600, ); + warning_is + { is( C4::Auth::_timeout_syspref, 600, ); } + "The value of the system preference 'timeout' is not correct, defaulting to 600", + 'Bad values throw a warning and fallback to 600'; }; subtest 'check_cookie_auth' => sub { -- 2.39.5