Bugzilla – Attachment 155355 Details for
Bug 30843
TOTP expiration delay should be configurable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30843: Add unit test for Koha::Auth::TwoFactorAuth::verify
Bug-30843-Add-unit-test-for-KohaAuthTwoFactorAuthv.patch (text/plain), 2.28 KB, created by
Marcel de Rooy
on 2023-09-08 06:31:42 UTC
(
hide
)
Description:
Bug 30843: Add unit test for Koha::Auth::TwoFactorAuth::verify
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-09-08 06:31:42 UTC
Size:
2.28 KB
patch
obsolete
>From 64867ac0e44b0d4f8995b50386b0592bc9058c7b Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Fri, 8 Sep 2023 01:53:38 +0000 >Subject: [PATCH] Bug 30843: Add unit test for > Koha::Auth::TwoFactorAuth::verify >Content-Type: text/plain; charset=utf-8 > >This change adds a unit test to test Koha::Auth::TwoFactorAuth::verify > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Koha/Auth/TwoFactorAuth.t | 35 +++++++++++++++++++++++- > 1 file changed, 34 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Auth/TwoFactorAuth.t b/t/db_dependent/Koha/Auth/TwoFactorAuth.t >index 6a82e427e0..eb50a503f7 100755 >--- a/t/db_dependent/Koha/Auth/TwoFactorAuth.t >+++ b/t/db_dependent/Koha/Auth/TwoFactorAuth.t >@@ -1,7 +1,7 @@ > #!/usr/bin/perl > > use Modern::Perl; >-use Test::More tests => 2; >+use Test::More tests => 3; > use Test::Exception; > use Test::MockModule; > >@@ -89,3 +89,36 @@ subtest 'qr_code' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'verify' => sub { >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_preference( 'TwoFactorAuthentication', 'enabled' ); >+ t::lib::Mocks::mock_config( 'encryption_key', 'bad_example' ); >+ t::lib::Mocks::mock_config( 'mfa_range', undef ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ $patron->encode_secret('6557s35ui2gyhkmuuvei6rpk44'); # this is base32 btw >+ $patron->auth_method('two-factor'); >+ $patron->store; >+ >+ my $auth = Koha::Auth::TwoFactorAuth->new( { patron => $patron } ); >+ my $code = 394342; >+ my $timestamp = 1694137671; >+ my $verified; >+ $verified = $auth->verify( $code, undef, undef, $timestamp, undef ); >+ is( $verified, 1, "code valid within 1 minute" ); >+ >+ $verified = $auth->verify( $code, undef, undef, ( $timestamp + 60 ), undef ); >+ is( $verified, 0, "code invalid within 2 minutes" ); >+ >+ t::lib::Mocks::mock_config( 'mfa_range', 10 ); >+ $verified = $auth->verify( $code, undef, undef, ( $timestamp + 300 ), undef ); >+ is( $verified, 1, "code valid within 5 minutes" ); >+ >+ $verified = $auth->verify( $code, undef, undef, ( $timestamp + 330 ), undef ); >+ is( $verified, 0, "code valid within 5.5 minutes" ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.30.2
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 30843
:
155253
|
155348
|
155349
|
155354
|
155355
|
155356
|
155357