Merge pull request #148 from jaredj/sub-semicolons

Remove extraneous semicolons
This commit is contained in:
Matt Simerson 2014-11-11 15:27:27 -08:00
commit 7ba86cb5a2
35 changed files with 167 additions and 167 deletions

View File

@ -40,7 +40,7 @@ my @failed;
foreach ( @$apps ) { foreach ( @$apps ) {
my $name = $_->{app} or die 'missing app name'; my $name = $_->{app} or die 'missing app name';
install_app( $name, $_->{info} ); install_app( $name, $_->{info} );
}; }
foreach ( get_perl_modules() ) { foreach ( get_perl_modules() ) {
#print Dumper($_); #print Dumper($_);
@ -78,7 +78,7 @@ sub get_perl_modules {
return get_perl_modules_from_Makefile_PL(); return get_perl_modules_from_Makefile_PL();
}; };
die "unable to find module list. Run this script in the dist dir\n"; die "unable to find module list. Run this script in the dist dir\n";
}; }
sub get_perl_modules_from_Makefile_PL { sub get_perl_modules_from_Makefile_PL {
my $fh = new IO::File 'Makefile.PL', 'r' my $fh = new IO::File 'Makefile.PL', 'r'
@ -102,7 +102,7 @@ sub get_perl_modules_from_Makefile_PL {
} }
$fh->close; $fh->close;
return @modules; return @modules;
}; }
sub get_perl_modules_from_ini { sub get_perl_modules_from_ini {
my $fh = new IO::File 'dist.ini', 'r' my $fh = new IO::File 'dist.ini', 'r'
@ -127,7 +127,7 @@ sub get_perl_modules_from_ini {
$fh->close; $fh->close;
#print Dumper(\@modules); #print Dumper(\@modules);
return @modules; return @modules;
}; }
sub install_app { sub install_app {
my ( $app, $info) = @_; my ( $app, $info) = @_;
@ -142,7 +142,7 @@ sub install_app {
install_app_linux( $app, $info ); install_app_linux( $app, $info );
}; };
}; }
sub install_app_darwin { sub install_app_darwin {
my ($app, $info ) = @_; my ($app, $info ) = @_;
@ -181,7 +181,7 @@ sub install_app_freebsd {
system "make install clean" system "make install clean"
and warn "'make install clean' failed for port $app\n"; and warn "'make install clean' failed for port $app\n";
}; };
}; }
sub install_app_linux { sub install_app_linux {
my ($app, $info ) = @_; my ($app, $info ) = @_;
@ -197,7 +197,7 @@ sub install_app_linux {
else { else {
warn "no Linux package manager detected\n"; warn "no Linux package manager detected\n";
}; };
}; }
sub install_module { sub install_module {
@ -220,7 +220,7 @@ sub install_module {
return 1 if ! $EVAL_ERROR; return 1 if ! $EVAL_ERROR;
install_module_cpan($module, $version); install_module_cpan($module, $version);
}; }
sub install_module_cpan { sub install_module_cpan {
@ -309,7 +309,7 @@ sub install_module_linux {
return install_module_linux_apt($module, $info); return install_module_linux_apt($module, $info);
} }
warn "no Linux package manager detected\n"; warn "no Linux package manager detected\n";
}; }
sub install_module_linux_yum { sub install_module_linux_yum {
my ($module, $info) = @_; my ($module, $info) = @_;
@ -322,7 +322,7 @@ sub install_module_linux_yum {
$package =~ s/::/-/g; $package =~ s/::/-/g;
}; };
system "/usr/bin/yum -y install $package"; system "/usr/bin/yum -y install $package";
}; }
sub install_module_linux_apt { sub install_module_linux_apt {
my ($module, $info) = @_; my ($module, $info) = @_;
@ -335,7 +335,7 @@ sub install_module_linux_apt {
$package =~ s/::/-/g; $package =~ s/::/-/g;
}; };
system "/usr/bin/apt-get -y install $package"; system "/usr/bin/apt-get -y install $package";
}; }
sub get_cpan_config { sub get_cpan_config {
@ -397,4 +397,4 @@ sub name_overrides {
my ($match) = grep { $_->{module} eq $mod } @modules; my ($match) = grep { $_->{module} eq $mod } @modules;
return $match if $match; return $match if $match;
return { module=>$mod, info => { } }; return { module=>$mod, info => { } };
}; }

View File

@ -6,7 +6,7 @@ use Net::IP;
sub new { sub new {
return bless {}, shift; return bless {}, shift;
}; }
sub tildeexp { sub tildeexp {
my ($self, $path) = @_; my ($self, $path) = @_;
@ -44,7 +44,7 @@ sub is_ipv6 {
my ($self, $ip) = @_; my ($self, $ip) = @_;
return if !$ip; return if !$ip;
return Net::IP::ip_is_ipv6($ip); return Net::IP::ip_is_ipv6($ip);
}; }
sub get_resolver { sub get_resolver {
my ($self, %args) = @_; my ($self, %args) = @_;

View File

@ -276,7 +276,7 @@ sub store_auth_results {
my $ar = join('; ', $auths, $result); my $ar = join('; ', $auths, $result);
$self->log(LOGDEBUG, "auth-results: $ar"); $self->log(LOGDEBUG, "auth-results: $ar");
$self->qp->connection->notes('authentication_results', $ar ); $self->qp->connection->notes('authentication_results', $ar );
}; }
sub is_immune { sub is_immune {
my $self = shift; my $self = shift;

View File

@ -552,7 +552,7 @@ sub get_config {
$values{$key} = $val; $values{$key} = $val;
}; };
return %values; return %values;
}; }
sub get_config_contents { sub get_config_contents {
my $name = shift; my $name = shift;
@ -569,7 +569,7 @@ sub get_config_contents {
my @contents = <$fh>; my @contents = <$fh>;
return @contents; return @contents;
}; };
}; }
sub check_plugins_table { sub check_plugins_table {
my $rows = exec_query( 'SELECT COUNT(*) FROM plugin'); my $rows = exec_query( 'SELECT COUNT(*) FROM plugin');
@ -591,7 +591,7 @@ sub check_plugins_table {
exec_query($aq, [$id, $alias]); exec_query($aq, [$id, $alias]);
}; };
}; };
}; }
sub exec_query { sub exec_query {
my $query = shift; my $query = shift;

View File

@ -100,7 +100,7 @@ sub get_default_field_widths {
); );
return %widths; return %widths;
}; }
sub handle_plugin { sub handle_plugin {
my ($message, $plugin, $pid, $line) = @_; my ($message, $plugin, $pid, $line) = @_;

View File

@ -81,7 +81,7 @@ sub get_response {
}; };
return $response; return $response;
}; }
sub get_socket { sub get_socket {
my ($self) = @_; my ($self) = @_;
@ -99,7 +99,7 @@ sub get_socket {
return; return;
}; };
return $socket; return $socket;
}; }
__END__ __END__

View File

