|
Lines 41-47
$schema->storage->txn_begin;
Link Here
|
| 41 |
|
41 |
|
| 42 |
subtest 'checkauth() tests' => sub { |
42 |
subtest 'checkauth() tests' => sub { |
| 43 |
|
43 |
|
| 44 |
plan tests => 5; |
44 |
plan tests => 6; |
| 45 |
|
45 |
|
| 46 |
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => undef } }); |
46 |
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => undef } }); |
| 47 |
|
47 |
|
|
Lines 111-116
subtest 'checkauth() tests' => sub {
Link Here
|
| 111 |
is( $userid, undef, 'If librarian user is used and password with GET, they should not be logged in' ); |
111 |
is( $userid, undef, 'If librarian user is used and password with GET, they should not be logged in' ); |
| 112 |
}; |
112 |
}; |
| 113 |
|
113 |
|
|
|
114 |
subtest 'Template params tests (password_expired)' => sub { |
| 115 |
|
| 116 |
plan tests => 1; |
| 117 |
|
| 118 |
my $password_expired; |
| 119 |
|
| 120 |
my $patron_class = Test::MockModule->new('Koha::Patron'); |
| 121 |
$patron_class->mock( 'password_expired', sub { return $password_expired; } ); |
| 122 |
|
| 123 |
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => 1 } }); |
| 124 |
my $password = 'password'; |
| 125 |
t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); |
| 126 |
$patron->set_password( { password => $password } ); |
| 127 |
|
| 128 |
my $cgi_mock = Test::MockModule->new('CGI')->mock( 'request_method', 'POST' ); |
| 129 |
my $cgi = CGI->new; |
| 130 |
$cgi->param( -name => 'userid', -value => $patron->userid ); |
| 131 |
$cgi->param( -name => 'password', -value => $password ); |
| 132 |
|
| 133 |
my $auth = Test::MockModule->new( 'C4::Auth' ); |
| 134 |
# Tests will fail if we hit safe_exit |
| 135 |
$auth->mock( 'safe_exit', sub { return } ); |
| 136 |
|
| 137 |
my ( $userid, $cookie, $sessionID, $flags ); |
| 138 |
|
| 139 |
{ |
| 140 |
t::lib::Mocks::mock_preference( 'DumpTemplateVarsOpac', 1 ); |
| 141 |
# checkauth will redirect and safe_exit if not authenticated and not authorized |
| 142 |
local *STDOUT; |
| 143 |
my $stdout; |
| 144 |
open STDOUT, '>', \$stdout; |
| 145 |
|
| 146 |
# Password has expired |
| 147 |
$password_expired = 1; |
| 148 |
C4::Auth::checkauth( $cgi, 0, { catalogue => 1 } ); |
| 149 |
like( $stdout, qr{'password_has_expired' => 1}, 'password_has_expired is set to 1' ); |
| 150 |
|
| 151 |
close STDOUT; |
| 152 |
}; |
| 153 |
}; |
| 154 |
|
| 114 |
subtest 'Two-factor authentication' => sub { |
155 |
subtest 'Two-factor authentication' => sub { |
| 115 |
|
156 |
|
| 116 |
my $patron = $builder->build_object( |
157 |
my $patron = $builder->build_object( |
| 117 |
- |
|
|