|
Lines 156-162
subtest 'checkauth() tests' => sub {
Link Here
|
| 156 |
$cgi->param( 'userid', $patron->userid ); |
156 |
$cgi->param( 'userid', $patron->userid ); |
| 157 |
$cgi->param( 'password', $password ); |
157 |
$cgi->param( 'password', $password ); |
| 158 |
|
158 |
|
| 159 |
my ( $userid, $cookie, $sessionID, $flags, $template ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); |
159 |
my ( $userid, $cookie, $sessionID, $flags, $template ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { no_print_for_tests => 1 } ); |
| 160 |
is( $template->{VARS}->{password_has_expired}, 1 ); |
160 |
is( $template->{VARS}->{password_has_expired}, 1 ); |
| 161 |
}; |
161 |
}; |
| 162 |
|
162 |
|
|
Lines 191-197
subtest 'checkauth() tests' => sub {
Link Here
|
| 191 |
$cgi->param( -name => 'koha_login_context', -value => 1 ); |
191 |
$cgi->param( -name => 'koha_login_context', -value => 1 ); |
| 192 |
my ( $userid, $cookie, $flags, $template ); |
192 |
my ( $userid, $cookie, $flags, $template ); |
| 193 |
( $userid, $cookie, $sessionID, $flags, $template ) = |
193 |
( $userid, $cookie, $sessionID, $flags, $template ) = |
| 194 |
C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); |
194 |
C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { no_print_for_tests => 1 } ); |
| 195 |
is( $template->{VARS}->{loginprompt}, 1, 'Changing to non-existent user causes a redirect to login' ); |
195 |
is( $template->{VARS}->{loginprompt}, 1, 'Changing to non-existent user causes a redirect to login' ); |
| 196 |
}; |
196 |
}; |
| 197 |
|
197 |
|
|
Lines 226-232
subtest 'checkauth() tests' => sub {
Link Here
|
| 226 |
$cgi->param( -name => 'password', -value => $password ); |
226 |
$cgi->param( -name => 'password', -value => $password ); |
| 227 |
$cgi->param( -name => 'koha_login_context', -value => 1 ); |
227 |
$cgi->param( -name => 'koha_login_context', -value => 1 ); |
| 228 |
my ( $userid, $cookie, $sessionID, $flags, $template ) = |
228 |
my ( $userid, $cookie, $sessionID, $flags, $template ) = |
| 229 |
C4::Auth::checkauth( $cgi, 0, {}, 'opac', undef, undef, { do_not_print => 1 } ); |
229 |
C4::Auth::checkauth( $cgi, 0, {}, 'opac', undef, undef, { no_print_for_tests => 1 } ); |
| 230 |
is( $userid, $patron2->userid, 'Login of patron2 approved' ); |
230 |
is( $userid, $patron2->userid, 'Login of patron2 approved' ); |
| 231 |
isnt( $sessionID, $previous_sessionID, 'Did not return previous session ID' ); |
231 |
isnt( $sessionID, $previous_sessionID, 'Did not return previous session ID' ); |
| 232 |
ok( $sessionID, 'New session ID not empty' ); |
232 |
ok( $sessionID, 'New session ID not empty' ); |
|
Lines 243-249
subtest 'checkauth() tests' => sub {
Link Here
|
| 243 |
$cgi->param( -name => 'password', -value => $password ); |
243 |
$cgi->param( -name => 'password', -value => $password ); |
| 244 |
$cgi->param( -name => 'koha_login_context', -value => 1 ); |
244 |
$cgi->param( -name => 'koha_login_context', -value => 1 ); |
| 245 |
( $userid, $cookie, $sessionID, $flags, $template ) = |
245 |
( $userid, $cookie, $sessionID, $flags, $template ) = |
| 246 |
C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); |
246 |
C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { no_print_for_tests => 1 } ); |
| 247 |
is( $template->{VARS}->{nopermission}, 1, 'No permission response' ); |
247 |
is( $template->{VARS}->{nopermission}, 1, 'No permission response' ); |
| 248 |
}; |
248 |
}; |
| 249 |
|
249 |
|
|
Lines 774-780
subtest 'checkauth & check_cookie_auth' => sub {
Link Here
|
| 774 |
$ENV{"HTTP_COOKIE"} = "CGISESSID=$sessionID"; |
774 |
$ENV{"HTTP_COOKIE"} = "CGISESSID=$sessionID"; |
| 775 |
# Not authenticated yet, the login form is displayed |
775 |
# Not authenticated yet, the login form is displayed |
| 776 |
my $template; |
776 |
my $template; |
| 777 |
( $userid, $cookie, $sessionID, $flags, $template ) = C4::Auth::checkauth($cgi, 0, {catalogue => 1}, 'intranet', undef, undef, { do_not_print => 1 } ); |
777 |
( $userid, $cookie, $sessionID, $flags, $template ) = C4::Auth::checkauth($cgi, 0, {catalogue => 1}, 'intranet', undef, undef, { no_print_for_tests => 1 } ); |
| 778 |
is( $template->{VARS}->{loginprompt}, 1, ); |
778 |
is( $template->{VARS}->{loginprompt}, 1, ); |
| 779 |
|
779 |
|
| 780 |
# Sending undefined fails obviously |
780 |
# Sending undefined fails obviously |
|
Lines 816-822
subtest 'checkauth & check_cookie_auth' => sub {
Link Here
|
| 816 |
$cgi->param('logout.x', 1); |
816 |
$cgi->param('logout.x', 1); |
| 817 |
$cgi->delete( 'userid', 'password' ); |
817 |
$cgi->delete( 'userid', 'password' ); |
| 818 |
( $userid, $cookie, $sessionID, $flags, $template ) = |
818 |
( $userid, $cookie, $sessionID, $flags, $template ) = |
| 819 |
C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); |
819 |
C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { no_print_for_tests => 1 } ); |
| 820 |
|
820 |
|
| 821 |
is( $sessionID, undef ); |
821 |
is( $sessionID, undef ); |
| 822 |
is( $ENV{"HTTP_COOKIE"}, "CGISESSID=$first_sessionID", 'HTTP_COOKIE not unset' ); |
822 |
is( $ENV{"HTTP_COOKIE"}, "CGISESSID=$first_sessionID", 'HTTP_COOKIE not unset' ); |
| 823 |
- |
|
|