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

(-)a/t/db_dependent/Auth.t (-4 / +26 lines)
Lines 6-14 Link Here
6
use Modern::Perl;
6
use Modern::Perl;
7
7
8
use CGI qw ( -utf8 );
8
use CGI qw ( -utf8 );
9
10
use Test::MockObject;
9
use Test::MockModule;
11
use Test::MockModule;
10
use List::MoreUtils qw/all any none/;
12
use List::MoreUtils qw/all any none/;
11
use Test::More tests => 20;
13
use Test::More tests => 21;
12
use Test::Warn;
14
use Test::Warn;
13
use t::lib::Mocks;
15
use t::lib::Mocks;
14
use t::lib::TestBuilder;
16
use t::lib::TestBuilder;
Lines 23-33 BEGIN { Link Here
23
    use_ok('C4::Auth');
25
    use_ok('C4::Auth');
24
}
26
}
25
27
26
my $schema = Koha::Database->schema;
28
my $schema  = Koha::Database->schema;
27
$schema->storage->txn_begin;
28
my $builder = t::lib::TestBuilder->new;
29
my $builder = t::lib::TestBuilder->new;
29
my $dbh     = C4::Context->dbh;
30
my $dbh     = C4::Context->dbh;
30
31
32
$schema->storage->txn_begin;
33
34
subtest 'checkauth() tests' => sub {
35
36
    plan tests => 1;
37
38
    my $patron = $builder->build({ source => 'Borrower', value => { flags => undef } })->{userid};
39
40
    # Mock a CGI object with real userid param
41
    my $cgi = Test::MockObject->new();
42
    $cgi->mock( 'param', sub { return $patron; } );
43
    $cgi->mock( 'cookie', sub { return; } );
44
45
    my $authnotrequired = 1;
46
    my ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, $authnotrequired );
47
48
    is( $userid, undef, 'checkauth() returns undef for userid if no logged in user (Bug 18275)' );
49
50
};
51
31
my $hash1 = hash_password('password');
52
my $hash1 = hash_password('password');
32
my $hash2 = hash_password('password');
53
my $hash2 = hash_password('password');
33
54
Lines 198-200 ok( ( any { 'OPACBaseURL' eq $_ } keys %{$template2->{VARS}} ), Link Here
198
219
199
ok(C4::Auth::checkpw_hash('password', $hash1), 'password validates with first hash');
220
ok(C4::Auth::checkpw_hash('password', $hash1), 'password validates with first hash');
200
ok(C4::Auth::checkpw_hash('password', $hash2), 'password validates with second hash');
221
ok(C4::Auth::checkpw_hash('password', $hash2), 'password validates with second hash');
201
- 
222
223

Return to bug 18275