find . -name '*.t' -exec perltidy -b {} \;

This commit is contained in:
Matt Simerson 2013-04-21 00:52:07 -04:00
parent f988f0337c
commit 58aab2ad20
11 changed files with 185 additions and 173 deletions

View File

@ -7,21 +7,31 @@ use_ok('Test::Qpsmtpd');
ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection"); ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");
is(($smtpd->command('EHLO localhost'))[0], 250, 'EHLO localhost'); 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->command('MAIL FROM:<ask@perl.org>'))[0],
is($smtpd->transaction->sender->address, 'ask@perl.org', 'got the right sender'); 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->command('MAIL FROM:<ask @perl.org>'))[0],
is($smtpd->transaction->sender->address, 'ask @perl.org', 'got the right sender'); 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->command('MAIL FROM:ask@perl.org'))[0],
is($smtpd->transaction->sender->format, '<ask@perl.org>', 'got the right sender'); 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->command('MAIL FROM:ask@[1.2.3.4]'))[0],
is($smtpd->transaction->sender->format, '<ask@[1.2.3.4]>', 'got the right sender'); 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'; my $command = 'MAIL FROM:<ask@perl.org> SIZE=1230';
is(($smtpd->command($command))[0], 250, $command); 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:<>'; $command = 'MAIL FROM:<>';
is(($smtpd->command($command))[0], 250, $command); 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'; $command = 'MAIL FROM:<ask@p.qpsmtpd-test.askask.com> SIZE=1230';
is(($smtpd->command($command))[0], 250, $command); 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'; $command = 'MAIL FROM:<ask@perl.org> SIZE=1230 CORRECT-WITHOUT-ARG';
is(($smtpd->command($command))[0], 250, $command); is(($smtpd->command($command))[0], 250, $command);
@ -38,4 +50,3 @@ $command = 'MAIL FROM:';
is(($smtpd->command($command))[0], 250, $command); is(($smtpd->command($command))[0], 250, $command);
is($smtpd->transaction->sender->format, '<>', 'got the right sender'); is($smtpd->transaction->sender->format, '<>', 'got the right sender');

View File

