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

51 lines
1.3 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: {
skip 'No LDAP server given', 3 unless ( $ENV{LDAPSERVER} );
init(
{
2016-05-23 18:55:20 +02:00
logLevel => 'error',
2016-05-12 21:02:48 +02:00
useSafeJail => 1,
authentication => 'LDAP',
userDB => 'LDAP',
LDAPFilter => $ENV{LDAPFILTER} || '(cn=$user)',
ldapServer => $ENV{LDAPSERVER},
ldapBase => $ENV{LDAPBASE},
managerDn => $ENV{MANAGERDN} || '',
managerPassword => $ENV{MANAGERPASSWORD} || '',
}
);
my $postString = 'user='
. ( $ENV{LDAPACCOUNT} || 'dwho' )
. '&password='
. ( $ENV{LDAPPWD} || 'dwho' );
# Try yo authenticate
# -------------------
ok(
$res = &client->_post(
2016-05-30 22:20:50 +02:00
'/',
2016-05-19 22:07:46 +02:00
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'
);
ok( $res->[0] == 200, 'Response is 200' ) or explain( $res->[0], 200 );
my $cookies = getCookies($res);
my $id;
ok( $id = $cookies->{lemonldap}, 'Get cookie' )
or explain( $res, 'Set-Cookie: something' );
2016-05-22 19:06:55 +02:00
logout($id);
2016-05-12 21:02:48 +02:00
clean_sessions();
}
count(3);
done_testing( count() );