find . -name '*.t' -exec perltidy -b {} \;
This commit is contained in:
parent
f988f0337c
commit
58aab2ad20
@ -7,21 +7,31 @@ use_ok('Test::Qpsmtpd');
|
||||
ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");
|
||||
is(($smtpd->command('EHLO localhost'))[0], 250, 'EHLO localhost');
|
||||
|
||||
is(($smtpd->command('MAIL FROM:<ask@perl.org>'))[0], 250, 'MAIL FROM:<ask@perl.org>');
|
||||
is($smtpd->transaction->sender->address, 'ask@perl.org', 'got the right sender');
|
||||
is(($smtpd->command('MAIL FROM:<ask@perl.org>'))[0],
|
||||
250, 'MAIL FROM:<ask@perl.org>');
|
||||
is($smtpd->transaction->sender->address, 'ask@perl.org',
|
||||
'got the right sender');
|
||||
|
||||
is(($smtpd->command('MAIL FROM:<ask @perl.org>'))[0], 250, 'MAIL FROM:<ask @perl.org>');
|
||||
is($smtpd->transaction->sender->address, 'ask @perl.org', 'got the right sender');
|
||||
is(($smtpd->command('MAIL FROM:<ask @perl.org>'))[0],
|
||||
250, 'MAIL FROM:<ask @perl.org>');
|
||||
is($smtpd->transaction->sender->address,
|
||||
'ask @perl.org',
|
||||
'got the right sender');
|
||||
|
||||
is(($smtpd->command('MAIL FROM:ask@perl.org'))[0], 250, 'MAIL FROM:ask@perl.org');
|
||||
is($smtpd->transaction->sender->format, '<ask@perl.org>', 'got the right sender');
|
||||
is(($smtpd->command('MAIL FROM:ask@perl.org'))[0],
|
||||
250, 'MAIL FROM:ask@perl.org');
|
||||
is($smtpd->transaction->sender->format,
|
||||
'<ask@perl.org>', 'got the right sender');
|
||||
|
||||
is(($smtpd->command('MAIL FROM:ask@[1.2.3.4]'))[0], 250, 'MAIL FROM:ask@[1.2.3.4]');
|
||||
is($smtpd->transaction->sender->format, '<ask@[1.2.3.4]>', 'got the right sender');
|
||||
is(($smtpd->command('MAIL FROM:ask@[1.2.3.4]'))[0],
|
||||
250, 'MAIL FROM:ask@[1.2.3.4]');
|
||||
is($smtpd->transaction->sender->format,
|
||||
'<ask@[1.2.3.4]>', 'got the right sender');
|
||||
|
||||
my $command = 'MAIL FROM:<ask@perl.org> SIZE=1230';
|
||||
is(($smtpd->command($command))[0], 250, $command);
|
||||
is($smtpd->transaction->sender->format, '<ask@perl.org>', 'got the right sender');
|
||||
is($smtpd->transaction->sender->format,
|
||||
'<ask@perl.org>', 'got the right sender');
|
||||
|
||||
$command = 'MAIL FROM:<>';
|
||||
is(($smtpd->command($command))[0], 250, $command);
|
||||
@ -29,7 +39,9 @@ is($smtpd->transaction->sender->format, '<>', 'got the right sender');
|
||||
|
||||
$command = 'MAIL FROM:<ask@p.qpsmtpd-test.askask.com> SIZE=1230';
|
||||
is(($smtpd->command($command))[0], 250, $command);
|
||||
is($smtpd->transaction->sender->format, '<ask@p.qpsmtpd-test.askask.com>', 'got the right sender');
|
||||
is($smtpd->transaction->sender->format,
|
||||
'<ask@p.qpsmtpd-test.askask.com>',
|
||||
'got the right sender');
|
||||
|
||||
$command = 'MAIL FROM:<ask@perl.org> SIZE=1230 CORRECT-WITHOUT-ARG';
|
||||
is(($smtpd->command($command))[0], 250, $command);
|
||||
@ -38,4 +50,3 @@ $command = 'MAIL FROM:';
|
||||
is(($smtpd->command($command))[0], 250, $command);
|
||||
is($smtpd->transaction->sender->format, '<>', 'got the right sender');
|
||||
|
||||
|
||||
|
26
t/auth.t
26
t/auth.t
@ -32,12 +32,14 @@ my $pass = 'good_pass';
|
||||
my $enc_plain = Qpsmtpd::Auth::e64(join("\0", '', $user, $pass));
|
||||
|
||||
# get_auth_details_plain: plain auth method handles credentials properly
|
||||
my ($loginas,$ruser,$passClear) = Qpsmtpd::Auth::get_auth_details_plain($smtpd, $enc_plain);
|
||||
my ($loginas, $ruser, $passClear) =
|
||||
Qpsmtpd::Auth::get_auth_details_plain($smtpd, $enc_plain);
|
||||
cmp_ok($user, 'eq', $user, "get_auth_details_plain, user");
|
||||
cmp_ok($passClear, 'eq', $pass, "get_auth_details_plain, password");
|
||||
|
||||
my $bad_auth = Qpsmtpd::Auth::e64(join("\0", 'loginas', 'user@foo', 'passer'));
|
||||
($loginas,$ruser,$passClear) = Qpsmtpd::Auth::get_auth_details_plain($smtpd, $bad_auth );
|
||||
($loginas, $ruser, $passClear) =
|
||||
Qpsmtpd::Auth::get_auth_details_plain($smtpd, $bad_auth);
|
||||
ok(!$loginas, "get_auth_details_plain, loginas -");
|
||||
ok(!$ruser, "get_auth_details_plain, user -");
|
||||
ok(!$passClear, "get_auth_details_plain, pass -");
|
||||
@ -50,12 +52,12 @@ $r = Qpsmtpd::Auth::SASL($smtpd, 'plain', $enc_plain);
|
||||
cmp_ok(OK, '==', $r, "plain auth");
|
||||
|
||||
if ($ENV{QPSMTPD_DEVELOPER} && is_interactive()) {
|
||||
|
||||
# same thing, but must be entered interactively
|
||||
print "answer: $enc_plain\n";
|
||||
$r = Qpsmtpd::Auth::SASL($smtpd, 'plain', '');
|
||||
cmp_ok(OK, '==', $r, "SASL, plain");
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
# LOGIN
|
||||
|
||||
@ -71,15 +73,15 @@ if ( $ENV{QPSMTPD_DEVELOPER} && is_interactive() ) {
|
||||
|
||||
# get_auth_details_login
|
||||
print "answer: $enc_pass\n";
|
||||
($ruser,$passClear) = Qpsmtpd::Auth::get_auth_details_login( $smtpd, $enc_user );
|
||||
($ruser, $passClear) =
|
||||
Qpsmtpd::Auth::get_auth_details_login($smtpd, $enc_user);
|
||||
cmp_ok($ruser, 'eq', $user, "get_auth_details_login, user +");
|
||||
cmp_ok($passClear, 'eq', $pass, "get_auth_details_login, pass +");
|
||||
|
||||
print "encoded pass: $enc_pass\n";
|
||||
$r = Qpsmtpd::Auth::SASL($smtpd, 'login', $enc_user);
|
||||
cmp_ok(OK, '==', $r, "SASL, login");
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
# CRAM-MD5
|
||||
|
||||
@ -87,7 +89,8 @@ if ( $ENV{QPSMTPD_DEVELOPER} && is_interactive() ) {
|
||||
print "starting SASL\n";
|
||||
|
||||
# since we don't have bidirection communication here, we pre-generate a ticket
|
||||
my $ticket = sprintf( '<%x.%x@%s>', rand(1000000), time(), $smtpd->config('me') );
|
||||
my $ticket =
|
||||
sprintf('<%x.%x@%s>', rand(1000000), time(), $smtpd->config('me'));
|
||||
my $hash_pass = hmac_md5_hex($ticket, $pass);
|
||||
my $enc_answer = Qpsmtpd::Auth::e64(join(' ', $user, $hash_pass));
|
||||
print "answer: $enc_answer\n";
|
||||
@ -95,13 +98,13 @@ if ( $ENV{QPSMTPD_DEVELOPER} && is_interactive() ) {
|
||||
cmp_ok($r[0], 'eq', $ticket, "get_auth_details_cram_md5, ticket");
|
||||
cmp_ok($r[1], 'eq', $user, "get_auth_details_cram_md5, user");
|
||||
cmp_ok($r[2], 'eq', $hash_pass, "get_auth_details_cram_md5, passHash");
|
||||
|
||||
#warn Data::Dumper::Dumper(\@r);
|
||||
|
||||
# this isn't going to work without bidirection communication to get the ticket
|
||||
#$r = Qpsmtpd::Auth::SASL($smtpd, 'cram-md5' );
|
||||
#cmp_ok( OK, '==', $r, "login auth");
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
sub is_interactive {
|
||||
|
||||
@ -123,7 +126,7 @@ sub is_interactive {
|
||||
|
||||
# ...it's directly attached to the terminal
|
||||
return -t *ARGV;
|
||||
};
|
||||
}
|
||||
|
||||
# If *ARGV isn't opened, it will be interactive if *STDIN is attached
|
||||
# to a terminal and either there are no files specified on the command line
|
||||
@ -131,7 +134,6 @@ sub is_interactive {
|
||||
return -t *STDIN && (@ARGV == 0 || $ARGV[0] eq '-');
|
||||
}
|
||||
|
||||
|
||||
__END__
|
||||
|
||||
if ( ref $r ) {
|
||||
|
11
t/config.t
11
t/config.t
@ -15,7 +15,7 @@ BEGIN { # need this to happen before anything else
|
||||
open my $me_config, '>', $f;
|
||||
print $me_config "some.host.example.org";
|
||||
close $me_config;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");
|
||||
@ -25,12 +25,13 @@ is($smtpd->config('me'), 'some.host.example.org', 'config("me")');
|
||||
# test for ignoring leading/trailing whitespace (relayclients has a
|
||||
# line with both)
|
||||
my $relayclients = join ",", sort $smtpd->config('relayclients');
|
||||
is($relayclients,
|
||||
is(
|
||||
$relayclients,
|
||||
'127.0.0.1,192.0.,2001:0DB8,2001:0DB8:0000:0000:0000:0000:0000:0001,2001:DB8::1,2001:DB8::1/32',
|
||||
'config("relayclients") are trimmed');
|
||||
'config("relayclients") are trimmed'
|
||||
);
|
||||
|
||||
foreach my $f (@mes) {
|
||||
unlink $f if -f $f;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
4
t/misc.t
4
t/misc.t
@ -9,9 +9,7 @@ ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");
|
||||
is(($smtpd->fault)->[0], 451, 'fault returns 451');
|
||||
is(($smtpd->fault("test message"))->[1],
|
||||
"Internal error - try again later - test message",
|
||||
'returns the input message'
|
||||
);
|
||||
|
||||
'returns the input message');
|
||||
|
||||
# vrfy command
|
||||
is(($smtpd->command('VRFY <foo@bar>'))[0], 252, 'VRFY command');
|
||||
|
@ -7,11 +7,8 @@ my $qp = Test::Qpsmtpd->new();
|
||||
|
||||
$qp->run_plugin_tests();
|
||||
|
||||
foreach my $file (
|
||||
"./t/config/greylist.dbm",
|
||||
"./t/config/greylist.dbm.lock"
|
||||
) {
|
||||
foreach my $file ("./t/config/greylist.dbm", "./t/config/greylist.dbm.lock") {
|
||||
next if !-f $file;
|
||||
unlink $file;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,8 @@ is ($ao->host, 'example.com', 'host');
|
||||
$as = '<"musa_ibrah@caramail.comandrea.luger"@wifo.ac.at>';
|
||||
$ao = Qpsmtpd::Address->parse($as);
|
||||
ok($ao, "parse $as");
|
||||
is ($ao->format, '<"musa_ibrah\@caramail.comandrea.luger"@wifo.ac.at>', "format $as");
|
||||
is($ao->format, '<"musa_ibrah\@caramail.comandrea.luger"@wifo.ac.at>',
|
||||
"format $as");
|
||||
|
||||
# email addresses with spaces
|
||||
$as = '<foo bar@example.com>';
|
||||
@ -63,7 +64,8 @@ ok ($ao = Qpsmtpd::Address->parse('<'.$as.'>'), "parse $as");
|
||||
is($ao && $ao->address, $as, "address $as");
|
||||
|
||||
# Not sure why we can change the address like this, but we can so test it ...
|
||||
is ($ao && $ao->address('test@example.com'), 'test@example.com', 'address(test@example.com)');
|
||||
is($ao && $ao->address('test@example.com'),
|
||||
'test@example.com', 'address(test@example.com)');
|
||||
|
||||
$as = '<foo@foo.x.example.com>';
|
||||
$ao = Qpsmtpd::Address->new($as);
|
||||
@ -76,8 +78,7 @@ ok ($ao = Qpsmtpd::Address->parse("<$as>"), "parse <$as>");
|
||||
is($ao && $ao->address, $as, "address $as");
|
||||
ok($ao eq $as, "overloaded 'cmp' operator");
|
||||
|
||||
my @unsorted_list = map { Qpsmtpd::Address->new($_) }
|
||||
qw(
|
||||
my @unsorted_list = map { Qpsmtpd::Address->new($_) } qw(
|
||||
"musa_ibrah@caramail.comandrea.luger"@wifo.ac.at
|
||||
foo@example.com
|
||||
ask@perl.org
|
||||
@ -87,8 +88,7 @@ my @unsorted_list = map { Qpsmtpd::Address->new($_) }
|
||||
);
|
||||
|
||||
# NOTE that this is sorted by _host_ not by _domain_
|
||||
my @sorted_list = map { Qpsmtpd::Address->new($_) }
|
||||
qw(
|
||||
my @sorted_list = map { Qpsmtpd::Address->new($_) } qw(
|
||||
jpeacock@cpan.org
|
||||
foo@example.com
|
||||
test@example.com
|
||||
|
6
t/rset.t
6
t/rset.t
@ -7,7 +7,9 @@ use_ok('Test::Qpsmtpd');
|
||||
ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");
|
||||
is(($smtpd->command('EHLO localhost'))[0], 250, 'EHLO localhost');
|
||||
|
||||
is(($smtpd->command('MAIL FROM:<ask@perl.org>'))[0], 250, 'MAIL FROM:<ask@perl.org>');
|
||||
is($smtpd->transaction->sender->address, 'ask@perl.org', 'got the right sender');
|
||||
is(($smtpd->command('MAIL FROM:<ask@perl.org>'))[0],
|
||||
250, 'MAIL FROM:<ask@perl.org>');
|
||||
is($smtpd->transaction->sender->address, 'ask@perl.org',
|
||||
'got the right sender');
|
||||
is(($smtpd->command('RSET'))[0], 250, 'RSET');
|
||||
is($smtpd->transaction->sender, undef, 'No sender stored after rset');
|
||||
|
@ -15,8 +15,8 @@ BEGIN { # need this to happen before anything else
|
||||
|
||||
ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");
|
||||
|
||||
my ($spool_dir,$tempfile,$tempdir) = ( $smtpd->spool_dir,
|
||||
$smtpd->temp_file(), $smtpd->temp_dir() );
|
||||
my ($spool_dir, $tempfile, $tempdir) =
|
||||
($smtpd->spool_dir, $smtpd->temp_file(), $smtpd->temp_dir());
|
||||
|
||||
ok($spool_dir =~ m!t/tmp/$!, "Located the spool directory");
|
||||
ok($tempfile =~ /^$spool_dir/, "Temporary filename");
|
||||
|
@ -6,13 +6,14 @@ use Test::More;
|
||||
|
||||
if (!$ENV{'QPSMTPD_DEVELOPER'}) {
|
||||
plan skip_all => "not a developer, skipping POD tests";
|
||||
};
|
||||
}
|
||||
|
||||
use lib 'lib';
|
||||
|
||||
my $this_perl = $Config{'perlpath'} || $EXECUTABLE_NAME;
|
||||
|
||||
my @files = find( {wanted=>\&test_syntax, no_chdir=>1}, 'plugins', 'lib', 't' );
|
||||
my @files =
|
||||
find({wanted => \&test_syntax, no_chdir => 1}, 'plugins', 'lib', 't');
|
||||
|
||||
sub test_syntax {
|
||||
my $f = $File::Find::name;
|
||||
@ -25,7 +26,7 @@ sub test_syntax {
|
||||
if ($exit_code == 0) {
|
||||
ok($exit_code == 0, "syntax $f");
|
||||
return;
|
||||
};
|
||||
}
|
||||
if ($r =~ /^Can't locate (.*?) in /) {
|
||||
ok(0 == 0, "skipping $f, I couldn't load w/o $1");
|
||||
return;
|
||||
@ -35,7 +36,7 @@ sub test_syntax {
|
||||
return;
|
||||
}
|
||||
print "ec: $exit_code, r: $r\n";
|
||||
};
|
||||
}
|
||||
|
||||
done_testing();
|
||||
|
||||
|
@ -11,7 +11,7 @@ eval "use Test::Pod 1.14";
|
||||
if ($@) {
|
||||
plan skip_all => "Test::Pod 1.14 required for testing POD";
|
||||
exit;
|
||||
};
|
||||
}
|
||||
|
||||
my @poddirs = qw( lib plugins );
|
||||
all_pod_files_ok(all_pod_files(@poddirs));
|
||||
|
Loading…
Reference in New Issue
Block a user