@ -138,7 +138,7 @@ sub wait_length {
return $self->connection->notes('earlytalker_wait'); return $self->connection->notes('earlytalker_wait');
} }
return $self->{_args}{wait}; return $self->{_args}{wait};
}; }
sub apr_connect_handler { sub apr_connect_handler {
my ($self, $transaction) = @_; my ($self, $transaction) = @_;

View File

@ -168,7 +168,7 @@ sub has_required_headers {
$self->log(LOGINFO, "fail, no $h header" ); $self->log(LOGINFO, "fail, no $h header" );
} }
return $errors; return $errors;
}; }
sub has_singular_headers { sub has_singular_headers {
my ($self, $header) = @_; my ($self, $header) = @_;
@ -187,7 +187,7 @@ sub has_singular_headers {
$self->log(LOGINFO, "fail, too many $h headers" ); $self->log(LOGINFO, "fail, too many $h headers" );
} }
return $errors; return $errors;
}; }
sub invalid_date_range { sub invalid_date_range {
my $self = shift; my $self = shift;

View File

@ -347,11 +347,11 @@ sub from_handler {
if ( $sender->host && ".$tld" eq substr($sender->host,-$len,$len) ) { if ( $sender->host && ".$tld" eq substr($sender->host,-$len,$len) ) {
$self->log(LOGINFO, "penalizing .$tld envelope sender"); $self->log(LOGINFO, "penalizing .$tld envelope sender");
$self->adjust_karma(-$score); $self->adjust_karma(-$score);
}; }
}; }
return DECLINED; return DECLINED;
}; }
sub rcpt_handler { sub rcpt_handler {
my ($self,$transaction, $recipient, %args) = @_; my ($self,$transaction, $recipient, %args) = @_;
@ -365,7 +365,7 @@ sub rcpt_handler {
if ( $count > 1 ) { if ( $count > 1 ) {
$self->log(LOGINFO, "recipients c: $count ($recipient)"); $self->log(LOGINFO, "recipients c: $count ($recipient)");
$self->connection->notes('recipient_count', $count); $self->connection->notes('recipient_count', $count);
}; }
return DECLINED if $self->is_immune(); return DECLINED if $self->is_immune();
@ -379,13 +379,13 @@ sub rcpt_handler {
if ( $history > 0 ) { if ( $history > 0 ) {
$self->log(LOGINFO, "info, good history"); $self->log(LOGINFO, "info, good history");
return DECLINED; return DECLINED;
}; }
my $karma = $self->connection->notes('karma'); my $karma = $self->connection->notes('karma');
if ( $karma > 0 ) { if ( $karma > 0 ) {
$self->log(LOGINFO, "info, good connection"); $self->log(LOGINFO, "info, good connection");
return DECLINED; return DECLINED;
}; }
# limit # of recipients if host has negative or unknown karma # limit # of recipients if host has negative or unknown karma
return DENY, "too many recipients for karma $karma (h: $history)"; return DENY, "too many recipients for karma $karma (h: $history)";
@ -401,7 +401,7 @@ sub data_handler {
my $karma = $self->connection->notes('karma'); my $karma = $self->connection->notes('karma');
if ( $karma < -4 ) { # bad karma if ( $karma < -4 ) { # bad karma
return $self->get_reject("very bad karma: $karma"); return $self->get_reject("very bad karma: $karma");
}; }
return DECLINED; return DECLINED;
} }
@ -461,8 +461,8 @@ sub illegal_envelope_format {
if ( uc substr($addr,0,6) ne 'FROM:<' && uc substr($addr,0,4) ne 'TO:<' ) { if ( uc substr($addr,0,6) ne 'FROM:<' && uc substr($addr,0,4) ne 'TO:<' ) {
$self->log(LOGINFO, "illegal envelope address format: $addr" ); $self->log(LOGINFO, "illegal envelope address format: $addr" );
$self->adjust_karma(-2); $self->adjust_karma(-2);
}; }
}; }
sub parse_db_record { sub parse_db_record {
my ($self, $value) = @_; my ($self, $value) = @_;

View File

@ -154,5 +154,5 @@ sub get_load_method {
$self->log(LOGERROR, "unable to acquire system load"); $self->log(LOGERROR, "unable to acquire system load");
return; return;
}; }

View File

@ -16,7 +16,7 @@ sub get_qp_version {
my ($ver_line) = grep { $_ =~ /^our \$VERSION/ } @$rvfile; my ($ver_line) = grep { $_ =~ /^our \$VERSION/ } @$rvfile;
my ($ver) = $ver_line =~ /['"]([0-9\.]+)['"]/; my ($ver) = $ver_line =~ /['"]([0-9\.]+)['"]/;
return $ver; return $ver;
}; }
sub get_rpm_version { sub get_rpm_version {
my $rvfile = get_file_contents('packaging/rpm/VERSION') my $rvfile = get_file_contents('packaging/rpm/VERSION')
@ -33,4 +33,4 @@ sub get_file_contents {
}; };
my @r = <$fh>; my @r = <$fh>;
return \@r; return \@r;
}; }

View File

@ -10,12 +10,12 @@ sub register_tests {
if ( ! $vpopdir ) { if ( ! $vpopdir ) {
warn "skipping tests, vpopmail not installed\n"; warn "skipping tests, vpopmail not installed\n";
return; return;
}; }
if ( ! -d "$vpopdir/domains/example.com" ) { if ( ! -d "$vpopdir/domains/example.com" ) {
warn "skipping tests, no example users set up.\n"; warn "skipping tests, no example users set up.\n";
return; return;
}; }
$self->register_test("test_auth_checkpassword"); $self->register_test("test_auth_checkpassword");
} }

View File

@ -25,7 +25,7 @@ sub test_auth_vpopmail {
warn "vpopmail plugin not configured\n"; warn "vpopmail plugin not configured\n";
foreach ( 0..2) { ok( 1, "skipped") }; foreach ( 0..2) { ok( 1, "skipped") };
return; return;
}; }
my ($tran, $ret, $note, $u, $r, $p, $a ); my ($tran, $ret, $note, $u, $r, $p, $a );
$tran = $self->qp->transaction; $tran = $self->qp->transaction;

View File

