|
|
|
@ -4,96 +4,99 @@ use IO::String; |
|
|
|
|
use Data::Dumper; |
|
|
|
|
|
|
|
|
|
require 't/test-lib.pm'; |
|
|
|
|
require 't/smtp.pm'; |
|
|
|
|
my $maintests = 5; |
|
|
|
|
|
|
|
|
|
use_ok('Lemonldap::NG::Common::FormEncode'); |
|
|
|
|
count(1); |
|
|
|
|
my $res; |
|
|
|
|
SKIP: { |
|
|
|
|
eval { require Crypt::U2F::Server; require Authen::U2F::Tester }; |
|
|
|
|
if ( $@ or $Crypt::U2F::Server::VERSION < 0.42 ) { |
|
|
|
|
skip 'Missing libraries', $maintests; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
use_ok('Lemonldap::NG::Common::FormEncode'); |
|
|
|
|
my $res; |
|
|
|
|
|
|
|
|
|
my $client = LLNG::Manager::Test->new( { |
|
|
|
|
ini => { |
|
|
|
|
logLevel => 'debug', |
|
|
|
|
sfOnlyUpgrade => 1, |
|
|
|
|
u2fActivation => 1, |
|
|
|
|
u2fAuthnLevel => 5, |
|
|
|
|
authentication => 'Demo', |
|
|
|
|
userDB => 'Same', |
|
|
|
|
'vhostOptions' => { |
|
|
|
|
'test1.example.com' => { |
|
|
|
|
'vhostAuthnLevel' => 3 |
|
|
|
|
my $client = LLNG::Manager::Test->new( { |
|
|
|
|
ini => { |
|
|
|
|
logLevel => 'error', |
|
|
|
|
sfOnlyUpgrade => 1, |
|
|
|
|
u2fActivation => 1, |
|
|
|
|
u2fAuthnLevel => 5, |
|
|
|
|
authentication => 'Demo', |
|
|
|
|
userDB => 'Same', |
|
|
|
|
'vhostOptions' => { |
|
|
|
|
'test1.example.com' => { |
|
|
|
|
'vhostAuthnLevel' => 3 |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
# CASE 1: no 2F available |
|
|
|
|
# ----------------------- |
|
|
|
|
my $query = 'user=rtyler&password=rtyler'; |
|
|
|
|
ok( |
|
|
|
|
$res = $client->_post( |
|
|
|
|
'/', |
|
|
|
|
IO::String->new($query), |
|
|
|
|
length => length($query), |
|
|
|
|
accept => 'text/html', |
|
|
|
|
), |
|
|
|
|
'Auth query' |
|
|
|
|
); |
|
|
|
|
count(1); |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
my $id = expectCookie($res); |
|
|
|
|
# CASE 1: no 2F available |
|
|
|
|
# ----------------------- |
|
|
|
|
my $query = 'user=rtyler&password=rtyler'; |
|
|
|
|
ok( |
|
|
|
|
$res = $client->_post( |
|
|
|
|
'/', |
|
|
|
|
IO::String->new($query), |
|
|
|
|
length => length($query), |
|
|
|
|
accept => 'text/html', |
|
|
|
|
), |
|
|
|
|
'Auth query' |
|
|
|
|
); |
|
|
|
|
my $id = expectCookie($res); |
|
|
|
|
|
|
|
|
|
# After attempting to access test1, |
|
|
|
|
# the handler sends up back to /upgradesession |
|
|
|
|
# -------------------------------------------- |
|
|
|
|
# After attempting to access test1, |
|
|
|
|
# the handler sends up back to /upgradesession |
|
|
|
|
# -------------------------------------------- |
|
|
|
|
ok( |
|
|
|
|
$res = $client->_get( |
|
|
|
|
'/upgradesession', |
|
|
|
|
query => 'url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29t', |
|
|
|
|
accept => 'text/html', |
|
|
|
|
cookie => "lemonldap=$id", |
|
|
|
|
), |
|
|
|
|
'Upgrade session query' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
ok( |
|
|
|
|
$res = $client->_get( |
|
|
|
|
'/upgradesession', |
|
|
|
|
query => 'url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29t', |
|
|
|
|
accept => 'text/html', |
|
|
|
|
cookie => "lemonldap=$id", |
|
|
|
|
), |
|
|
|
|
'Upgrade session query' |
|
|
|
|
); |
|
|
|
|
count(1); |
|
|
|
|
( my $host, my $url, $query ) = |
|
|
|
|
expectForm( $res, undef, '/upgradesession', 'confirm', 'url' ); |
|
|
|
|
|
|
|
|
|
( my $host, my $url, $query ) = |
|
|
|
|
expectForm( $res, undef, '/upgradesession', 'confirm', 'url' ); |
|
|
|
|
# Accept session upgrade |
|
|
|
|
# ---------------------- |
|
|
|
|
|
|
|
|
|
# Accept session upgrade |
|
|
|
|
# ---------------------- |
|
|
|
|
ok( |
|
|
|
|
$res = $client->_post( |
|
|
|
|
'/upgradesession', |
|
|
|
|
IO::String->new($query), |
|
|
|
|
length => length($query), |
|
|
|
|
accept => 'text/html', |
|
|
|
|
cookie => "lemonldap=$id", |
|
|
|
|
), |
|
|
|
|
'Accept session upgrade query' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
ok( |
|
|
|
|
$res = $client->_post( |
|
|
|
|
'/upgradesession', |
|
|
|
|
IO::String->new($query), |
|
|
|
|
length => length($query), |
|
|
|
|
accept => 'text/html', |
|
|
|
|
cookie => "lemonldap=$id", |
|
|
|
|
), |
|
|
|
|
'Accept session upgrade query' |
|
|
|
|
); |
|
|
|
|
count(1); |
|
|
|
|
expectCookie( $res, 'lemonldappdata' ); |
|
|
|
|
|
|
|
|
|
my $pdata = expectCookie( $res, 'lemonldappdata' ); |
|
|
|
|
# A message warns the user that they do not have any 2FA available |
|
|
|
|
expectPortalError( $res, 83 ); |
|
|
|
|
|
|
|
|
|
# A message warns the user that they do not have any 2FA available |
|
|
|
|
expectPortalError( $res, 83 ); |
|
|
|
|
$query = 'user=rtyler&password=rtyler'; |
|
|
|
|
ok( |
|
|
|
|
$res = $client->_post( |
|
|
|
|
'/upgradesession', |
|
|
|
|
IO::String->new($query), |
|
|
|
|
length => length($query), |
|
|
|
|
accept => 'text/html', |
|
|
|
|
cookie => "lemonldap=$id", |
|
|
|
|
), |
|
|
|
|
'Accept session upgrade query' |
|
|
|
|
); |
|
|
|
|
expectRedirection( $res, 'http://auth.example.com/' ); |
|
|
|
|
$client->logout($id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$query = 'user=rtyler&password=rtyler'; |
|
|
|
|
ok( |
|
|
|
|
$res = $client->_post( |
|
|
|
|
'/upgradesession', |
|
|
|
|
IO::String->new($query), |
|
|
|
|
length => length($query), |
|
|
|
|
accept => 'text/html', |
|
|
|
|
cookie => "lemonldap=$id", |
|
|
|
|
), |
|
|
|
|
'Accept session upgrade query' |
|
|
|
|
); |
|
|
|
|
count(1); |
|
|
|
|
expectRedirection( $res, 'http://auth.example.com/' ); |
|
|
|
|
count($maintests); |
|
|
|
|
clean_sessions(); |
|
|
|
|
|
|
|
|
|
done_testing( count() ); |
|
|
|
|