@ -32,12 +32,14 @@ my $pass = 'good_pass';
my $enc_plain = Qpsmtpd::Auth::e64(join("\0", '', $user, $pass)); my $enc_plain = Qpsmtpd::Auth::e64(join("\0", '', $user, $pass));
# get_auth_details_plain: plain auth method handles credentials properly # 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($user, 'eq', $user, "get_auth_details_plain, user");
cmp_ok($passClear, 'eq', $pass, "get_auth_details_plain, password"); cmp_ok($passClear, 'eq', $pass, "get_auth_details_plain, password");
my $bad_auth = Qpsmtpd::Auth::e64(join("\0", 'loginas', 'user@foo', 'passer')); 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(!$loginas, "get_auth_details_plain, loginas -");
ok(!$ruser, "get_auth_details_plain, user -"); ok(!$ruser, "get_auth_details_plain, user -");
ok(!$passClear, "get_auth_details_plain, pass -"); 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"); cmp_ok(OK, '==', $r, "plain auth");
if ($ENV{QPSMTPD_DEVELOPER} && is_interactive()) { if ($ENV{QPSMTPD_DEVELOPER} && is_interactive()) {
# same thing, but must be entered interactively # same thing, but must be entered interactively
print "answer: $enc_plain\n"; print "answer: $enc_plain\n";
$r = Qpsmtpd::Auth::SASL($smtpd, 'plain', ''); $r = Qpsmtpd::Auth::SASL($smtpd, 'plain', '');
cmp_ok(OK, '==', $r, "SASL, plain"); cmp_ok(OK, '==', $r, "SASL, plain");
}; }
# LOGIN # LOGIN
@ -71,15 +73,15 @@ if ( $ENV{QPSMTPD_DEVELOPER} && is_interactive() ) {
# get_auth_details_login # get_auth_details_login
print "answer: $enc_pass\n"; 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($ruser, 'eq', $user, "get_auth_details_login, user +");
cmp_ok($passClear, 'eq', $pass, "get_auth_details_login, pass +"); cmp_ok($passClear, 'eq', $pass, "get_auth_details_login, pass +");
print "encoded pass: $enc_pass\n"; print "encoded pass: $enc_pass\n";
$r = Qpsmtpd::Auth::SASL($smtpd, 'login', $enc_user); $r = Qpsmtpd::Auth::SASL($smtpd, 'login', $enc_user);
cmp_ok(OK, '==', $r, "SASL, login"); cmp_ok(OK, '==', $r, "SASL, login");
}; }
# CRAM-MD5 # CRAM-MD5
@ -87,7 +89,8 @@ if ( $ENV{QPSMTPD_DEVELOPER} && is_interactive() ) {
print "starting SASL\n"; print "starting SASL\n";
# since we don't have bidirection communication here, we pre-generate a ticket # 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 $hash_pass = hmac_md5_hex($ticket, $pass);
my $enc_answer = Qpsmtpd::Auth::e64(join(' ', $user, $hash_pass)); my $enc_answer = Qpsmtpd::Auth::e64(join(' ', $user, $hash_pass));
print "answer: $enc_answer\n"; 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[0], 'eq', $ticket, "get_auth_details_cram_md5, ticket");
cmp_ok($r[1], 'eq', $user, "get_auth_details_cram_md5, user"); 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"); cmp_ok($r[2], 'eq', $hash_pass, "get_auth_details_cram_md5, passHash");
#warn Data::Dumper::Dumper(\@r); #warn Data::Dumper::Dumper(\@r);
# this isn't going to work without bidirection communication to get the ticket # this isn't going to work without bidirection communication to get the ticket
#$r = Qpsmtpd::Auth::SASL($smtpd, 'cram-md5' ); #$r = Qpsmtpd::Auth::SASL($smtpd, 'cram-md5' );
#cmp_ok( OK, '==', $r, "login auth"); #cmp_ok( OK, '==', $r, "login auth");
}; }
sub is_interactive { sub is_interactive {
@ -123,7 +126,7 @@ sub is_interactive {
# ...it's directly attached to the terminal # ...it's directly attached to the terminal
return -t *ARGV; return -t *ARGV;
}; }
# If *ARGV isn't opened, it will be interactive if *STDIN is attached # 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 # 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 '-'); return -t *STDIN && (@ARGV == 0 || $ARGV[0] eq '-');
} }
__END__ __END__
if ( ref $r ) { if ( ref $r ) {

View File

@ -15,7 +15,7 @@ BEGIN { # need this to happen before anything else
open my $me_config, '>', $f; open my $me_config, '>', $f;
print $me_config "some.host.example.org"; print $me_config "some.host.example.org";
close $me_config; close $me_config;
}; }
} }
ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection"); 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 # test for ignoring leading/trailing whitespace (relayclients has a
# line with both) # line with both)
my $relayclients = join ",", sort $smtpd->config('relayclients'); 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', '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) { foreach my $f (@mes) {
unlink $f if -f $f; unlink $f if -f $f;
}; }

View File

@ -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)->[0], 451, 'fault returns 451');
is(($smtpd->fault("test message"))->[1], is(($smtpd->fault("test message"))->[1],
"Internal error - try again later - test message", "Internal error - try again later - test message",
'returns the input message' 'returns the input message');
);
# vrfy command # vrfy command
is(($smtpd->command('VRFY <foo@bar>'))[0], 252, 'VRFY command'); is(($smtpd->command('VRFY <foo@bar>'))[0], 252, 'VRFY command');

View File

@ -7,11 +7,8 @@ my $qp = Test::Qpsmtpd->new();
$qp->run_plugin_tests(); $qp->run_plugin_tests();
foreach my $file ( foreach my $file ("./t/config/greylist.dbm", "./t/config/greylist.dbm.lock") {
"./t/config/greylist.dbm",
"./t/config/greylist.dbm.lock"
) {
next if !-f $file; next if !-f $file;
unlink $file; unlink $file;
}; }

View File

