Bugzilla – Attachment 129539 Details for
Bug 29894
2FA: Add few validations, clear secret, send register notice
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29894: First draft for testing
Bug-29894-First-draft-for-testing.patch (text/plain), 2.67 KB, created by
Marcel de Rooy
on 2022-01-17 15:30:52 UTC
(
hide
)
Description:
Bug 29894: First draft for testing
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-01-17 15:30:52 UTC
Size:
2.67 KB
patch
obsolete
>From e290dc346e861e4e1cc8166cc30d4a193496d796 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 17 Jan 2022 15:30:14 +0000 >Subject: [PATCH] Bug 29894: First draft for testing >Content-Type: text/plain; charset=utf-8 > >--- > t/db_dependent/Koha/Auth/TwoFactorAuth.t | 74 ++++++++++++++++++++++++ > 1 file changed, 74 insertions(+) > create mode 100644 t/db_dependent/Koha/Auth/TwoFactorAuth.t > >diff --git a/t/db_dependent/Koha/Auth/TwoFactorAuth.t b/t/db_dependent/Koha/Auth/TwoFactorAuth.t >new file mode 100644 >index 0000000000..2e6912621e >--- /dev/null >+++ b/t/db_dependent/Koha/Auth/TwoFactorAuth.t >@@ -0,0 +1,74 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use Test::More tests => 1; >+use Test::Exception; >+ >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+#use C4::Context; >+use Koha::Database; >+#use Koha::AuthUtils; >+use Koha::Auth::TwoFactorAuth; >+ >+our $schema = Koha::Database->new->schema; >+our $builder = t::lib::TestBuilder->new; >+ >+subtest 'new' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_preference('TwoFactorAuthentication', 1); >+ >+ # Trivial test: no patron, no object >+ throws_ok { Koha::Auth::TwoFactorAuth->new; } >+ 'Koha::Exceptions::MissingParameter', >+ 'Croaked on missing patron'; >+ throws_ok { Koha::Auth::TwoFactorAuth->new({ patron => 'Henk', secret => q<> }) } >+ 'Koha::Exceptions::MissingParameter', >+ 'Croaked on missing patron object'; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ $patron->auth_method('two-factor'); >+ $patron->secret(''); >+ $patron->store; >+ >+ >+ throws_ok { Koha::Auth::TwoFactorAuth->new({ patron => $patron }) } >+ 'Koha::Exceptions::MissingParameter', >+ 'Croaked on missing secret'; >+ >+ >+ >+ >+ >+ >+ >+ >+ >+# my $cgi = Test::MockObject->new; >+# $cgi->mock( 'param', sub { return 2; } ); >+# my $auth = Test::MockModule->new( 'C4::Auth' ); >+# $auth->mock( 'checkauth', \&MockedCheckauth ); >+ >+ >+ >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.20.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 29894
:
129538
|
129539
|
129669
|
129670
|
129689
|
129690
|
129691
|
129692
|
133286
|
133287
|
133288
|
133289
|
133562
|
133563
|
133564
|
133565
|
133566
|
133618
|
133661
|
133662
|
133663
|
133664
|
133665
|
133666
|
133667