Lines 10-16
use CGI qw ( -utf8 );
Link Here
|
10 |
use Test::MockObject; |
10 |
use Test::MockObject; |
11 |
use Test::MockModule; |
11 |
use Test::MockModule; |
12 |
use List::MoreUtils qw/all any none/; |
12 |
use List::MoreUtils qw/all any none/; |
13 |
use Test::More tests => 20; |
13 |
use Test::More tests => 26; |
14 |
use Test::Warn; |
14 |
use Test::Warn; |
15 |
use t::lib::Mocks; |
15 |
use t::lib::Mocks; |
16 |
use t::lib::TestBuilder; |
16 |
use t::lib::TestBuilder; |
Lines 20-27
use C4::Members;
Link Here
|
20 |
use Koha::AuthUtils qw/hash_password/; |
20 |
use Koha::AuthUtils qw/hash_password/; |
21 |
use Koha::Database; |
21 |
use Koha::Database; |
22 |
use Koha::Patrons; |
22 |
use Koha::Patrons; |
|
|
23 |
use File::Basename; |
23 |
|
24 |
|
24 |
BEGIN { |
25 |
BEGIN { |
|
|
26 |
push( @INC, dirname(__FILE__) . '/..' ); |
27 |
|
25 |
use_ok('C4::Auth'); |
28 |
use_ok('C4::Auth'); |
26 |
} |
29 |
} |
27 |
|
30 |
|
Lines 32-37
my $dbh = C4::Context->dbh;
Link Here
|
32 |
# FIXME: SessionStorage defaults to mysql, but it seems to break transaction |
35 |
# FIXME: SessionStorage defaults to mysql, but it seems to break transaction |
33 |
# handling |
36 |
# handling |
34 |
t::lib::Mocks::mock_preference( 'SessionStorage', 'tmp' ); |
37 |
t::lib::Mocks::mock_preference( 'SessionStorage', 'tmp' ); |
|
|
38 |
t::lib::Mocks::mock_preference( 'UseKohaPlugins', 0 ); |
35 |
|
39 |
|
36 |
$schema->storage->txn_begin; |
40 |
$schema->storage->txn_begin; |
37 |
|
41 |
|
Lines 129-134
subtest 'no_set_userenv parameter tests' => sub {
Link Here
|
129 |
ok( checkpw( $dbh, $patron->userid, $password, undef, undef, 1 ), 'checkpw returns true' ); |
133 |
ok( checkpw( $dbh, $patron->userid, $password, undef, undef, 1 ), 'checkpw returns true' ); |
130 |
is( C4::Context->userenv, undef, 'Userenv should be undef as required' ); |
134 |
is( C4::Context->userenv, undef, 'Userenv should be undef as required' ); |
131 |
C4::Context->_new_userenv('DUMMY SESSION'); |
135 |
C4::Context->_new_userenv('DUMMY SESSION'); |
|
|
136 |
<<<<<<< 41e0ff7cd6240c2c9ba2d1bec816b191ef091eb1 |
132 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->branchcode, 'Library 1', 0, '', ''); |
137 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->branchcode, 'Library 1', 0, '', ''); |
133 |
is( C4::Context->userenv->{branch}, $library->branchcode, 'Userenv gives correct branch' ); |
138 |
is( C4::Context->userenv->{branch}, $library->branchcode, 'Userenv gives correct branch' ); |
134 |
ok( checkpw( $dbh, $patron->userid, $password, undef, undef, 1 ), 'checkpw returns true' ); |
139 |
ok( checkpw( $dbh, $patron->userid, $password, undef, undef, 1 ), 'checkpw returns true' ); |
Lines 136-141
subtest 'no_set_userenv parameter tests' => sub {
Link Here
|
136 |
ok( checkpw( $dbh, $patron->userid, $password, undef, undef, 0 ), 'checkpw still returns true' ); |
141 |
ok( checkpw( $dbh, $patron->userid, $password, undef, undef, 0 ), 'checkpw still returns true' ); |
137 |
isnt( C4::Context->userenv->{branch}, $library->branchcode, 'Userenv branch is overwritten if no_set_userenv is false' ); |
142 |
isnt( C4::Context->userenv->{branch}, $library->branchcode, 'Userenv branch is overwritten if no_set_userenv is false' ); |
138 |
}; |
143 |
}; |
|
|
144 |
======= |
145 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, 'Library 1', 0, '', ''); |
146 |
is( C4::Context->userenv->{branch}, $library->{branchcode}, 'Userenv gives correct branch' ); |
147 |
ok( checkpw( $dbh, $patron->{userid}, 'password', undef, undef, 1 ), 'checkpw returns true' ); |
148 |
is( C4::Context->userenv->{branch}, $library->{branchcode}, 'Userenv branch is preserved if no_set_userenv is true' ); |
149 |
ok( checkpw( $dbh, $patron->{userid}, 'password', undef, undef, 0 ), 'checkpw still returns true' ); |
150 |
isnt( C4::Context->userenv->{branch}, $library->{branchcode}, 'Userenv branch is overwritten if no_set_userenv is false' ); |
151 |
|
152 |
t::lib::Mocks::mock_preference( 'UseKohaPlugins', 1 ); |
153 |
my @result = checkpw( $dbh, $patron->{userid}, 'wrong_password', undef, undef, 1 ); |
154 |
is( $result[0], 0, 'With TestAuth plugin, checkpw returns 0' ); |
155 |
is( $result[1], undef, 'With TestAuth plugin, checkpw returns empty cardnumber' ); |
156 |
is( $result[2], undef, 'With TestAuth plugin, checkpw returns empty userid' ); |
157 |
@result = checkpw( $dbh, 'test', 'test', undef, undef, 1 ); |
158 |
is( $result[0], 1, 'With TestAuth plugin, checkpw returns 1' ); |
159 |
is( $result[1], 'test', 'With TestAuth plugin, checkpw returns test cardnumber' ); |
160 |
is( $result[2], 'test', 'With TestAuth plugin, checkpw returns test userid' ); |
161 |
} |
162 |
>>>>>>> Bug 20340 - Ability to add and use authentication plugins |
139 |
|
163 |
|
140 |
# get_template_and_user tests |
164 |
# get_template_and_user tests |
141 |
|
165 |
|
142 |
- |
|
|