Lines 21-26
use Test::More tests => 2;
Link Here
|
21 |
use C4::Context; |
21 |
use C4::Context; |
22 |
use Koha::AuthUtils; |
22 |
use Koha::AuthUtils; |
23 |
use Koha::Auth::TwoFactorAuth; |
23 |
use Koha::Auth::TwoFactorAuth; |
|
|
24 |
use Koha::Encryption; |
24 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
25 |
use t::lib::Selenium; |
26 |
use t::lib::Selenium; |
26 |
use t::lib::TestBuilder; |
27 |
use t::lib::TestBuilder; |
Lines 80-86
SKIP: {
Link Here
|
80 |
$s->submit_form; |
81 |
$s->submit_form; |
81 |
is( $driver->find_element('//div[@class="two-factor-status"]')->get_text(), 'Status: Enabled', '2FA is enabled' ); |
82 |
is( $driver->find_element('//div[@class="two-factor-status"]')->get_text(), 'Status: Enabled', '2FA is enabled' ); |
82 |
$patron = $patron->get_from_storage; |
83 |
$patron = $patron->get_from_storage; |
83 |
is( $patron->secret, $secret32, 'secret is set in DB' ); |
84 |
is( Koha::Encryption->new->decrypt_hex($patron->secret), $secret32, 'encrypted secret is set in DB' ); |
84 |
|
85 |
|
85 |
}; |
86 |
}; |
86 |
|
87 |
|
Lines 89-94
SKIP: {
Link Here
|
89 |
|
90 |
|
90 |
my $mainpage = $s->base_url . q|mainpage.pl|; |
91 |
my $mainpage = $s->base_url . q|mainpage.pl|; |
91 |
|
92 |
|
|
|
93 |
my $secret32 = Koha::Encryption->new->decrypt_hex($patron->secret); |
92 |
{ # ok first try |
94 |
{ # ok first try |
93 |
$driver->get($mainpage . q|?logout.x=1|); |
95 |
$driver->get($mainpage . q|?logout.x=1|); |
94 |
$driver->get($s->base_url . q|circ/circulation.pl?borrowernumber=|.$patron->borrowernumber); |
96 |
$driver->get($s->base_url . q|circ/circulation.pl?borrowernumber=|.$patron->borrowernumber); |
Lines 98-104
SKIP: {
Link Here
|
98 |
like( $driver->get_title, qr(Two-factor authentication), 'Must be on the second auth screen' ); |
100 |
like( $driver->get_title, qr(Two-factor authentication), 'Must be on the second auth screen' ); |
99 |
is( login_error($s), undef ); |
101 |
is( login_error($s), undef ); |
100 |
|
102 |
|
101 |
my $auth = Koha::Auth::TwoFactorAuth->new({patron => $patron}); |
103 |
my $auth = Koha::Auth::TwoFactorAuth->new( |
|
|
104 |
{ patron => $patron, secret32 => $secret32 } ); |
102 |
my $code = $auth->code(); |
105 |
my $code = $auth->code(); |
103 |
$auth->clear; |
106 |
$auth->clear; |
104 |
$driver->find_element('//form[@id="loginform"]//input[@id="otp_token"]')->send_keys($code); |
107 |
$driver->find_element('//form[@id="loginform"]//input[@id="otp_token"]')->send_keys($code); |
Lines 139-145
SKIP: {
Link Here
|
139 |
$driver->find_element('//input[@type="submit"]')->click; |
142 |
$driver->find_element('//input[@type="submit"]')->click; |
140 |
ok($driver->find_element('//div[@class="dialog error"][contains(text(), "Invalid two-factor code")]')); |
143 |
ok($driver->find_element('//div[@class="dialog error"][contains(text(), "Invalid two-factor code")]')); |
141 |
|
144 |
|
142 |
my $auth = Koha::Auth::TwoFactorAuth->new({patron => $patron}); |
145 |
my $auth = Koha::Auth::TwoFactorAuth->new( |
|
|
146 |
{ patron => $patron, secret32 => $secret32 } ); |
143 |
my $code = $auth->code(); |
147 |
my $code = $auth->code(); |
144 |
$auth->clear; |
148 |
$auth->clear; |
145 |
$driver->find_element('//form[@id="loginform"]//input[@id="otp_token"]')->send_keys($code); |
149 |
$driver->find_element('//form[@id="loginform"]//input[@id="otp_token"]')->send_keys($code); |
146 |
- |
|
|