From 8f0cb797904af5882c679e9b2769fbb20b584271 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 10 Sep 2021 11:27:33 +0200 Subject: [PATCH] Bug 28998: Adjust Selenium test Content-Type: text/plain; charset=utf-8 Test plan: Run t/db_dependent/selenium/authentication_2fa.t Signed-off-by: Marcel de Rooy --- t/db_dependent/selenium/authentication_2fa.t | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/selenium/authentication_2fa.t b/t/db_dependent/selenium/authentication_2fa.t index ebc0c7f991..6fc42228e7 100755 --- a/t/db_dependent/selenium/authentication_2fa.t +++ b/t/db_dependent/selenium/authentication_2fa.t @@ -21,6 +21,7 @@ use Test::More tests => 2; use C4::Context; use Koha::AuthUtils; use Koha::Auth::TwoFactorAuth; +use Koha::Encryption; use t::lib::Mocks; use t::lib::Selenium; use t::lib::TestBuilder; @@ -80,7 +81,7 @@ SKIP: { $s->submit_form; is( $driver->find_element('//div[@class="two-factor-status"]')->get_text(), 'Status: Enabled', '2FA is enabled' ); $patron = $patron->get_from_storage; - is( $patron->secret, $secret32, 'secret is set in DB' ); + is( Koha::Encryption->new->decrypt_hex($patron->secret), $secret32, 'encrypted secret is set in DB' ); }; @@ -89,6 +90,7 @@ SKIP: { my $mainpage = $s->base_url . q|mainpage.pl|; + my $secret32 = Koha::Encryption->new->decrypt_hex($patron->secret); { # ok first try $driver->get($mainpage . q|?logout.x=1|); $driver->get($s->base_url . q|circ/circulation.pl?borrowernumber=|.$patron->borrowernumber); @@ -98,7 +100,8 @@ SKIP: { like( $driver->get_title, qr(Two-factor authentication), 'Must be on the second auth screen' ); is( login_error($s), undef ); - my $auth = Koha::Auth::TwoFactorAuth->new({patron => $patron}); + my $auth = Koha::Auth::TwoFactorAuth->new( + { patron => $patron, secret32 => $secret32 } ); my $code = $auth->code(); $auth->clear; $driver->find_element('//form[@id="loginform"]//input[@id="otp_token"]')->send_keys($code); @@ -139,7 +142,8 @@ SKIP: { $driver->find_element('//input[@type="submit"]')->click; ok($driver->find_element('//div[@class="dialog error"][contains(text(), "Invalid two-factor code")]')); - my $auth = Koha::Auth::TwoFactorAuth->new({patron => $patron}); + my $auth = Koha::Auth::TwoFactorAuth->new( + { patron => $patron, secret32 => $secret32 } ); my $code = $auth->code(); $auth->clear; $driver->find_element('//form[@id="loginform"]//input[@id="otp_token"]')->send_keys($code); -- 2.20.1