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 => 26; |
13 |
use Test::More tests => 20; |
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 115-142
subtest 'track_login_daily tests' => sub {
Link Here
|
115 |
|
115 |
|
116 |
}; |
116 |
}; |
117 |
|
117 |
|
118 |
my $hash1 = hash_password('password'); |
118 |
subtest 'no_set_userenv parameter tests' => sub { |
119 |
my $hash2 = hash_password('password'); |
|
|
120 |
|
119 |
|
121 |
{ # tests no_set_userenv parameter |
120 |
plan tests => 7; |
122 |
my $patron = $builder->build( { source => 'Borrower' } ); |
121 |
|
123 |
Koha::Patrons->find( $patron->{borrowernumber} )->update_password( $patron->{userid}, 'password' ); |
122 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
124 |
my $library = $builder->build( |
123 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
125 |
{ |
124 |
my $password = 'password'; |
126 |
source => 'Branch', |
|
|
127 |
} |
128 |
); |
129 |
|
125 |
|
130 |
ok( checkpw( $dbh, $patron->{userid}, 'password', undef, undef, 1 ), 'checkpw returns true' ); |
126 |
t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); |
|
|
127 |
$patron->set_password( $password ); |
128 |
|
129 |
ok( checkpw( $dbh, $patron->userid, $password, undef, undef, 1 ), 'checkpw returns true' ); |
131 |
is( C4::Context->userenv, undef, 'Userenv should be undef as required' ); |
130 |
is( C4::Context->userenv, undef, 'Userenv should be undef as required' ); |
132 |
C4::Context->_new_userenv('DUMMY SESSION'); |
131 |
C4::Context->_new_userenv('DUMMY SESSION'); |
133 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, 'Library 1', 0, '', ''); |
132 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->branchcode, 'Library 1', 0, '', ''); |
134 |
is( C4::Context->userenv->{branch}, $library->{branchcode}, 'Userenv gives correct branch' ); |
133 |
is( C4::Context->userenv->{branch}, $library->branchcode, 'Userenv gives correct branch' ); |
135 |
ok( checkpw( $dbh, $patron->{userid}, 'password', undef, undef, 1 ), 'checkpw returns true' ); |
134 |
ok( checkpw( $dbh, $patron->userid, $password, undef, undef, 1 ), 'checkpw returns true' ); |
136 |
is( C4::Context->userenv->{branch}, $library->{branchcode}, 'Userenv branch is preserved if no_set_userenv is true' ); |
135 |
is( C4::Context->userenv->{branch}, $library->branchcode, 'Userenv branch is preserved if no_set_userenv is true' ); |
137 |
ok( checkpw( $dbh, $patron->{userid}, 'password', undef, undef, 0 ), 'checkpw still returns true' ); |
136 |
ok( checkpw( $dbh, $patron->userid, $password, undef, undef, 0 ), 'checkpw still returns true' ); |
138 |
isnt( C4::Context->userenv->{branch}, $library->{branchcode}, 'Userenv branch is overwritten if no_set_userenv is false' ); |
137 |
isnt( C4::Context->userenv->{branch}, $library->branchcode, 'Userenv branch is overwritten if no_set_userenv is false' ); |
139 |
} |
138 |
}; |
140 |
|
139 |
|
141 |
# get_template_and_user tests |
140 |
# get_template_and_user tests |
142 |
|
141 |
|
Lines 311-315
my ( $template2 );
Link Here
|
311 |
ok( ( any { 'OPACBaseURL' eq $_ } keys %{$template2->{VARS}} ), |
310 |
ok( ( any { 'OPACBaseURL' eq $_ } keys %{$template2->{VARS}} ), |
312 |
'OPACBaseURL is in Staff template' ); |
311 |
'OPACBaseURL is in Staff template' ); |
313 |
|
312 |
|
|
|
313 |
my $hash1 = hash_password('password'); |
314 |
my $hash2 = hash_password('password'); |
315 |
|
314 |
ok(C4::Auth::checkpw_hash('password', $hash1), 'password validates with first hash'); |
316 |
ok(C4::Auth::checkpw_hash('password', $hash1), 'password validates with first hash'); |
315 |
ok(C4::Auth::checkpw_hash('password', $hash2), 'password validates with second hash'); |
317 |
ok(C4::Auth::checkpw_hash('password', $hash2), 'password validates with second hash'); |