lemonldap-ng/lemonldap-ng-portal/t/21-Auth-and-password-LDAP.t

49 lines
1.2 KiB
Perl
Raw Normal View History

2016-05-12 21:02:48 +02:00
use Test::More;
use strict;
use IO::String;
require 't/test-lib.pm';
my $res;
SKIP: {
2016-12-23 07:41:03 +01:00
skip 'No LDAP server given', 1 unless ( $ENV{LDAPSERVER} );
2016-05-12 21:02:48 +02:00
2016-11-14 13:34:46 +01:00
my $client = LLNG::Manager::Test->new(
2016-05-12 21:02:48 +02:00
{
2016-11-14 13:34:46 +01:00
ini => {
logLevel => 'error',
useSafeJail => 1,
authentication => 'LDAP',
userDB => 'LDAP',
LDAPFilter => $ENV{LDAPFILTER} || '(cn=$user)',
ldapServer => $ENV{LDAPSERVER},
ldapBase => $ENV{LDAPBASE},
managerDn => $ENV{MANAGERDN} || '',
managerPassword => $ENV{MANAGERPASSWORD} || '',
}
2016-05-12 21:02:48 +02:00
}
);
my $postString = 'user='
. ( $ENV{LDAPACCOUNT} || 'dwho' )
. '&password='
. ( $ENV{LDAPPWD} || 'dwho' );
# Try yo authenticate
# -------------------
ok(
2016-11-14 13:34:46 +01:00
$res = $client->_post(
'/', IO::String->new($postString),
2016-05-30 22:20:50 +02:00
length => length($postString)
2016-05-12 21:02:48 +02:00
),
'Auth query'
);
2016-12-23 07:41:03 +01:00
expectOK($res);
my $id = expectCookie($res);
2016-11-14 13:34:46 +01:00
$client->logout($id);
2016-05-12 21:02:48 +02:00
clean_sessions();
}
2016-12-23 07:41:03 +01:00
count(1);
2016-05-12 21:02:48 +02:00
done_testing( count() );