Commit e001cc40 authored by Xavier Guimard's avatar Xavier Guimard

Enable test for "expire" too

parent 3069887a
......@@ -7,10 +7,9 @@ require 't/test-lib.pm';
use lib 't/lib';
my $res;
my $maintests = 3;
SKIP: {
skip 'LLNGTESTLDAP is not set', $maintests unless ( $ENV{LLNGTESTLDAP} );
skip 'LLNGTESTLDAP is not set' unless ( $ENV{LLNGTESTLDAP} );
require 't/test-ldap.pm';
my $client = LLNG::Manager::Test->new(
......@@ -32,60 +31,66 @@ SKIP: {
}
}
);
my $postString = 'user='
. ( $ENV{LDAPACCOUNT} || 'reset' )
. '&password='
. ( $ENV{LDAPPWD} || 'reset' );
use Lemonldap::NG::Portal::Main::Constants 'PE_PP_CHANGE_AFTER_RESET',
'PE_PP_PASSWORD_EXPIRED', 'PE_PASSWORD_OK';
foreach my $tpl (
[ 'reset', PE_PP_CHANGE_AFTER_RESET ],
[ 'expire', PE_PP_PASSWORD_EXPIRED ]
)
{
my $user = $tpl->[0];
my $code = $tpl->[1];
my $postString = "user=$user&password=$user";
# Try yo authenticate
# -------------------
ok(
$res = $client->_post(
'/', IO::String->new($postString),
length => length($postString),
accept => 'text/html',
),
'Auth query'
);
my $match = 'trmsg="'
. &Lemonldap::NG::Portal::Main::Constants::PE_PP_CHANGE_AFTER_RESET . '"';
ok( $res->[2]->[0] =~ /$match/, 'Password is expired' );
# Try yo authenticate
# -------------------
ok(
$res = $client->_post(
'/', IO::String->new($postString),
length => length($postString),
accept => 'text/html',
),
'Auth query'
);
my $match = 'trmsg="' . $code . '"';
ok( $res->[2]->[0] =~ /$match/, 'Password is expired' );
count(2);
#open F, '>../e2e-tests/conf/portal/result.html' or die $!;
#print F $res->[2]->[0];
#close F;
my ( $host, $url, $query ) =
expectForm( $res, '#', undef, 'user', 'oldpassword', 'newpassword',
'confirmpassword' );
ok( $query =~ /user=reset/, 'User is reset' )
or explain( $query, 'user=reset' );
count(1);
$query =~ s/(oldpassword)=/$1=reset/g;
$query =~ s/((?:confirm|new)password)=/$1=newp/g;
ok(
$res = $client->_post(
'/', IO::String->new($query),
length => length($query),
accept => 'text/html',
),
'Post new password'
);
my $match = 'trmsg="'
. &Lemonldap::NG::Portal::Main::Constants::PE_PASSWORD_OK . '"';
ok( $res->[2]->[0] =~ /$match/, 'Password is expired' );
count(1);
#open F, '>../e2e-tests/conf/portal/result.html' or die $!;
#print F $res->[2]->[0];
#close F;
my ( $host, $url, $query ) =
expectForm( $res, '#', undef, 'user', 'oldpassword', 'newpassword',
'confirmpassword' );
ok( $query =~ /user=$user/, "User is $user" )
or explain( $query, "user=$user" );
count(1);
$query =~ s/(oldpassword)=/$1=$user/g;
$query =~ s/((?:confirm|new)password)=/$1=newp/g;
ok(
$res = $client->_post(
'/', IO::String->new($query),
length => length($query),
accept => 'text/html',
),
'Post new password'
);
my $match = 'trmsg="' . PE_PASSWORD_OK . '"';
ok( $res->[2]->[0] =~ /$match/, 'Password is changed' );
count(2);
ok(
$res = $client->_post(
'/', IO::String->new('user=reset&password=newp'),
length => 24
),
'Auth query'
);
count(1);
expectCookie($res) or print STDERR Dumper($res);
$postString = "user=$user&password=newp";
ok(
$res = $client->_post(
'/', IO::String->new($postString),
length => length($postString),
),
'Auth query'
);
count(1);
expectCookie($res) or print STDERR Dumper($res);
}
}
clean_sessions();
count($maintests);
stopLdapServer() if $ENV{LLNGTESTLDAP};
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