Commit 3fe95615 authored by Xavier Guimard's avatar Xavier Guimard

Don't depend on Email::Sender for tests

parent 6e380971
......@@ -3,17 +3,21 @@ use strict;
use IO::String;
BEGIN {
require 't/test-lib.pm';
require 't/smtp.pm';
eval {
require 't/test-lib.pm';
require 't/smtp.pm';
};
}
my $maintests = 13;
my ( $res, $user, $pwd, $host, $url, $query ) = my $mailSend = 0;
my ( $res, $user, $pwd, $host, $url, $query );
my $mailSend = 0;
SKIP: {
eval 'use GD::SecurityImage;use Image::Magick;';
eval
'require Email::Sender::Simple;use GD::SecurityImage;use Image::Magick;';
if ($@) {
skip 'Lasso not found', $maintests;
skip 'Missing dependencies', $maintests;
}
my $client = LLNG::Manager::Test->new(
......
......@@ -3,95 +3,99 @@ use strict;
use IO::String;
BEGIN {
require 't/test-lib.pm';
require 't/smtp.pm';
eval {
require 't/test-lib.pm';
require 't/smtp.pm';
};
}
my $maintests = 10;
my ( $res, $user, $pwd );
my $client = LLNG::Manager::Test->new(
{
ini => {
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
registerDB => 'Demo',
captcha_register_enabled => 0,
requireToken => 1,
}
SKIP: {
eval 'require Email::Sender::Simple';
if ($@) {
skip 'Missing dependencies', $maintests;
}
);
# Test normal first access
# ------------------------
ok(
$res = $client->_get( '/register', accept => 'text/html' ),
'Unauth request',
);
count(1);
my ( $host, $url, $query ) =
expectForm( $res, '#', undef, 'firstname', 'lastname', 'mail' );
ok(
$query =~
my $client = LLNG::Manager::Test->new(
{
ini => {
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
registerDB => 'Demo',
captcha_register_enabled => 0,
requireToken => 1,
}
}
);
# Test normal first access
# ------------------------
ok(
$res = $client->_get( '/register', accept => 'text/html' ),
'Unauth request',
);
my ( $host, $url, $query ) =
expectForm( $res, '#', undef, 'firstname', 'lastname', 'mail' );
ok(
$query =~
s/^.*(token=[^&]+).*$/$1&firstname=foo&lastname=bar&mail=foobar%40badwolf.org/,
'Token found'
);
count(1);
'Token found'
);
ok(
$res = $client->_post(
'/register',
IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Ask to create account'
);
count(1);
expectOK($res);
ok(
$res = $client->_post(
'/register',
IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Ask to create account'
);
expectOK($res);
ok( mail() =~ m#a href="http://auth.example.com/register\?(.*?)"#,
'Found register token' )
or print STDERR Dumper($main::mail);
$query = $1;
ok( $query =~ /register_token=/, 'Found register_token' );
count(2);
ok( mail() =~ m#a href="http://auth.example.com/register\?(.*?)"#,
'Found register token' )
or print STDERR Dumper($main::mail);
$query = $1;
ok( $query =~ /register_token=/, 'Found register_token' );
ok(
$res = $client->_get( '/register', query => $query, accept => 'text/html' ),
'Push register_token'
);
expectOK($res);
count(1);
ok(
$res =
$client->_get( '/register', query => $query, accept => 'text/html' ),
'Push register_token'
);
expectOK($res);
ok(
mail() =~
m#Your login is.+?<b>(\w+)</b>.*?Your password is.+?<b>(.*?)</b>#s,
'Found user and password'
);
$user = $1;
$pwd = $2;
ok( $user eq 'fbar', 'Get good login' );
count(2);
ok(
mail() =~
m#Your login is.+?<b>(\w+)</b>.*?Your password is.+?<b>(.*?)</b>#s,
'Found user and password'
);
$user = $1;
$pwd = $2;
ok( $user eq 'fbar', 'Get good login' );
# Try to authenticate
# 1. get token
ok( $res = $client->_get( '/', accept => 'text/html' ), 'Unauth request' );
count(1);
# Try to authenticate
# 1. get token
ok( $res = $client->_get( '/', accept => 'text/html' ), 'Unauth request' );
( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' );
$query =~ s/.*\b(token=[^&]+).*/$1&user=fbar&password=fbar/;
( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' );
$query =~ s/.*\b(token=[^&]+).*/$1&user=fbar&password=fbar/;
ok(
$res = $client->_post(
'/', IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Try to authenticate'
);
count(1);
expectCookie($res);
ok(
$res = $client->_post(
'/', IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Try to authenticate'
);
expectCookie($res);
}
count($maintests);
clean_sessions();
......
......@@ -3,81 +3,88 @@ use strict;
use IO::String;
BEGIN {
require 't/test-lib.pm';
require 't/smtp.pm';
eval {
require 't/test-lib.pm';
require 't/smtp.pm';
};
}
my $maintests = 8;
my ( $res, $user, $pwd );
my $client = LLNG::Manager::Test->new(
{
ini => {
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
authentication => 'Demo',
userDB => 'Same',
registerDB => 'Demo',
captcha_register_enabled => 0,
}
SKIP: {
eval 'require Email::Sender::Simple';
if ($@) {
skip 'Missing dependencies', $maintests;
}
);
# Test normal first access
# ------------------------
ok(
$res = $client->_get( '/register', accept => 'text/html' ),
'Unauth request',
);
count(1);
my ( $host, $url, $query ) =
expectForm( $res, '#', undef, 'firstname', 'lastname', 'mail' );
my $client = LLNG::Manager::Test->new(
{
ini => {
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
authentication => 'Demo',
userDB => 'Same',
registerDB => 'Demo',
captcha_register_enabled => 0,
}
}
);
# Test normal first access
# ------------------------
ok(
$res = $client->_get( '/register', accept => 'text/html' ),
'Unauth request',
);
my ( $host, $url, $query ) =
expectForm( $res, '#', undef, 'firstname', 'lastname', 'mail' );
ok(
$res = $client->_post(
'/register',
IO::String->new('firstname=foo&lastname=bar&mail=foobar%40badwolf.org'),
length => 52,
accept => 'text/html'
),
'Ask to create account'
);
count(1);
expectOK($res);
ok(
$res = $client->_post(
'/register',
IO::String->new(
'firstname=foo&lastname=bar&mail=foobar%40badwolf.org'),
length => 52,
accept => 'text/html'
),
'Ask to create account'
);
expectOK($res);
ok( mail() =~ m#a href="http://auth.example.com/register\?(.*?)"#,
'Found register token' );
$query = $1;
ok( $query =~ /register_token=/, 'Found register_token' );
count(2);
ok( mail() =~ m#a href="http://auth.example.com/register\?(.*?)"#,
'Found register token' );
$query = $1;
ok( $query =~ /register_token=/, 'Found register_token' );
ok(
$res = $client->_get( '/register', query => $query, accept => 'text/html' ),
'Push register_token'
);
expectOK($res);
count(1);
ok(
$res =
$client->_get( '/register', query => $query, accept => 'text/html' ),
'Push register_token'
);
expectOK($res);
ok(
mail() =~
m#Your login is.+?<b>(\w+)</b>.*?Your password is.+?<b>(.*?)</b>#s,
'Found user and password'
);
$user = $1;
$pwd = $2;
ok( $user eq 'fbar', 'Get good login' );
count(2);
ok(
mail() =~
m#Your login is.+?<b>(\w+)</b>.*?Your password is.+?<b>(.*?)</b>#s,
'Found user and password'
);
$user = $1;
$pwd = $2;
ok( $user eq 'fbar', 'Get good login' );
ok(
$res = $client->_post(
'/', IO::String->new('user=fbar&password=fbar'),
length => 23,
accept => 'text/html'
),
'Try to authenticate'
);
count(1);
expectCookie($res);
ok(
$res = $client->_post(
'/', IO::String->new('user=fbar&password=fbar'),
length => 23,
accept => 'text/html'
),
'Try to authenticate'
);
expectCookie($res);
}
count($maintests);
clean_sessions();
......
......@@ -3,8 +3,10 @@ use strict;
use IO::String;
BEGIN {
require 't/test-lib.pm';
require 't/smtp.pm';
eval {
require 't/test-lib.pm';
require 't/smtp.pm';
};
}
my ( $res, $host, $url, $query );
......@@ -13,9 +15,10 @@ my $mailSend = 0;
my $mail2 = 0;
SKIP: {
eval 'use GD::SecurityImage;use Image::Magick;';
eval
'require Email::Sender::Simple;use GD::SecurityImage;use Image::Magick;';
if ($@) {
skip 'Lasso not found', $maintests;
skip 'Missing dependencies', $maintests;
}
my $client = LLNG::Manager::Test->new(
......
......@@ -3,82 +3,90 @@ use strict;
use IO::String;
BEGIN {
require 't/test-lib.pm';
require 't/smtp.pm';
eval {
require 't/test-lib.pm';
require 't/smtp.pm';
};
}
my ( $res, $user, $pwd );
my $mailSend = 0;
my $maintests = 7;
my $mailSend = 0;
my $mail2 = 0;
my $client = LLNG::Manager::Test->new(
{
ini => {
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
authentication => 'Demo',
userDB => 'Same',
passwordDB => 'Demo',
captcha_mail_enabled => 0,
requireToken => 1,
portalDisplayResetPassword => 1,
}
SKIP: {
eval
'require Email::Sender::Simple;use GD::SecurityImage;use Image::Magick;';
if ($@) {
skip 'Missing dependencies', $maintests;
}
);
# Test form
# ------------------------
ok( $res = $client->_get( '/resetpwd', accept => 'text/html' ), 'Reset form', );
count(1);
my ( $host, $url, $query ) = expectForm( $res, '#', undef, 'mail', 'token' );
$query =~ s/mail=&//;
$query .= '&mail=dwho%40badwolf.org';
# Post email
ok(
$res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Post mail'
);
count(1);
ok( mail() =~ m#a href="http://auth.example.com/resetpwd\?(.*?)"#,
'Found link in mail' );
$query = $1;
count(1);
ok(
$res = $client->_get( '/resetpwd', query => $query, accept => 'text/html' ),
'Post mail token received by mail'
);
count(1);
( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' );
ok( $res->[2]->[0] =~ /newpassword/s, ' Ask for a new password' );
count(1);
$query .= '&newpassword=zz&confirmpassword=zz';
# Post new password
ok(
$res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Post new password'
);
count(1);
ok( mail() =~ /Your password was changed/, 'Password was changed' );
count(1);
#print STDERR Dumper($query);
my $client = LLNG::Manager::Test->new(
{
ini => {
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
authentication => 'Demo',
userDB => 'Same',
passwordDB => 'Demo',
captcha_mail_enabled => 0,
requireToken => 1,
portalDisplayResetPassword => 1,
}
}
);
# Test form
# ------------------------
ok( $res = $client->_get( '/resetpwd', accept => 'text/html' ),
'Reset form', );
my ( $host, $url, $query ) =
expectForm( $res, '#', undef, 'mail', 'token' );
$query =~ s/mail=&//;
$query .= '&mail=dwho%40badwolf.org';
# Post email
ok(
$res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Post mail'
);
ok( mail() =~ m#a href="http://auth.example.com/resetpwd\?(.*?)"#,
'Found link in mail' );
$query = $1;
ok(
$res =
$client->_get( '/resetpwd', query => $query, accept => 'text/html' ),
'Post mail token received by mail'
);
( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' );
ok( $res->[2]->[0] =~ /newpassword/s, ' Ask for a new password' );
$query .= '&newpassword=zz&confirmpassword=zz';
# Post new password
ok(
$res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Post new password'
);
ok( mail() =~ /Your password was changed/, 'Password was changed' );
#print STDERR Dumper($query);
}
count($maintests);
clean_sessions();
......
......@@ -3,80 +3,87 @@ use strict;
use IO::String;
BEGIN {
require 't/test-lib.pm';
require 't/smtp.pm';
eval {
require 't/test-lib.pm';
require 't/smtp.pm';
};
}
my ( $res, $user, $pwd );
my $mailSend = 0;
my $maintests = 7;
my $mailSend = 0;
my $mail2 = 0;
my $client = LLNG::Manager::Test->new(
{
ini => {
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
authentication => 'Demo',
userDB => 'Same',
passwordDB => 'Demo',
captcha_mail_enabled => 0,
portalDisplayResetPassword => 1,
}
SKIP: {
eval
'require Email::Sender::Simple;use GD::SecurityImage;use Image::Magick;';
if ($@) {
skip 'Missing dependencies', $maintests;
}
);
# Test form
# ------------------------
ok( $res = $client->_get( '/resetpwd', accept => 'text/html' ), 'Reset form', );
count(1);
my ( $host, $url, $query ) = expectForm( $res, '#', undef, 'mail' );
$query = 'mail=dwho%40badwolf.org';
# Post email
ok(
$res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Post mail'
);
count(1);
ok( mail() =~ m#a href="http://auth.example.com/resetpwd\?(.*?)"#,
'Found link in mail' );
$query = $1;
count(1);
ok(
$res = $client->_get( '/resetpwd', query => $query, accept => 'text/html' ),
'Post mail token received by mail'
);
count(1);
( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' );
ok( $res->[2]->[0] =~ /newpassword/s, ' Ask for a new password' );
count(1);
$query .= '&newpassword=zz&confirmpassword=zz';
# Post new password
ok(
$res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Post new password'
);
count(1);
ok( mail() =~ /Your password was changed/, 'Password was changed' );
count(1);
#print STDERR Dumper($query);
my $client = LLNG::Manager::Test->new(
{
ini => {
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
authentication => 'Demo',
userDB => 'Same',
passwordDB => 'Demo',
captcha_mail_enabled => 0,
portalDisplayResetPassword => 1,
}
}
);
# Test form
# ------------------------
ok( $res = $client->_get( '/resetpwd', accept => 'text/html' ),
'Reset form', );
my ( $host, $url, $query ) = expectForm( $res, '#', undef, 'mail' );
$query = 'mail=dwho%40badwolf.org';
# Post email
ok(
$res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Post mail'
);
ok( mail() =~ m#a href="http://auth.example.com/resetpwd\?(.*?)"#,
'Found link in mail' );
$query = $1;
ok(
$res =
$client->_get( '/resetpwd', query => $query, accept => 'text/html' ),
'Post mail token received by mail'
);
( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' );
ok( $res->[2]->[0] =~ /newpassword/s, ' Ask for a new password' );
$query .= '&newpassword=zz&confirmpassword=zz';
# Post new password
ok(
$res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Post new password'
);
ok( mail() =~ /Your password was changed/, 'Password was changed' );
#print STDERR Dumper($query);
}
count($maintests);
clean_sessions();
......
......@@ -55,6 +55,7 @@
"notifications": 0,
"passwordDB": "Null",
"portal": "http://auth.example.com/",
"portalDisplayResetPassword": 0,
"casStorage": "Apache::Session::File",
"casStorageOptions": {
"Directory": "t/sessions/saml",
......
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