View | Details | Raw Unified | Return to bug 29894
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Auth/TwoFactorAuth.t (-1 / +74 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
use Test::More tests => 1;
20
use Test::Exception;
21
22
use t::lib::Mocks;
23
use t::lib::TestBuilder;
24
25
#use C4::Context;
26
use Koha::Database;
27
#use Koha::AuthUtils;
28
use Koha::Auth::TwoFactorAuth;
29
30
our $schema = Koha::Database->new->schema;
31
our $builder  = t::lib::TestBuilder->new;
32
33
subtest 'new' => sub {
34
    plan tests => 3;
35
    $schema->storage->txn_begin;
36
37
    t::lib::Mocks::mock_preference('TwoFactorAuthentication', 1);
38
39
    # Trivial test: no patron, no object
40
    throws_ok { Koha::Auth::TwoFactorAuth->new; }
41
        'Koha::Exceptions::MissingParameter',
42
        'Croaked on missing patron';
43
    throws_ok { Koha::Auth::TwoFactorAuth->new({ patron => 'Henk', secret => q<> }) }
44
        'Koha::Exceptions::MissingParameter',
45
        'Croaked on missing patron object';
46
47
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
48
    $patron->auth_method('two-factor');
49
    $patron->secret('');
50
    $patron->store;
51
52
    
53
    throws_ok { Koha::Auth::TwoFactorAuth->new({ patron => $patron }) }
54
        'Koha::Exceptions::MissingParameter',
55
        'Croaked on missing secret';
56
57
58
59
60
61
62
63
64
65
#    my $cgi = Test::MockObject->new;
66
#    $cgi->mock( 'param', sub { return 2; } );
67
#    my $auth = Test::MockModule->new( 'C4::Auth' );
68
#    $auth->mock( 'checkauth', \&MockedCheckauth );
69
70
71
    
72
73
    $schema->storage->txn_rollback;
74
};

Return to bug 29894