|
Lines 151-159
subtest 'checkauth() tests' => sub {
Link Here
|
| 151 |
} |
151 |
} |
| 152 |
|
152 |
|
| 153 |
t::lib::Mocks::mock_preference( 'TwoFactorAuthentication', 0 ); |
153 |
t::lib::Mocks::mock_preference( 'TwoFactorAuthentication', 0 ); |
| 154 |
$patron->encode_secret('one_secret'); |
154 |
$patron->auth_method('password')->store; |
| 155 |
$patron->auth_method('password'); |
|
|
| 156 |
$patron->store; |
| 157 |
( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired', undef, 'intranet' ); |
155 |
( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired', undef, 'intranet' ); |
| 158 |
is( $userid, $patron->userid, 'Succesful login' ); |
156 |
is( $userid, $patron->userid, 'Succesful login' ); |
| 159 |
is( C4::Auth::get_session($sessionID)->param('waiting-for-2FA'), undef, 'Second auth not required' ); |
157 |
is( C4::Auth::get_session($sessionID)->param('waiting-for-2FA'), undef, 'Second auth not required' ); |
|
Lines 166-178
subtest 'checkauth() tests' => sub {
Link Here
|
| 166 |
logout($cgi); |
164 |
logout($cgi); |
| 167 |
|
165 |
|
| 168 |
t::lib::Mocks::mock_preference( 'TwoFactorAuthentication', 1 ); |
166 |
t::lib::Mocks::mock_preference( 'TwoFactorAuthentication', 1 ); |
|
|
167 |
t::lib::Mocks::mock_config('encryption_key', '1234tH1s=t&st'); |
| 169 |
$patron->auth_method('password')->store; |
168 |
$patron->auth_method('password')->store; |
| 170 |
( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired', undef, 'intranet' ); |
169 |
( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired', undef, 'intranet' ); |
| 171 |
is( $userid, $patron->userid, 'Succesful login' ); |
170 |
is( $userid, $patron->userid, 'Succesful login' ); |
| 172 |
is( C4::Auth::get_session($sessionID)->param('waiting-for-2FA'), undef, 'Second auth not required' ); |
171 |
is( C4::Auth::get_session($sessionID)->param('waiting-for-2FA'), undef, 'Second auth not required' ); |
| 173 |
logout($cgi); |
172 |
logout($cgi); |
| 174 |
|
173 |
|
| 175 |
$patron->auth_method('two-factor')->store; |
174 |
$patron->encode_secret('one_secret'); |
|
|
175 |
$patron->auth_method('two-factor'); |
| 176 |
$patron->store; |
| 176 |
( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired', undef, 'intranet' ); |
177 |
( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired', undef, 'intranet' ); |
| 177 |
is( $userid, $patron->userid, 'Succesful login' ); |
178 |
is( $userid, $patron->userid, 'Succesful login' ); |
| 178 |
my $session = C4::Auth::get_session($sessionID); |
179 |
my $session = C4::Auth::get_session($sessionID); |
|
Lines 192-197
subtest 'checkauth() tests' => sub {
Link Here
|
| 192 |
is( $userid, $patron->userid, 'Succesful login' ); |
193 |
is( $userid, $patron->userid, 'Succesful login' ); |
| 193 |
is( C4::Auth::get_session($sessionID)->param('waiting-for-2FA'), 0, 'Second auth no longer required if OTP token has been verified' ); |
194 |
is( C4::Auth::get_session($sessionID)->param('waiting-for-2FA'), 0, 'Second auth no longer required if OTP token has been verified' ); |
| 194 |
|
195 |
|
|
|
196 |
t::lib::Mocks::mock_preference( 'TwoFactorAuthentication', 0 ); |
| 195 |
}; |
197 |
}; |
| 196 |
|
198 |
|
| 197 |
C4::Context->_new_userenv; # For next tests |
199 |
C4::Context->_new_userenv; # For next tests |
| 198 |
- |
|
|