@ -35,7 +35,8 @@ is ($ao->host, 'example.com', 'host');
$as = '<"musa_ibrah@caramail.comandrea.luger"@wifo.ac.at>'; $as = '<"musa_ibrah@caramail.comandrea.luger"@wifo.ac.at>';
$ao = Qpsmtpd::Address->parse($as); $ao = Qpsmtpd::Address->parse($as);
ok($ao, "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 # email addresses with spaces
$as = '<foo bar@example.com>'; $as = '<foo bar@example.com>';
@ -63,7 +64,8 @@ ok ($ao = Qpsmtpd::Address->parse('<'.$as.'>'), "parse $as");
is($ao && $ao->address, $as, "address $as"); is($ao && $ao->address, $as, "address $as");
# Not sure why we can change the address like this, but we can so test it ... # 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>'; $as = '<foo@foo.x.example.com>';
$ao = Qpsmtpd::Address->new($as); $ao = Qpsmtpd::Address->new($as);
@ -76,8 +78,7 @@ ok ($ao = Qpsmtpd::Address->parse("<$as>"), "parse <$as>");
is($ao && $ao->address, $as, "address $as"); is($ao && $ao->address, $as, "address $as");
ok($ao eq $as, "overloaded 'cmp' operator"); ok($ao eq $as, "overloaded 'cmp' operator");
my @unsorted_list = map { Qpsmtpd::Address->new($_) } my @unsorted_list = map { Qpsmtpd::Address->new($_) } qw(
qw(
"musa_ibrah@caramail.comandrea.luger"@wifo.ac.at "musa_ibrah@caramail.comandrea.luger"@wifo.ac.at
foo@example.com foo@example.com
ask@perl.org ask@perl.org
@ -87,8 +88,7 @@ my @unsorted_list = map { Qpsmtpd::Address->new($_) }
); );
# NOTE that this is sorted by _host_ not by _domain_ # NOTE that this is sorted by _host_ not by _domain_
my @sorted_list = map { Qpsmtpd::Address->new($_) } my @sorted_list = map { Qpsmtpd::Address->new($_) } qw(
qw(
jpeacock@cpan.org jpeacock@cpan.org
foo@example.com foo@example.com
test@example.com test@example.com

View File

@ -7,7 +7,9 @@ use_ok('Test::Qpsmtpd');
ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection"); ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");
is(($smtpd->command('EHLO localhost'))[0], 250, 'EHLO localhost'); 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->command('MAIL FROM:<ask@perl.org>'))[0],
is($smtpd->transaction->sender->address, 'ask@perl.org', 'got the right sender'); 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->command('RSET'))[0], 250, 'RSET');
is($smtpd->transaction->sender, undef, 'No sender stored after rset'); is($smtpd->transaction->sender, undef, 'No sender stored after rset');

View File

@ -15,8 +15,8 @@ BEGIN { # need this to happen before anything else
ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection"); ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");
my ($spool_dir,$tempfile,$tempdir) = ( $smtpd->spool_dir, my ($spool_dir, $tempfile, $tempdir) =
$smtpd->temp_file(), $smtpd->temp_dir() ); ($smtpd->spool_dir, $smtpd->temp_file(), $smtpd->temp_dir());
ok($spool_dir =~ m!t/tmp/$!, "Located the spool directory"); ok($spool_dir =~ m!t/tmp/$!, "Located the spool directory");
ok($tempfile =~ /^$spool_dir/, "Temporary filename"); ok($tempfile =~ /^$spool_dir/, "Temporary filename");

View File

@ -6,13 +6,14 @@ use Test::More;
if (!$ENV{'QPSMTPD_DEVELOPER'}) { if (!$ENV{'QPSMTPD_DEVELOPER'}) {
plan skip_all => "not a developer, skipping POD tests"; plan skip_all => "not a developer, skipping POD tests";
}; }
use lib 'lib'; use lib 'lib';
my $this_perl = $Config{'perlpath'} || $EXECUTABLE_NAME; 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 { sub test_syntax {
my $f = $File::Find::name; my $f = $File::Find::name;
@ -25,7 +26,7 @@ sub test_syntax {
if ($exit_code == 0) { if ($exit_code == 0) {
ok($exit_code == 0, "syntax $f"); ok($exit_code == 0, "syntax $f");
return; return;
}; }
if ($r =~ /^Can't locate (.*?) in /) { if ($r =~ /^Can't locate (.*?) in /) {
ok(0 == 0, "skipping $f, I couldn't load w/o $1"); ok(0 == 0, "skipping $f, I couldn't load w/o $1");
return; return;
@ -35,7 +36,7 @@ sub test_syntax {
return; return;
} }
print "ec: $exit_code, r: $r\n"; print "ec: $exit_code, r: $r\n";
}; }
done_testing(); done_testing();

View File

@ -11,7 +11,7 @@ eval "use Test::Pod 1.14";
if ($@) { if ($@) {
plan skip_all => "Test::Pod 1.14 required for testing POD"; plan skip_all => "Test::Pod 1.14 required for testing POD";
exit; exit;
}; }
my @poddirs = qw( lib plugins ); my @poddirs = qw( lib plugins );
all_pod_files_ok(all_pod_files(@poddirs)); all_pod_files_ok(all_pod_files(@poddirs));