Bugzilla – Attachment 138163 Details for
Bug 30588
Add the option to require 2FA setup on first staff login
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30588: Adjust existing selenium tests
Bug-30588-Adjust-existing-selenium-tests.patch (text/plain), 5.41 KB, created by
Jonathan Druart
on 2022-07-27 08:05:31 UTC
(
hide
)
Description:
Bug 30588: Adjust existing selenium tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-07-27 08:05:31 UTC
Size:
5.41 KB
patch
obsolete
>From 815a8a00f7253fa67711609b589beec73cbcee05 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 26 Jul 2022 14:34:56 +0200 >Subject: [PATCH] Bug 30588: Adjust existing selenium tests > >Sponsored-by: Rijksmuseum, Netherlands >--- > t/db_dependent/selenium/authentication_2fa.t | 66 ++++++++++++++++---- > 1 file changed, 53 insertions(+), 13 deletions(-) > >diff --git a/t/db_dependent/selenium/authentication_2fa.t b/t/db_dependent/selenium/authentication_2fa.t >index c48b8b1ffa2..a917e191f86 100755 >--- a/t/db_dependent/selenium/authentication_2fa.t >+++ b/t/db_dependent/selenium/authentication_2fa.t >@@ -46,7 +46,7 @@ SKIP: { > my $driver = $s->driver; > > subtest 'Setup' => sub { >- plan tests => 10; >+ plan tests => 12; > > my $mainpage = $s->base_url . q|mainpage.pl|; > $driver->get($mainpage); >@@ -63,22 +63,50 @@ SKIP: { > $driver->get($s->base_url . q|members/two_factor_auth.pl|); > like( $driver->get_title, qr(Two-factor authentication), 'Must be on the page with the pref on' ); > >- is( $driver->find_element('//div[@class="two-factor-status"]')->get_text(), 'Status: Disabled', '2FA is disabled' ); >+ is( >+ $driver->find_element( '//div[@id="registration-status-disabled"]/div[@class="two-factor-status"]' )->get_text, >+ 'Status: Disabled', >+ '2FA is disabled' >+ ); > >- $driver->find_element('//form[@id="two-factor-auth"]//input[@type="submit"]')->click; >+ is( >+ $driver->find_element( '//div[@id="registration-status-enabled"]/div[@class="two-factor-status"]' )->get_text, >+ '', # 'Status: Enabled' is not shown >+ '2FA is disabled' >+ ); >+ >+ $driver->find_element('//*[@id="enable-2FA"]')->click; >+ $s->wait_for_ajax; > ok($driver->find_element('//img[@id="qr_code"]'), 'There is a QR code'); > >- $s->fill_form({pin_code => 'wrong_code'}); >- $s->submit_form; >+ $driver->find_element('//*[@id="pin_code"]')->send_keys('wrong_code'); >+ $driver->find_element('//*[@id="register-2FA"]')->click; >+ $s->wait_for_ajax; > ok($driver->find_element('//div[@class="dialog error"][contains(text(), "Invalid PIN code")]')); > is( $patron->get_from_storage->secret, undef, 'secret is not set in DB yet' ); > >- my $secret32 = $driver->find_element('//form[@id="two-factor-auth"]//input[@name="secret32"]')->get_value(); >+ my $secret32 = $driver->find_element('//*[@id="secret32"]')->get_value(); > my $auth = Koha::Auth::TwoFactorAuth->new({patron => $patron, secret32 => $secret32}); > my $code = $auth->code(); >- $s->fill_form({pin_code => $code}); >- $s->submit_form; >- is( $driver->find_element('//div[@class="two-factor-status"]')->get_text(), 'Status: Enabled', '2FA is enabled' ); >+ $driver->find_element('//*[@id="pin_code"]')->clear; >+ $driver->find_element('//*[@id="pin_code"]')->send_keys($code); >+ $driver->find_element('//*[@id="register-2FA"]')->click; >+ # Wait for the response then go to the page, don't wait for the redirect >+ $s->wait_for_ajax; >+ $driver->capture_screenshot('selenium_failure_2.png'); >+ $driver->get($s->base_url . q|members/two_factor_auth.pl|); >+ is( >+ $driver->find_element( '//div[@id="registration-status-disabled"]/div[@class="two-factor-status"]' )->get_text, >+ '', # 'Status: Disabled' is not shown >+ '2FA is enabled' >+ ); >+ >+ is( >+ $driver->find_element( '//div[@id="registration-status-enabled"]/div[@class="two-factor-status"]' )->get_text, >+ 'Status: Enabled', >+ '2FA is enabled' >+ ); >+ > $patron = $patron->get_from_storage; > is( $patron->decoded_secret, $secret32, 'encrypted secret is set in DB' ); > >@@ -202,7 +230,7 @@ SKIP: { > }; > > subtest "Disable" => sub { >- plan tests => 4; >+ plan tests => 6; > > my $mainpage = $s->base_url . q|mainpage.pl|; > $driver->get( $mainpage . q|?logout.x=1| ); >@@ -217,7 +245,13 @@ SKIP: { > $driver->get( $s->base_url . q|members/two_factor_auth.pl| ); > > is( >- $driver->find_element('//div[@class="two-factor-status"]')->get_text(), >+ $driver->find_element( '//div[@id="registration-status-disabled"]/div[@class="two-factor-status"]' )->get_text, >+ '', # 'Status: Disabled' is not shown >+ '2FA is enabled' >+ ); >+ >+ is( >+ $driver->find_element( '//div[@id="registration-status-enabled"]/div[@class="two-factor-status"]' )->get_text, > 'Status: Enabled', > '2FA is enabled' > ); >@@ -225,9 +259,15 @@ SKIP: { > $driver->find_element('//form[@id="two-factor-auth"]//input[@type="submit"]')->click; > > is( >- $driver->find_element('//div[@class="two-factor-status"]')->get_text(), >+ $driver->find_element( '//div[@id="registration-status-disabled"]/div[@class="two-factor-status"]' )->get_text, > 'Status: Disabled', >- '2FA has been disabled' >+ '2FA is disabled' >+ ); >+ >+ is( >+ $driver->find_element( '//div[@id="registration-status-enabled"]/div[@class="two-factor-status"]' )->get_text, >+ '', # 'Status: Enabled' is not shown >+ '2FA is disabled' > ); > > $patron = $patron->get_from_storage; >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30588
:
138160
|
138161
|
138162
|
138163
|
138164
|
138165
|
138166
|
138191
|
138193
|
138953
|
138954
|
138955
|
138956
|
138957
|
138958
|
138959
|
138960
|
138961
|
138962
|
140365
|
140366
|
140367
|
140368
|
140369
|
140416
|
140417
|
140418
|
140419
|
140420
|
140421
|
140422
|
140423
|
140424
|
140425
|
140426
|
140427
|
140428
|
140429
|
140430
|
141978
|
141979
|
141980
|
141981
|
141982
|
141983
|
141984
|
141985
|
141986
|
141987
|
141988
|
141989
|
141990
|
141991
|
141992
|
142344
|
142345
|
142346
|
142347
|
142348
|
142349
|
142350
|
142351
|
142352
|
142353
|
142354
|
142355
|
142356
|
142357
|
142358