Lines 42-51
subtest 'new' => sub {
Link Here
|
42 |
'Croaked on wrong encoding'; |
42 |
'Croaked on wrong encoding'; |
43 |
|
43 |
|
44 |
# Test passing secret or secret32 (converted to base32) |
44 |
# Test passing secret or secret32 (converted to base32) |
45 |
$patron->secret('nv4v65dpobpxgzldojsxiii'); # this is base32 already for 'my_top_secret!' |
45 |
$patron->encode_secret('nv4v65dpobpxgzldojsxiii'); # this is base32 already for 'my_top_secret!' |
46 |
my $auth = Koha::Auth::TwoFactorAuth->new({ patron => $patron }); |
46 |
my $auth = Koha::Auth::TwoFactorAuth->new({ patron => $patron }); |
47 |
is( $auth->secret32, $patron->secret, 'Base32 secret as expected' ); |
47 |
is( $auth->secret32, $patron->decoded_secret, 'Base32 secret as expected' ); |
48 |
$auth->code( $patron->secret ); # trigger conversion by passing base32 to code |
48 |
$auth->code( $patron->decoded_secret ); # trigger conversion by passing base32 to code |
49 |
is( $auth->secret, 'my_top_secret!', 'Decoded secret fine too' ); |
49 |
is( $auth->secret, 'my_top_secret!', 'Decoded secret fine too' ); |
50 |
# The other way around |
50 |
# The other way around |
51 |
$auth = Koha::Auth::TwoFactorAuth->new({ patron => $patron, secret => 'my_top_secret!' }); |
51 |
$auth = Koha::Auth::TwoFactorAuth->new({ patron => $patron, secret => 'my_top_secret!' }); |
Lines 64-70
subtest 'qr_code' => sub {
Link Here
|
64 |
|
64 |
|
65 |
t::lib::Mocks::mock_preference('TwoFactorAuthentication', 1); |
65 |
t::lib::Mocks::mock_preference('TwoFactorAuthentication', 1); |
66 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
66 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
67 |
$patron->secret('you2wont2guess2it'); # this is base32 btw |
67 |
$patron->encode_secret('you2wont2guess2it'); # this is base32 btw |
68 |
$patron->auth_method('two-factor'); |
68 |
$patron->auth_method('two-factor'); |
69 |
$patron->store; |
69 |
$patron->store; |
70 |
|
70 |
|
Lines 76-82
subtest 'qr_code' => sub {
Link Here
|
76 |
$auth->clear; |
76 |
$auth->clear; |
77 |
|
77 |
|
78 |
# Changing the secret should generate different data, right? |
78 |
# Changing the secret should generate different data, right? |
79 |
$patron->secret('no3really3not3cracked'); # base32 |
79 |
$patron->encode_secret('no3really3not3cracked'); # base32 |
80 |
$patron->store; |
80 |
$patron->store; |
81 |
$auth = Koha::Auth::TwoFactorAuth->new({ patron => $patron }); |
81 |
$auth = Koha::Auth::TwoFactorAuth->new({ patron => $patron }); |
82 |
my $img_data02 = $auth->qr_code; |
82 |
my $img_data02 = $auth->qr_code; |
83 |
- |
|
|