@ -10,7 +10,7 @@ sub register_tests {
if ( $@ ) { if ( $@ ) {
warn "skipping auth_vpopmail_sql tests, is DBI installed?\n"; warn "skipping auth_vpopmail_sql tests, is DBI installed?\n";
return; return;
}; }
$self->register_test("auth_vpopmail_sql"); $self->register_test("auth_vpopmail_sql");
} }
@ -21,7 +21,7 @@ sub auth_vpopmail_sql {
my $dbh = $self->get_db_handle() or do { my $dbh = $self->get_db_handle() or do {
foreach ( 0..2 ) { foreach ( 0..2 ) {
ok( 1, "skipped (no DB)" ); ok( 1, "skipped (no DB)" );
}; }
return; return;
}; };
ok( $dbh, "auth_vpopmail_sql, got a dbh" ); ok( $dbh, "auth_vpopmail_sql, got a dbh" );
@ -30,9 +30,9 @@ sub auth_vpopmail_sql {
if ( ! $vuser || ! $vuser->{pw_passwd} ) { if ( ! $vuser || ! $vuser->{pw_passwd} ) {
foreach ( 0..1 ) { foreach ( 0..1 ) {
ok( 1, "no example.com domain" ); ok( 1, "no example.com domain" );
}; }
return; return;
}; }
ok( ref $vuser, "found example.com domain" ); ok( ref $vuser, "found example.com domain" );
ok( $self->auth_vmysql( ok( $self->auth_vmysql(

View File

@ -35,7 +35,7 @@ sub test_badmailfrom_is_immune_sender {
$address = Qpsmtpd::Address->new( '<matt@example.com>' ); $address = Qpsmtpd::Address->new( '<matt@example.com>' );
$transaction->sender($address); $transaction->sender($address);
ok( ! $self->is_immune_sender( $transaction->sender, ['bad@example.com'] ), "false"); ok( ! $self->is_immune_sender( $transaction->sender, ['bad@example.com'] ), "false");
}; }
sub test_badmailfrom_hook_mail { sub test_badmailfrom_hook_mail {
my $self = shift; my $self = shift;
@ -60,7 +60,7 @@ sub test_badmailfrom_hook_mail {
($r, $err) = $self->hook_mail( $transaction, $address ); ($r, $err) = $self->hook_mail( $transaction, $address );
cmp_ok( $r, '==', DENY, "hook_mail rc"); cmp_ok( $r, '==', DENY, "hook_mail rc");
cmp_ok( $err, 'eq', 'Yer a spammin bastert', "custom reason"); cmp_ok( $err, 'eq', 'Yer a spammin bastert', "custom reason");
}; }
sub test_badmailfrom_match { sub test_badmailfrom_match {
my $self = shift; my $self = shift;
@ -87,7 +87,7 @@ sub test_badmailfrom_match {
ok( ! $self->is_match( 'matt@test.net', 'test.not$', 'tnpi.net' ), ok( ! $self->is_match( 'matt@test.net', 'test.not$', 'tnpi.net' ),
"pattern non-match"); "pattern non-match");
}; }
sub _reset_connection_flags { sub _reset_connection_flags {
my $self = shift; my $self = shift;
@ -95,5 +95,5 @@ sub _reset_connection_flags {
$self->qp->connection->notes('whitelisthost', 0); $self->qp->connection->notes('whitelisthost', 0);
$self->connection->notes('naughty',0); $self->connection->notes('naughty',0);
$self->connection->notes('rejected', 0); $self->connection->notes('rejected', 0);
}; }

View File

@ -30,5 +30,5 @@ sub test_badmailfromto_is_sender_immune {
$transaction->sender( Qpsmtpd::Address->new( '<matt@example.com>' ) ); $transaction->sender( Qpsmtpd::Address->new( '<matt@example.com>' ) );
ok( ! $self->is_sender_immune( $transaction->sender, ['bad@example.com'] ), "false"); ok( ! $self->is_sender_immune( $transaction->sender, ['bad@example.com'] ), "false");
}; }

View File

@ -19,7 +19,7 @@ sub _reset_connection_flags {
$self->qp->connection->notes('whitelisthost', 0); $self->qp->connection->notes('whitelisthost', 0);
$self->connection->notes('naughty',0); $self->connection->notes('naughty',0);
$self->connection->notes('rejected', 0); $self->connection->notes('rejected', 0);
}; }
sub test_is_match { sub test_is_match {
my $self = shift; my $self = shift;
@ -55,7 +55,7 @@ sub test_is_match {
ok( ! $self->is_match( 'matt@example.com', 'example.not$', 'tnpi.com' ), ok( ! $self->is_match( 'matt@example.com', 'example.not$', 'tnpi.com' ),
"pattern non-match"); "pattern non-match");
}; }
sub test_hook_rcpt { sub test_hook_rcpt {
my $self = shift; my $self = shift;
@ -75,7 +75,7 @@ sub test_hook_rcpt {
$recipient = Qpsmtpd::Address->new( '<any@bad.example.com>' ); $recipient = Qpsmtpd::Address->new( '<any@bad.example.com>' );
($r, $mess) = $self->hook_rcpt( $transaction, $recipient ); ($r, $mess) = $self->hook_rcpt( $transaction, $recipient );
cmp_ok( $r, '==', DENY, "bad host match, +, $mess"); cmp_ok( $r, '==', DENY, "bad host match, +, $mess");
}; }
sub test_get_host_and_to { sub test_get_host_and_to {
my $self = shift; my $self = shift;
@ -99,4 +99,4 @@ sub test_get_host_and_to {
($host, $to) = $self->get_host_and_to( $recipient ); ($host, $to) = $self->get_host_and_to( $recipient );
cmp_ok( $host, 'eq', 'example.com', "case normalized +"); cmp_ok( $host, 'eq', 'example.com', "case normalized +");
cmp_ok( $to, 'eq', 'user@example.com', "case normalized +"); cmp_ok( $to, 'eq', 'user@example.com', "case normalized +");
}; }

View File

@ -9,7 +9,7 @@ sub register_tests {
my $self = shift; my $self = shift;
$self->register_test('test_hook_unrecognized_command'); $self->register_test('test_hook_unrecognized_command');
}; }
sub test_hook_unrecognized_command { sub test_hook_unrecognized_command {
my $self = shift; my $self = shift;
@ -28,4 +28,4 @@ sub test_hook_unrecognized_command {
cmp_ok( $code, '==', DENY_DISCONNECT, "over limit" ); cmp_ok( $code, '==', DENY_DISCONNECT, "over limit" );
cmp_ok( $self->connection->notes( 'unrec_cmd_count'), '==', 4, "correct increment" ); cmp_ok( $self->connection->notes( 'unrec_cmd_count'), '==', 4, "correct increment" );
}; }

View File

@ -29,7 +29,7 @@ sub setup_test_headers {
$transaction->body_write( "test message body " ); $transaction->body_write( "test message body " );
$self->qp->connection->relay_client(0); $self->qp->connection->relay_client(0);
}; }
sub test_fetch_dmarc_record { sub test_fetch_dmarc_record {
my $self = shift; my $self = shift;
@ -37,12 +37,12 @@ sub test_fetch_dmarc_record {
foreach ( qw/ tnpi.net nictool.com / ) { foreach ( qw/ tnpi.net nictool.com / ) {
my @matches = $self->fetch_dmarc_record($_); my @matches = $self->fetch_dmarc_record($_);
cmp_ok( scalar @matches, '==', 1, 'fetch_dmarc_record'); cmp_ok( scalar @matches, '==', 1, 'fetch_dmarc_record');
}; }
foreach ( qw/ example.com / ) { foreach ( qw/ example.com / ) {
my @matches = $self->fetch_dmarc_record($_); my @matches = $self->fetch_dmarc_record($_);
cmp_ok( scalar @matches, '==', 0, 'fetch_dmarc_record'); cmp_ok( scalar @matches, '==', 0, 'fetch_dmarc_record');
}; }
}; }
sub test_get_organizational_domain { sub test_get_organizational_domain {
my $self = shift; my $self = shift;
@ -53,7 +53,7 @@ sub test_get_organizational_domain {
cmp_ok( $self->get_organizational_domain('test.www.tnpi.net'), 'eq', 'tnpi.net' ); cmp_ok( $self->get_organizational_domain('test.www.tnpi.net'), 'eq', 'tnpi.net' );
cmp_ok( $self->get_organizational_domain('www.example.co.uk'), 'eq', 'example.co.uk' ); cmp_ok( $self->get_organizational_domain('www.example.co.uk'), 'eq', 'example.co.uk' );
cmp_ok( $self->get_organizational_domain('plus.google.com'), 'eq', 'google.com' ); cmp_ok( $self->get_organizational_domain('plus.google.com'), 'eq', 'google.com' );
}; }
sub test_discover_policy { sub test_discover_policy {
my $self = shift; my $self = shift;
@ -61,4 +61,4 @@ sub test_discover_policy {
$self->setup_test_headers(); $self->setup_test_headers();
ok( $self->discover_policy( 'tnpi.net' ), 'discover_policy' ); ok( $self->discover_policy( 'tnpi.net' ), 'discover_policy' );
}; }

View File

@ -27,7 +27,7 @@ sub test_ip_whitelisted {
$self->qp->connection->notes('whitelisthost', 'hello honey!'); $self->qp->connection->notes('whitelisthost', 'hello honey!');
ok( $self->ip_whitelisted(), "+"); ok( $self->ip_whitelisted(), "+");
$self->qp->connection->notes('whitelisthost', undef); $self->qp->connection->notes('whitelisthost', undef);
}; }
sub test_is_set_rblsmtpd { sub test_is_set_rblsmtpd {
my $self = shift; my $self = shift;
@ -43,7 +43,7 @@ sub test_is_set_rblsmtpd {
$ENV{RBLSMTPD} = ''; $ENV{RBLSMTPD} = '';
cmp_ok( 1,'==',$self->is_set_rblsmtpd('10.1.1.1'), "empty"); cmp_ok( 1,'==',$self->is_set_rblsmtpd('10.1.1.1'), "empty");
}; }
sub test_hook_connect { sub test_hook_connect {
my $self = shift; my $self = shift;
@ -62,7 +62,7 @@ sub test_hook_connect {
} }
else { else {
ok( 1, "connect +, skipped (is DNS working?)" ); ok( 1, "connect +, skipped (is DNS working?)" );
}; }
} }
sub test_reject_type { sub test_reject_type {
@ -76,4 +76,4 @@ sub test_reject_type {
$self->{_args}{reject_type} = 'disconnect'; $self->{_args}{reject_type} = 'disconnect';
cmp_ok( $self->get_reject_type(), '==', DENY_DISCONNECT, "disconnect"); cmp_ok( $self->get_reject_type(), '==', DENY_DISCONNECT, "disconnect");
}; }

View File

@ -56,7 +56,7 @@ sub test_log_and_return {
$transaction->notes('dspam', { class=> 'Innocent', probability => .96, confidence=>1 } ); $transaction->notes('dspam', { class=> 'Innocent', probability => .96, confidence=>1 } );
($r) = $self->log_and_return( $transaction ); ($r) = $self->log_and_return( $transaction );
cmp_ok( $r, '==', DECLINED, "($r)"); cmp_ok( $r, '==', DECLINED, "($r)");
}; }
sub test_get_dspam_results { sub test_get_dspam_results {
my $self = shift; my $self = shift;
@ -79,8 +79,8 @@ sub test_get_dspam_results {
$transaction->header->add('X-DSPAM-Result', $header); $transaction->header->add('X-DSPAM-Result', $header);
my $r = $self->get_dspam_results($transaction); my $r = $self->get_dspam_results($transaction);
ok( ref $r, "r: ($header)" ); ok( ref $r, "r: ($header)" );
}; }
}; }
sub test_reject_type { sub test_reject_type {
my $self = shift; my $self = shift;
@ -93,4 +93,4 @@ sub test_reject_type {
$self->{_args}{reject_type} = 'disconnect'; $self->{_args}{reject_type} = 'disconnect';
cmp_ok( $self->get_reject_type(), '==', DENY_DISCONNECT, "disconnect"); cmp_ok( $self->get_reject_type(), '==', DENY_DISCONNECT, "disconnect");
}; }

View File

@ -33,7 +33,7 @@ sub test_apr_connect_handler {
$self->qp->connection->notes('whitelisthost', 0); $self->qp->connection->notes('whitelisthost', 0);
($code, $mess) = $self->apr_connect_handler(); ($code, $mess) = $self->apr_connect_handler();
cmp_ok( $code, '==', DECLINED, "not sure"); cmp_ok( $code, '==', DECLINED, "not sure");
}; }
sub test_apr_data_handler { sub test_apr_data_handler {
my $self = shift; my $self = shift;
@ -50,7 +50,7 @@ sub test_apr_data_handler {
$self->qp->connection->notes('whitelisthost', 0); $self->qp->connection->notes('whitelisthost', 0);
($code, $mess) = $self->apr_data_handler(); ($code, $mess) = $self->apr_data_handler();
cmp_ok( $code, '==', DECLINED, "not sure"); cmp_ok( $code, '==', DECLINED, "not sure");
}; }
sub test_connect_handler { sub test_connect_handler {
my $self = shift; my $self = shift;
@ -67,7 +67,7 @@ sub test_connect_handler {
$self->qp->connection->notes('whitelisthost', 0); $self->qp->connection->notes('whitelisthost', 0);
($code, $mess) = $self->connect_handler(); ($code, $mess) = $self->connect_handler();
cmp_ok( $code, '==', DECLINED, "not sure"); cmp_ok( $code, '==', DECLINED, "not sure");
}; }
sub test_data_handler { sub test_data_handler {
my $self = shift; my $self = shift;
@ -84,14 +84,14 @@ sub test_data_handler {
$self->qp->connection->notes('whitelisthost', 0); $self->qp->connection->notes('whitelisthost', 0);
($code, $mess) = $self->data_handler(); ($code, $mess) = $self->data_handler();
cmp_ok( $code, '==', DECLINED, "not sure"); cmp_ok( $code, '==', DECLINED, "not sure");
}; }
sub test_log_and_pass { sub test_log_and_pass {
my $self = shift; my $self = shift;
my ($code, $mess) = $self->log_and_pass(); my ($code, $mess) = $self->log_and_pass();
cmp_ok( $code, '==', DECLINED, "default"); cmp_ok( $code, '==', DECLINED, "default");
}; }
sub test_log_and_deny { sub test_log_and_deny {
my $self = shift; my $self = shift;
@ -108,7 +108,7 @@ sub test_log_and_deny {
$self->{_args}{reject_type} = 'disconnect'; $self->{_args}{reject_type} = 'disconnect';
($code, $mess) = $self->log_and_deny(); ($code, $mess) = $self->log_and_deny();
cmp_ok( $code, '==', DENY_DISCONNECT, "bad, disconnect"); cmp_ok( $code, '==', DENY_DISCONNECT, "bad, disconnect");
}; }
sub test_mail_handler { sub test_mail_handler {
my $self = shift; my $self = shift;
@ -130,7 +130,7 @@ sub test_mail_handler {
$self->{_args}{reject_type} = 'disconnect'; $self->{_args}{reject_type} = 'disconnect';
($code, $mess) = $self->mail_handler(); ($code, $mess) = $self->mail_handler();
cmp_ok( $code, '==', DENY_DISCONNECT, "bad, disconnect"); cmp_ok( $code, '==', DENY_DISCONNECT, "bad, disconnect");
}; }
sub test_reject_type { sub test_reject_type {
my $self = shift; my $self = shift;
@ -143,4 +143,4 @@ sub test_reject_type {
$self->{_args}{reject_type} = 'disconnect'; $self->{_args}{reject_type} = 'disconnect';
cmp_ok( $self->get_reject_type(), '==', DENY_DISCONNECT, "disconnect"); cmp_ok( $self->get_reject_type(), '==', DENY_DISCONNECT, "disconnect");
}; }

View File

@ -11,7 +11,7 @@ my $test_email = 'user@example.com';
my @greydbs = qw( denysoft_greylist.dbm denysoft_greylist.dbm.lock ); my @greydbs = qw( denysoft_greylist.dbm denysoft_greylist.dbm.lock );
foreach ( @greydbs ) { foreach ( @greydbs ) {
unlink $_ if -f $_; unlink $_ if -f $_;
}; }
sub register_tests { sub register_tests {
my $self = shift; my $self = shift;
@ -98,7 +98,7 @@ sub test_hook_data {
$transaction->notes('whitelistrcpt', 1); $transaction->notes('whitelistrcpt', 1);
($code, $mess) = $self->hook_data( $transaction ); ($code, $mess) = $self->hook_data( $transaction );
cmp_ok( $code, '==', DECLINED, "missing recipients"); cmp_ok( $code, '==', DECLINED, "missing recipients");
}; }
sub test_get_db_key { sub test_get_db_key {
my $self = shift; my $self = shift;
@ -128,14 +128,14 @@ sub test_get_db_key {
$self->{_args}{recipient} = 1; $self->{_args}{recipient} = 1;
$key = $self->get_db_key( $address, $address ); $key = $self->get_db_key( $address, $address );
cmp_ok( $key, 'eq', "3232235777:$test_email:$test_email", "db key: $key"); cmp_ok( $key, 'eq', "3232235777:$test_email:$test_email", "db key: $key");
}; }
sub test_get_db_location { sub test_get_db_location {
my $self = shift; my $self = shift;
my $db = $self->get_db_location(); my $db = $self->get_db_location();
ok( $db, "db location: $db"); ok( $db, "db location: $db");
}; }
sub test_exclude { sub test_exclude {
my ( $self ) = @_; my ( $self ) = @_;
@ -144,7 +144,7 @@ sub test_exclude {
ok( $self->exclude(), "Relay client results in exclude() hit" ); ok( $self->exclude(), "Relay client results in exclude() hit" );
$self->connection->relay_client(0); $self->connection->relay_client(0);
ok( ! $self->exclude(), "Non-relay client results in exclude() miss" ); ok( ! $self->exclude(), "Non-relay client results in exclude() miss" );
}; }
sub test_greylist_geoip { sub test_greylist_geoip {
my $self = shift; my $self = shift;
@ -158,14 +158,14 @@ sub test_greylist_geoip {
$self->connection->notes('geoip_country', $cc ); $self->connection->notes('geoip_country', $cc );
ok( $self->geoip_match(), "match + ($cc)"); ok( $self->geoip_match(), "match + ($cc)");
ok( $self->exclude(), "match + ($cc) results in exclude() hit"); ok( $self->exclude(), "match + ($cc) results in exclude() hit");
}; }
foreach my $cc ( @invalid ) { foreach my $cc ( @invalid ) {
$self->connection->notes('geoip_country', $cc ); $self->connection->notes('geoip_country', $cc );
ok( ! $self->geoip_match(), "bad - ($cc)"); ok( ! $self->geoip_match(), "bad - ($cc)");
ok( ! $self->exclude(), "miss - ($cc) results in exclude() miss"); ok( ! $self->exclude(), "miss - ($cc) results in exclude() miss");
}; }
}; }
sub test_greylist_p0f_genre { sub test_greylist_p0f_genre {
my $self = shift; my $self = shift;
@ -226,5 +226,5 @@ sub _reset_transaction {
$self->qp->transaction->notes('tls_enabled',0); $self->qp->transaction->notes('tls_enabled',0);
$self->{_args}{p0f} = undef; $self->{_args}{p0f} = undef;
$self->{_args}{geoip} = undef; $self->{_args}{geoip} = undef;
}; }

View File

@ -33,7 +33,7 @@ sub setup_test_headers {
$self->qp->transaction->notes('whitelistsender', 0); $self->qp->transaction->notes('whitelistsender', 0);
$self->connection->notes('whitelisthost', 0); $self->connection->notes('whitelisthost', 0);
$self->connection->notes('naughty', 0); $self->connection->notes('naughty', 0);
}; }
sub test_invalid_date_range { sub test_invalid_date_range {
my $self = shift; my $self = shift;
@ -73,7 +73,7 @@ sub test_invalid_date_range {
my $past_1 = strftime "%a %b %e %H:%M:%S %Y", localtime time - 86400; #1d my $past_1 = strftime "%a %b %e %H:%M:%S %Y", localtime time - 86400; #1d
$r = $self->invalid_date_range( $past_1 ); $r = $self->invalid_date_range( $past_1 );
ok( ! $r, "a little old +" ); ok( ! $r, "a little old +" );
}; }
sub test_hook_data_post { sub test_hook_data_post {
my $self = shift; my $self = shift;
@ -119,4 +119,4 @@ sub test_hook_data_post {
$self->{_args}{reject_type} = 'perm'; $self->{_args}{reject_type} = 'perm';
($code, $mess) = $self->hook_data_post( $transaction ); ($code, $mess) = $self->hook_data_post( $transaction );
cmp_ok( DENY, '==', $code, "deny ( $code, $mess )" ); cmp_ok( DENY, '==', $code, "deny ( $code, $mess )" );
}; }

View File

@ -24,7 +24,7 @@ sub register_tests {
sub test_helo_handler { sub test_helo_handler {
my $self = shift; my $self = shift;
cmp_ok( $self->helo_handler(undef, undef), '==', DECLINED, "empty host"); cmp_ok( $self->helo_handler(undef, undef), '==', DECLINED, "empty host");
}; }
sub test_is_in_badhelo { sub test_is_in_badhelo {
my $self = shift; my $self = shift;
@ -34,7 +34,7 @@ sub test_is_in_badhelo {
($err, $why) = $self->is_in_badhelo('example.com'); ($err, $why) = $self->is_in_badhelo('example.com');
ok( ! $err, "example.com"); ok( ! $err, "example.com");
}; }
sub test_is_regex_match { sub test_is_regex_match {
my $self = shift; my $self = shift;
@ -47,7 +47,7 @@ sub test_is_regex_match {
($err, $why) = $self->is_regex_match('host-only', '!\.' ); ($err, $why) = $self->is_regex_match('host-only', '!\.' );
ok( $err, "negated pattern, $why"); ok( $err, "negated pattern, $why");
}; }
sub test_invalid_localhost { sub test_invalid_localhost {
my $self = shift; my $self = shift;
@ -61,14 +61,14 @@ sub test_invalid_localhost {
$self->qp->connection->remote_ip(undef); $self->qp->connection->remote_ip(undef);
($err, $why) = $self->invalid_localhost('not-localhost'); ($err, $why) = $self->invalid_localhost('not-localhost');
ok($err, "host: not-localhost, invalid remote ip"); ok($err, "host: not-localhost, invalid remote ip");
}; }
foreach my $ip (qw/ ::1 127.0.0.1 / ) { foreach my $ip (qw/ ::1 127.0.0.1 / ) {
$self->qp->connection->remote_ip($ip); $self->qp->connection->remote_ip($ip);
($err, $why) = $self->invalid_localhost('not-localhost'); ($err, $why) = $self->invalid_localhost('not-localhost');
ok( ! $err, "localhost, correct remote IP ($ip)"); ok( ! $err, "localhost, correct remote IP ($ip)");
} }
}; }
sub test_is_plain_ip { sub test_is_plain_ip {
my $self = shift; my $self = shift;
@ -81,7 +81,7 @@ sub test_is_plain_ip {
($err, $why) = $self->is_plain_ip('[254.254.254.254]'); ($err, $why) = $self->is_plain_ip('[254.254.254.254]');
ok( ! $err, "address literal"); ok( ! $err, "address literal");
}; }
sub test_is_address_literal { sub test_is_address_literal {
my $self = shift; my $self = shift;
@ -94,7 +94,7 @@ sub test_is_address_literal {
($err, $why) = $self->is_address_literal('254.254.254.254'); ($err, $why) = $self->is_address_literal('254.254.254.254');
ok( ! $err, "address literal"); ok( ! $err, "address literal");
}; }
sub test_no_forward_dns { sub test_no_forward_dns {
my $self = shift; my $self = shift;
@ -105,7 +105,7 @@ sub test_no_forward_dns {
# reserved .test TLD: http://tools.ietf.org/html/rfc2606 # reserved .test TLD: http://tools.ietf.org/html/rfc2606
($err, $why) = $self->no_forward_dns('perl.test'); ($err, $why) = $self->no_forward_dns('perl.test');
ok( $err, "perl.test"); ok( $err, "perl.test");
}; }
sub test_no_reverse_dns { sub test_no_reverse_dns {
my $self = shift; my $self = shift;
@ -118,7 +118,7 @@ sub test_no_reverse_dns {
($err, $why) = $self->no_reverse_dns('mail.theartfarm.com', '66.128.51.165'); ($err, $why) = $self->no_reverse_dns('mail.theartfarm.com', '66.128.51.165');
ok( ! $err, "66.128.51.165"); ok( ! $err, "66.128.51.165");
}; }
sub test_no_matching_dns { sub test_no_matching_dns {
my $self = shift; my $self = shift;
@ -132,7 +132,7 @@ sub test_no_matching_dns {
$self->qp->connection->notes('helo_forward_match', 1); $self->qp->connection->notes('helo_forward_match', 1);
($err, $why) = $self->no_matching_dns('matt.test'); ($err, $why) = $self->no_matching_dns('matt.test');
ok( ! $err, "pass"); ok( ! $err, "pass");
}; }
sub test_check_ip_match { sub test_check_ip_match {
my $self = shift; my $self = shift;
@ -154,7 +154,7 @@ sub test_check_ip_match {
$self->connection->notes('helo_forward_match', 0); $self->connection->notes('helo_forward_match', 0);
$self->check_ip_match($t->{ip2}); $self->check_ip_match($t->{ip2});
ok( $self->connection->notes('helo_forward_match'), $t->{r}); ok( $self->connection->notes('helo_forward_match'), $t->{r});
}; }
foreach my $t ( @bad_tests ) { foreach my $t ( @bad_tests ) {
$self->qp->connection->remote_ip($t->{ip}); $self->qp->connection->remote_ip($t->{ip});
@ -162,8 +162,8 @@ sub test_check_ip_match {
$self->connection->notes('helo_forward_match', 0); $self->connection->notes('helo_forward_match', 0);
$self->check_ip_match($t->{ip2}); $self->check_ip_match($t->{ip2});
ok( ! $self->connection->notes('helo_forward_match'), $t->{r}); ok( ! $self->connection->notes('helo_forward_match'), $t->{r});
}; }
}; }
sub test_check_name_match { sub test_check_name_match {
my $self = shift; my $self = shift;
@ -179,5 +179,5 @@ sub test_check_name_match {
$self->connection->notes('helo_reverse_match', 0); $self->connection->notes('helo_reverse_match', 0);
$self->check_name_match('mx0.example.com', 'mx0.example.net'); $self->check_name_match('mx0.example.com', 'mx0.example.net');
ok( ! $self->connection->notes('helo_reverse_match'), "domain"); ok( ! $self->connection->notes('helo_reverse_match'), "domain");
}; }

View File

@ -27,8 +27,8 @@ sub register_tests {
$self->register_test('test_set_continent'); $self->register_test('test_set_continent');
$self->register_test('test_set_distance'); $self->register_test('test_set_distance');
$self->register_test('test_set_asn'); $self->register_test('test_set_asn');
}; }
}; }
sub test_geoip2_lookup { sub test_geoip2_lookup {
my $self = shift; my $self = shift;
@ -44,7 +44,7 @@ sub test_geoip2_lookup {
cmp_ok( $self->connection->notes('geoip_country_name'), 'eq', 'United States', "24.24.24.24 is in country United States"); cmp_ok( $self->connection->notes('geoip_country_name'), 'eq', 'United States', "24.24.24.24 is in country United States");
cmp_ok( $self->connection->notes('geoip_continent'), 'eq', 'NA', "24.24.24.24 is in continent NA"); cmp_ok( $self->connection->notes('geoip_continent'), 'eq', 'NA', "24.24.24.24 is in continent NA");
cmp_ok( $self->connection->notes('geoip_city'), 'eq', 'Deer Park', "24.24.24.24 is in city of Deer Park"); cmp_ok( $self->connection->notes('geoip_city'), 'eq', 'Deer Park', "24.24.24.24 is in city of Deer Park");
}; }
sub test_geoip_lookup { sub test_geoip_lookup {
my $self = shift; my $self = shift;
@ -53,7 +53,7 @@ sub test_geoip_lookup {
cmp_ok( $self->geoip_lookup(), '==', DECLINED, "exit code"); cmp_ok( $self->geoip_lookup(), '==', DECLINED, "exit code");
cmp_ok( $self->connection->notes('geoip_country'), 'eq', 'US', "24.24.24.24 is in the US"); cmp_ok( $self->connection->notes('geoip_country'), 'eq', 'US', "24.24.24.24 is in the US");
}; }
sub test_geoip_load_db { sub test_geoip_load_db {
my $self = shift; my $self = shift;
@ -65,15 +65,15 @@ sub test_geoip_load_db {
} }
else { else {
ok( "no GeoIP city db" ); ok( "no GeoIP city db" );
}; }
if ( $self->{_geoip} ) { if ( $self->{_geoip} ) {
ok( ref $self->{_geoip}, "loaded GeoIP db" ); ok( ref $self->{_geoip}, "loaded GeoIP db" );
} }
else { else {
ok( "no GeoIP db" ); ok( "no GeoIP db" );
}; }
}; }
sub test_geoip_init_cc { sub test_geoip_init_cc {
my $self = shift; my $self = shift;
@ -85,7 +85,7 @@ sub test_geoip_init_cc {
$self->{_args}{distance} = $test_ip; $self->{_args}{distance} = $test_ip;
$self->init_my_country_code( $test_ip ); $self->init_my_country_code( $test_ip );
cmp_ok( $self->{_my_country_code}, 'eq', 'US', "country set and matches"); cmp_ok( $self->{_my_country_code}, 'eq', 'US', "country set and matches");
}; }
sub test_set_country_code { sub test_set_country_code {
my $self = shift; my $self = shift;
@ -100,7 +100,7 @@ sub test_set_country_code {
my $note = $self->connection->notes('geoip_country'); my $note = $self->connection->notes('geoip_country');
cmp_ok( $note, 'eq', 'US', "set_country_code set note to $cc"); cmp_ok( $note, 'eq', 'US', "set_country_code set note to $cc");
}; }
sub test_set_country_name { sub test_set_country_name {
my $self = shift; my $self = shift;
@ -118,7 +118,7 @@ sub test_set_country_name {
my $note = $self->connection->notes('geoip_country_name'); my $note = $self->connection->notes('geoip_country_name');
cmp_ok( $note, 'eq', 'United States', "note has: $cn"); cmp_ok( $note, 'eq', 'United States', "note has: $cn");
}; }
sub test_set_continent { sub test_set_continent {
my $self = shift; my $self = shift;
@ -140,8 +140,8 @@ sub test_set_continent {
else { else {
ok(1, "no continent data" ); ok(1, "no continent data" );
ok(1, "no continent data" ); ok(1, "no continent data" );
}; }
}; }
sub test_set_distance { sub test_set_distance {
my $self = shift; my $self = shift;
@ -165,7 +165,8 @@ sub test_set_distance {
ok( 1, "no distance data"); ok( 1, "no distance data");
ok( 1, "no distance data"); ok( 1, "no distance data");
} }
}; }
sub test_set_asn { sub test_set_asn {
my $self = shift; my $self = shift;
@ -184,4 +185,4 @@ sub test_set_asn {
$asn = $self->set_asn(); $asn = $self->set_asn();
ok( $self->connection->notes('geoip_asn') =~ /^7819/, "note has: $asn"); ok( $self->connection->notes('geoip_asn') =~ /^7819/, "note has: $asn");
}; }

View File

@ -12,7 +12,7 @@ sub register_tests {
$self->register_test('test_get_v3_query'); $self->register_test('test_get_v3_query');
$self->register_test('test_store_v2_results'); $self->register_test('test_store_v2_results');
$self->register_test('test_store_v3_results'); $self->register_test('test_store_v3_results');
}; }
sub test_query_p0f_v2 { sub test_query_p0f_v2 {
#TODO #TODO
@ -25,11 +25,11 @@ sub test_query_p0f_v2 {
# or c) is there a p0f test value? # or c) is there a p0f test value?
# parse and validate the response # parse and validate the response
# using $self->test_v2_response() # using $self->test_v2_response()
}; }
sub test_query_p0f_v3 { sub test_query_p0f_v3 {
#TODO: similar to v2 .... #TODO: similar to v2 ....
}; }
sub test_get_v2_query { sub test_get_v2_query {
my $self = shift; my $self = shift;
@ -44,7 +44,7 @@ sub test_get_v2_query {
my $r = $self->get_v2_query(); my $r = $self->get_v2_query();
ok( $r, 'r +' ); ok( $r, 'r +' );
}; }
sub test_get_v3_query { sub test_get_v3_query {
my $self = shift; my $self = shift;
@ -54,7 +54,7 @@ sub test_get_v3_query {
my $r = $self->get_v3_query(); my $r = $self->get_v3_query();
ok( $r, 'any +' ); ok( $r, 'any +' );
}; }
sub test_store_v2_results { sub test_store_v2_results {
my $self = shift; my $self = shift;
@ -67,7 +67,7 @@ sub test_store_v2_results {
ok( $r, "r: +") or return; ok( $r, "r: +") or return;
ok( $r->{genre} =~ /windows/i, "genre +" ); ok( $r->{genre} =~ /windows/i, "genre +" );
}; }
sub test_store_v3_results { sub test_store_v3_results {
my $self = shift; my $self = shift;
@ -79,6 +79,5 @@ sub test_store_v3_results {
ok( $r, "result"); ok( $r, "result");
ok( $r->{genre} =~ /windows/i, "genre" ); ok( $r->{genre} =~ /windows/i, "genre" );
}; }

View File

@ -31,7 +31,7 @@ sub test_hook_rcpt {
($r, $mess) = $self->hook_rcpt( $transaction, $address ); ($r, $mess) = $self->hook_rcpt( $transaction, $address );
cmp_ok( $r, '==', OK, "example.com"); cmp_ok( $r, '==', OK, "example.com");
$self->qp->connection->relay_client(0); $self->qp->connection->relay_client(0);
}; }
sub test_is_in_rcpthosts { sub test_is_in_rcpthosts {
my $self = shift; my $self = shift;
@ -44,11 +44,11 @@ sub test_is_in_rcpthosts {
} }
else { else {
ok(1, "is_in_rcpthosts (skip, no entries)" ); ok(1, "is_in_rcpthosts (skip, no entries)" );
}; }
ok( $self->is_in_rcpthosts( 'localhost' ), "is_in_rcpthosts +"); ok( $self->is_in_rcpthosts( 'localhost' ), "is_in_rcpthosts +");
ok( ! $self->is_in_rcpthosts( 'example.com' ), "is_in_rcpthosts -"); ok( ! $self->is_in_rcpthosts( 'example.com' ), "is_in_rcpthosts -");
}; }
sub test_is_in_morercpthosts { sub test_is_in_morercpthosts {
my $self = shift; my $self = shift;
@ -60,10 +60,10 @@ sub test_is_in_morercpthosts {
} }
else { else {
ok(1, "is_in_morercpthosts (skip, no entries)" ); ok(1, "is_in_morercpthosts (skip, no entries)" );
}; }
ok( ! $self->is_in_morercpthosts( 'example.com' ), "missing -"); ok( ! $self->is_in_morercpthosts( 'example.com' ), "missing -");
}; }
sub test_get_rcpt_host { sub test_get_rcpt_host {
my $self = shift; my $self = shift;
@ -96,5 +96,5 @@ sub test_get_rcpt_host {
$address = Qpsmtpd::Address->parse('<@example.com>'); $address = Qpsmtpd::Address->parse('<@example.com>');
ok( ! $self->get_rcpt_host( $address ), "missing user" ); ok( ! $self->get_rcpt_host( $address ), "missing user" );
}; }

View File

@ -26,7 +26,7 @@ sub test_relay_only {
cmp_ok( $r, '==', OK, "relay_only +"); cmp_ok( $r, '==', OK, "relay_only +");
$self->qp->connection->relay_client(0); $self->qp->connection->relay_client(0);
}; }
sub test_is_octet_match { sub test_is_octet_match {
my $self = shift; my $self = shift;
@ -41,7 +41,7 @@ sub test_is_octet_match {
$self->qp->connection->remote_ip('203.0.113.0'); $self->qp->connection->remote_ip('203.0.113.0');
ok( ! $self->is_octet_match(), "nope, -"); ok( ! $self->is_octet_match(), "nope, -");
}; }
sub test_is_in_cidr_block { sub test_is_in_cidr_block {
my $self = shift; my $self = shift;
@ -60,7 +60,7 @@ sub test_is_in_cidr_block {
$self->{_cidr_blocks} = [ 'fdda:b13d:e431:be17::' ]; $self->{_cidr_blocks} = [ 'fdda:b13d:e431:be17::' ];
ok( ! $self->is_in_cidr_block(), "nope, -" ); ok( ! $self->is_in_cidr_block(), "nope, -" );
}; }
sub test_is_in_norelayclients { sub test_is_in_norelayclients {
my $self = shift; my $self = shift;
@ -71,11 +71,11 @@ sub test_is_in_norelayclients {
foreach ( @matches ) { foreach ( @matches ) {
$self->qp->connection->remote_ip($_); $self->qp->connection->remote_ip($_);
ok( $self->is_in_norelayclients(), "match, + ($_)"); ok( $self->is_in_norelayclients(), "match, + ($_)");
}; }
foreach ( @false ) { foreach ( @false ) {
$self->qp->connection->remote_ip($_); $self->qp->connection->remote_ip($_);
ok( ! $self->is_in_norelayclients(), "match, - ($_)"); ok( ! $self->is_in_norelayclients(), "match, - ($_)");
}; }
}; }

View File

@ -44,7 +44,7 @@ sub test_hook_mail {
$self->{_args}{reject_type} = 'hard'; $self->{_args}{reject_type} = 'hard';
($r) = $self->hook_mail( $transaction, $sender ); ($r) = $self->hook_mail( $transaction, $sender );
ok( $r == DENY, "($r)"); ok( $r == DENY, "($r)");
}; }
sub test_check_dns { sub test_check_dns {
my $self = shift; my $self = shift;
@ -61,7 +61,7 @@ sub test_get_and_validate_mx {
ok( scalar $self->get_and_validate_mx( 'perl.com', $transaction ) ); ok( scalar $self->get_and_validate_mx( 'perl.com', $transaction ) );
ok( ! scalar $self->get_host_records( 'fake-domain-name-for-test.com', $transaction ) ); ok( ! scalar $self->get_host_records( 'fake-domain-name-for-test.com', $transaction ) );
}; }
sub test_get_host_records { sub test_get_host_records {
my $self = shift; my $self = shift;
@ -69,7 +69,7 @@ sub test_get_host_records {
ok( scalar $self->get_host_records( 'perl.com', $transaction ) ); ok( scalar $self->get_host_records( 'perl.com', $transaction ) );
ok( ! scalar $self->get_host_records( 'fake-domain-name-for-test.com', $transaction ) ); ok( ! scalar $self->get_host_records( 'fake-domain-name-for-test.com', $transaction ) );
}; }
sub test_mx_address_resolves { sub test_mx_address_resolves {
my $self = shift; my $self = shift;
@ -78,7 +78,7 @@ sub test_mx_address_resolves {
ok( $self->mx_address_resolves('mail.perl.com', $fromhost) ); ok( $self->mx_address_resolves('mail.perl.com', $fromhost) );
ok( ! $self->mx_address_resolves('no-such-mx.perl.com', $fromhost) ); ok( ! $self->mx_address_resolves('no-such-mx.perl.com', $fromhost) );
}; }
sub test_populate_invalid_networks { sub test_populate_invalid_networks {
my $self = shift; my $self = shift;
@ -93,5 +93,5 @@ sub test_populate_invalid_networks {
# clean up afterwards # clean up afterwards
$self->qp->config('invalid_resolvable_fromhost', undef ); $self->qp->config('invalid_resolvable_fromhost', undef );
$self->{invalid} = (); $self->{invalid} = ();
}; }

View File

@ -27,6 +27,6 @@ sub test_is_special_recipient {
foreach my $user ( qw/ postmaster abuse mailer-daemon root / ) { foreach my $user ( qw/ postmaster abuse mailer-daemon root / ) {
$address = Qpsmtpd::Address->new("$user\@example.com"); $address = Qpsmtpd::Address->new("$user\@example.com");
ok( $self->is_special_recipient( $address ), "special: $user"); ok( $self->is_special_recipient( $address ), "special: $user");
}; }
}; }

View File

@ -53,7 +53,7 @@ sub test_connect_to_spamd {
else { else {
ok( 1 == 1, "socket connect FAILED"); ok( 1 == 1, "socket connect FAILED");
ok( 1 == 1, "socket response FAILED"); ok( 1 == 1, "socket response FAILED");
}; }
# Try a TCP/IP connection # Try a TCP/IP connection
$self->{_args}{spamd_socket} = '127.0.0.1:783'; $self->{_args}{spamd_socket} = '127.0.0.1:783';
@ -68,8 +68,8 @@ sub test_connect_to_spamd {
else { else {
ok( 1 == 1, "tcp/ip connect FAILED"); ok( 1 == 1, "tcp/ip connect FAILED");
ok( 1 == 1, "tcp/ip response FAILED"); ok( 1 == 1, "tcp/ip response FAILED");
}; }
}; }
sub test_reject { sub test_reject {
my $self = shift; my $self = shift;
@ -88,7 +88,7 @@ sub test_reject {
$transaction->notes('spamassassin', { is_spam => 'Yes', score => 15 } ); $transaction->notes('spamassassin', { is_spam => 'Yes', score => 15 } );
($r) = $self->reject($transaction); ($r) = $self->reject($transaction);
cmp_ok( DENY, '==', $r, "r: $r"); cmp_ok( DENY, '==', $r, "r: $r");
}; }
sub test_munge_subject { sub test_munge_subject {
my $self = shift; my $self = shift;
@ -125,7 +125,7 @@ sub test_munge_subject {
$self->munge_subject($transaction); $self->munge_subject($transaction);
$r = $transaction->header->get('Subject'); chomp $r; $r = $transaction->header->get('Subject'); chomp $r;
cmp_ok($r, 'eq', "$subject", "+"); cmp_ok($r, 'eq', "$subject", "+");
}; }
sub test_get_spam_results { sub test_get_spam_results {
my $self = shift; my $self = shift;
@ -140,7 +140,7 @@ sub test_get_spam_results {
my $r_ref = $self->get_spam_results($transaction); my $r_ref = $self->get_spam_results($transaction);
if ( $h =~ /hits=/ ) { if ( $h =~ /hits=/ ) {
$r_ref->{hits} = delete $r_ref->{score}; # SA v2 compat $r_ref->{hits} = delete $r_ref->{score}; # SA v2 compat
}; }
my $r2 = _reassemble_header($r_ref); my $r2 = _reassemble_header($r_ref);
cmp_ok( $h, 'eq', $r2, $h ); cmp_ok( $h, 'eq', $r2, $h );
@ -149,11 +149,11 @@ sub test_get_spam_results {
if ( $h =~ /hits=/ ) { if ( $h =~ /hits=/ ) {
ok( 1 ); ok( 1 );
next; next;
}; # caching is broken for SA v2 headers } # caching is broken for SA v2 headers
$r2 = _reassemble_header($r_ref); $r2 = _reassemble_header($r_ref);
cmp_ok( $h, 'eq', $r2, $h ); cmp_ok( $h, 'eq', $r2, $h );
}; }
}; }
sub test_parse_spam_header { sub test_parse_spam_header {
my $self = shift; my $self = shift;
@ -162,11 +162,11 @@ sub test_parse_spam_header {
my $r_ref = $self->parse_spam_header($h); my $r_ref = $self->parse_spam_header($h);
if ( $h =~ /hits=/ ) { if ( $h =~ /hits=/ ) {
$r_ref->{hits} = delete $r_ref->{score}; # SA v2 compat $r_ref->{hits} = delete $r_ref->{score}; # SA v2 compat
}; }
my $r2 = _reassemble_header($r_ref); my $r2 = _reassemble_header($r_ref);
cmp_ok( $h, 'eq', $r2, $h ); cmp_ok( $h, 'eq', $r2, $h );
}; }
}; }
sub setup_headers { sub setup_headers {
my $self = shift; my $self = shift;
@ -174,7 +174,7 @@ sub setup_headers {
my $transaction = $self->qp->transaction; my $transaction = $self->qp->transaction;
my $header = Mail::Header->new(Modify => 0, MailFrom => "COERCE"); my $header = Mail::Header->new(Modify => 0, MailFrom => "COERCE");
$transaction->header( $header ); $transaction->header( $header );
}; }
sub test_message { sub test_message {
return <<'EO_MESSAGE' return <<'EO_MESSAGE'
@ -186,7 +186,7 @@ What so proudly we.
EO_MESSAGE EO_MESSAGE
}; }
sub _reassemble_header { sub _reassemble_header {
my $info_ref = shift; my $info_ref = shift;
@ -195,7 +195,7 @@ sub _reassemble_header {
foreach ( qw/ hits score required tests autolearn version / ) { foreach ( qw/ hits score required tests autolearn version / ) {
next if ! defined $info_ref->{$_}; next if ! defined $info_ref->{$_};
$string .= " $_=$info_ref->{$_}"; $string .= " $_=$info_ref->{$_}";
}; }
return $string; return $string;
}; }

View File

@ -16,7 +16,7 @@ sub register_tests {
warn "Could not load ClamAV::Client"; warn "Could not load ClamAV::Client";
$self->register_test('test_register'); $self->register_test('test_register');
$self->register_test('test_get_clamd'); $self->register_test('test_get_clamd');
}; }
$self->register_test('test_err_and_return'); $self->register_test('test_err_and_return');
$self->register_test('test_get_filename'); $self->register_test('test_get_filename');
@ -40,7 +40,7 @@ sub test_register {
ok( ! $self->{_args}{deny_viruses}, "deny_viruses 2"); ok( ! $self->{_args}{deny_viruses}, "deny_viruses 2");
is( $self->{_args}{max_size}, 200, "max_size 2"); is( $self->{_args}{max_size}, 200, "max_size 2");
ok( !$self->{_args}{scan_all}, "scan_all 2"); ok( !$self->{_args}{scan_all}, "scan_all 2");
}; }
sub test_err_and_return { sub test_err_and_return {
my $self = shift; my $self = shift;

View File

@ -36,7 +36,7 @@ sub __is_valid_ip {
foreach my $ip ( @bad ) { foreach my $ip ( @bad ) {
ok( !$base->is_valid_ip($ip), "is_valid_ip, neg: $ip"); ok( !$base->is_valid_ip($ip), "is_valid_ip, neg: $ip");
} }
}; }
sub __is_localhost { sub __is_localhost {
@ -47,7 +47,7 @@ sub __is_localhost {
for my $rem_ip (qw/ 128.0.0.1 ::2 2607:f060:b008:feed::128.0.0.1 /) { for my $rem_ip (qw/ 128.0.0.1 ::2 2607:f060:b008:feed::128.0.0.1 /) {
ok( !$base->is_localhost($rem_ip), "!is_localhost, $rem_ip"); ok( !$base->is_localhost($rem_ip), "!is_localhost, $rem_ip");
} }
}; }
sub __tildeexp { sub __tildeexp {
my $path = $base->tildeexp('~root/foo.txt'); my $path = $base->tildeexp('~root/foo.txt');
@ -55,7 +55,7 @@ sub __tildeexp {
$path = $base->tildeexp('no/tilde/in/path'); $path = $base->tildeexp('no/tilde/in/path');
cmp_ok( $path, 'eq', 'no/tilde/in/path', 'tildeexp, no expansion'); cmp_ok( $path, 'eq', 'no/tilde/in/path', 'tildeexp, no expansion');
}; }
sub __get_resolver { sub __get_resolver {
my $res = $base->get_resolver(); my $res = $base->get_resolver();

View File

@ -71,7 +71,7 @@ sub __clear_cache {
ok(! $Qpsmtpd::Config::config_cache{foo}, "clear_cache, config_cache") ok(! $Qpsmtpd::Config::config_cache{foo}, "clear_cache, config_cache")
or diag Data::Dumper::Dumper($Qpsmtpd::Config::config_cache{foo}); or diag Data::Dumper::Dumper($Qpsmtpd::Config::config_cache{foo});
ok(! $Qpsmtpd::Config::dir_memo{dir1}, "clear_cache, dir_memo") ok(! $Qpsmtpd::Config::dir_memo{dir1}, "clear_cache, dir_memo")
}; }
sub __default { sub __default {
is($config->default('me'), hostname, "default, my hostname"); is($config->default('me'), hostname, "default, my hostname");
@ -94,7 +94,7 @@ sub __get_qmail_map {
my $r = $config->get_qmail_map('users', 't/config/users.cdb'); my $r = $config->get_qmail_map('users', 't/config/users.cdb');
ok(keys %$r, 'get_qmail_map("users.cdb")'); ok(keys %$r, 'get_qmail_map("users.cdb")');
ok($r->{'!example.com-'}, "get_qmail_map, known entry"); ok($r->{'!example.com-'}, "get_qmail_map, known entry");
}; }
} }
sub __from_file { sub __from_file {
@ -121,4 +121,4 @@ sub __config_via_smtpd {
'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'
); );
}; }