Commit e7a712c0 authored by Yadd's avatar Yadd
Browse files

DBI auth works (#595)

parent 0ca85d42
......@@ -80,8 +80,8 @@ sub check_password {
# If $user is an object then it's a Lemonldap::NG::Portal::Main::Request
# object
if ( ref($user) ) {
$password ||= $user->datas->{password};
$user ||= $user->{user};
$password = $user->datas->{password};
$user = $user->{user};
}
my $table = $self->conf->{dbiAuthTable};
my $loginCol = $self->conf->{dbiAuthLoginCol};
......
......@@ -32,7 +32,7 @@ SKIP: {
ok(
$res = &client->_post(
'/', '',
IO::String->new('user=dwho&password=dwho'),
IO::String->new($postString),
'application/x-www-form-urlencoded',
length($postString)
),
......
use Test::More;
use strict;
use IO::String;
require 't/test-lib.pm';
my $res;
eval { unlink 't/userdb.db' };
SKIP: {
eval { require DBI; require DBD::SQLite; };
if ($@) {
skip 'DBD::SQLite not found', 3;
}
my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db");
$dbh->do('CREATE TABLE users (user text,password text,name text)');
$dbh->do("INSERT INTO users VALUES ('dwho','dwho','Doctor who')");
init(
{
logLevel => 'debug',
useSafeJail => 1,
authentication => 'DBI',
userDB => 'DBI',
dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db',
dbiAuthUser => '',
dbiAuthPassword => '',
dbiAuthTable => 'users',
dbiAuthLoginCol => 'user',
dbiAuthPasswordCol => 'password',
dbiAuthPasswordHash => '',
}
);
my $postString = 'user='
. ( $ENV{LDAPACCOUNT} || 'dwho' )
. '&password='
. ( $ENV{LDAPPWD} || 'dwho' );
# Try yo authenticate
# -------------------
ok(
$res = &client->_post(
'/', '',
IO::String->new('user=dwho&password=dwho'),
'application/x-www-form-urlencoded',
23
),
'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' );
clean_sessions();
}
count(3);
eval { unlink 't/userdb.db' };
done_testing( count() );
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment