remove test counters from plugin tests
replace with done_testing(), which provides the same "make sure to kvetch if tests fail to run" without requiring humans to do the bookkeeping.
This commit is contained in:
parent
ef80767652
commit
a5420149bd
@ -66,16 +66,16 @@ sub command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub input {
|
sub input {
|
||||||
my $self = shift;
|
my ($self, $command) = @_;
|
||||||
my $command = shift;
|
|
||||||
|
|
||||||
my $timeout = $self->config('timeout');
|
my $timeout = $self->config('timeout');
|
||||||
alarm $timeout;
|
alarm $timeout;
|
||||||
|
|
||||||
$command =~ s/\r?\n$//s; # advanced chomp
|
$command =~ s/\r?\n$//s; # advanced chomp
|
||||||
$self->log(LOGDEBUG, "dispatching $command");
|
$self->log(LOGDEBUG, "dispatching $command");
|
||||||
defined $self->dispatch(split / +/, $command, 2)
|
if (!defined $self->dispatch(split / +/, $command, 2)) {
|
||||||
or $self->respond(502, "command unrecognized: '$command'");
|
$self->respond(502, "command unrecognized: '$command'");
|
||||||
|
}
|
||||||
alarm $timeout;
|
alarm $timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,8 +91,8 @@ sub plugin_dirs {
|
|||||||
sub log {
|
sub log {
|
||||||
my ($self, $trace, $hook, $plugin, @log) = @_;
|
my ($self, $trace, $hook, $plugin, @log) = @_;
|
||||||
my $level = Qpsmtpd::TRACE_LEVEL() || 5;
|
my $level = Qpsmtpd::TRACE_LEVEL() || 5;
|
||||||
$level = $self->init_logger unless defined $level;
|
$level = $self->init_logger if !defined $level;
|
||||||
print("# " . join(" ", $$, @log) . "\n") if $trace <= $level;
|
print("# " . join(' ', $$, @log) . "\n") if $trace <= $level;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub varlog {
|
sub varlog {
|
||||||
@ -107,24 +107,14 @@ sub run_plugin_tests {
|
|||||||
$self->{_test_mode} = 1;
|
$self->{_test_mode} = 1;
|
||||||
my @plugins = $self->load_plugins();
|
my @plugins = $self->load_plugins();
|
||||||
|
|
||||||
# First count test number
|
|
||||||
my $num_tests = 0;
|
|
||||||
foreach my $plugin (@plugins) {
|
|
||||||
$plugin->register_tests();
|
|
||||||
$num_tests += $plugin->total_tests();
|
|
||||||
}
|
|
||||||
|
|
||||||
require Test::Builder;
|
require Test::Builder;
|
||||||
my $Test = Test::Builder->new();
|
my $Test = Test::Builder->new();
|
||||||
|
|
||||||
$Test->plan(tests => $num_tests);
|
|
||||||
|
|
||||||
# Now run them
|
|
||||||
|
|
||||||
foreach my $plugin (@plugins) {
|
foreach my $plugin (@plugins) {
|
||||||
|
$plugin->register_tests();
|
||||||
$plugin->run_tests($self);
|
$plugin->run_tests($self);
|
||||||
}
|
}
|
||||||
|
$Test->done_testing();
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ package Qpsmtpd::Plugin;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Qpsmtpd::Constants;
|
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Qpsmtpd::Constants;
|
||||||
|
|
||||||
sub register_tests {
|
sub register_tests {
|
||||||
|
|
||||||
@ -17,28 +17,17 @@ sub register_tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub register_test {
|
sub register_test {
|
||||||
my ($plugin, $test, $num_tests) = @_;
|
my ($plugin, $test) = @_;
|
||||||
$num_tests = 1 unless defined($num_tests);
|
|
||||||
|
|
||||||
# print STDERR "Registering test $test ($num_tests)\n";
|
# print STDERR "Registering test $test ($num_tests)\n";
|
||||||
push @{$plugin->{_tests}}, {name => $test, num => $num_tests};
|
push @{$plugin->{_tests}}, {name => $test};
|
||||||
}
|
|
||||||
|
|
||||||
sub total_tests {
|
|
||||||
my ($plugin) = @_;
|
|
||||||
my $total = 0;
|
|
||||||
foreach my $t (@{$plugin->{_tests}}) {
|
|
||||||
$total += $t->{num};
|
|
||||||
}
|
|
||||||
return $total;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run_tests {
|
sub run_tests {
|
||||||
my ($plugin, $qp) = @_;
|
my ($plugin, $qp) = @_;
|
||||||
foreach my $t (@{$plugin->{_tests}}) {
|
foreach my $t (@{$plugin->{_tests}}) {
|
||||||
my $method = $t->{name};
|
my $method = $t->{name};
|
||||||
print "# Running $method tests for plugin "
|
print "# " . $plugin->plugin_name . "\t $method\n";
|
||||||
. $plugin->plugin_name . "\n";
|
|
||||||
local $plugin->{_qp} = $qp;
|
local $plugin->{_qp} = $qp;
|
||||||
$plugin->$method();
|
$plugin->$method();
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ sub register_tests {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
$self->register_test("test_auth_checkpassword", 3);
|
$self->register_test("test_auth_checkpassword");
|
||||||
}
|
}
|
||||||
|
|
||||||
my @u_list = qw ( good bad none );
|
my @u_list = qw ( good bad none );
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->register_test("test_auth_flat_file", 3);
|
$self->register_test("test_auth_flat_file");
|
||||||
}
|
}
|
||||||
|
|
||||||
my @u_list = qw ( good bad none );
|
my @u_list = qw ( good bad none );
|
||||||
|
@ -8,7 +8,7 @@ use Qpsmtpd::Constants;
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test("test_auth_vpopmail", 3);
|
$self->register_test("test_auth_vpopmail");
|
||||||
}
|
}
|
||||||
|
|
||||||
my @u_list = qw ( good bad none );
|
my @u_list = qw ( good bad none );
|
||||||
|
@ -11,7 +11,7 @@ sub register_tests {
|
|||||||
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", 3);
|
$self->register_test("auth_vpopmail_sql");
|
||||||
}
|
}
|
||||||
|
|
||||||
sub auth_vpopmail_sql {
|
sub auth_vpopmail_sql {
|
||||||
|
@ -4,7 +4,7 @@ warn "loaded test auth_vpopmaild\n";
|
|||||||
|
|
||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->register_test("test_auth_vpopmaild", 3);
|
$self->register_test("test_auth_vpopmaild");
|
||||||
}
|
}
|
||||||
|
|
||||||
my @u_list = qw ( good bad none );
|
my @u_list = qw ( good bad none );
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->register_test("test_authdeny", 1);
|
$self->register_test("test_authdeny");
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_authdeny {
|
sub test_authdeny {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->register_test("test_authnull", 1);
|
$self->register_test("test_authnull");
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_authnull {
|
sub test_authnull {
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
#!perl -w
|
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Data::Dumper;
|
|
||||||
|
|
||||||
use Qpsmtpd::Address;
|
use Qpsmtpd::Address;
|
||||||
use Qpsmtpd::Constants;
|
use Qpsmtpd::Constants;
|
||||||
@ -9,9 +6,9 @@ use Qpsmtpd::Constants;
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test("test_badmailfrom_is_immune_sender", 5);
|
$self->register_test("test_badmailfrom_is_immune_sender");
|
||||||
$self->register_test("test_badmailfrom_match", 7);
|
$self->register_test("test_badmailfrom_match");
|
||||||
$self->register_test("test_badmailfrom_hook_mail", 4);
|
$self->register_test("test_badmailfrom_hook_mail");
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_badmailfrom_is_immune_sender {
|
sub test_badmailfrom_is_immune_sender {
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
#!perl -w
|
#!perl -w
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Data::Dumper;
|
|
||||||
|
|
||||||
use Qpsmtpd::Address;
|
use Qpsmtpd::Address;
|
||||||
|
|
||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test("test_badmailfromto_is_sender_immune", 5);
|
$self->register_test("test_badmailfromto_is_sender_immune");
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_badmailfromto_is_sender_immune {
|
sub test_badmailfromto_is_sender_immune {
|
||||||
|
@ -8,9 +8,9 @@ use Qpsmtpd::Constants;
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test("test_is_match", 10);
|
$self->register_test("test_is_match");
|
||||||
$self->register_test("test_hook_rcpt", 3);
|
$self->register_test("test_hook_rcpt");
|
||||||
$self->register_test("test_get_host_and_to", 8);
|
$self->register_test("test_get_host_and_to");
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _reset_connection_flags {
|
sub _reset_connection_flags {
|
||||||
|
@ -8,7 +8,7 @@ use Qpsmtpd::Constants;
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test('test_hook_unrecognized_command', 4);
|
$self->register_test('test_hook_unrecognized_command');
|
||||||
};
|
};
|
||||||
|
|
||||||
sub test_hook_unrecognized_command {
|
sub test_hook_unrecognized_command {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!perl -w
|
#!perl -w
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Data::Dumper;
|
|
||||||
use POSIX qw(strftime);
|
use POSIX qw(strftime);
|
||||||
|
|
||||||
use Qpsmtpd::Address;
|
use Qpsmtpd::Address;
|
||||||
@ -37,7 +36,6 @@ 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($_);
|
||||||
#warn Data::Dumper::Dumper(\@matches);
|
|
||||||
cmp_ok( scalar @matches, '==', 1, 'fetch_dmarc_record');
|
cmp_ok( scalar @matches, '==', 1, 'fetch_dmarc_record');
|
||||||
};
|
};
|
||||||
foreach ( qw/ example.com / ) {
|
foreach ( qw/ example.com / ) {
|
||||||
|
@ -8,10 +8,10 @@ use Qpsmtpd::Constants;
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test('test_hook_connect', 1);
|
$self->register_test('test_hook_connect');
|
||||||
$self->register_test('test_ip_whitelisted', 3);
|
$self->register_test('test_ip_whitelisted');
|
||||||
$self->register_test('test_is_set_rblsmtpd', 4);
|
$self->register_test('test_is_set_rblsmtpd');
|
||||||
$self->register_test('test_reject_type', 3);
|
$self->register_test('test_reject_type');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_ip_whitelisted {
|
sub test_ip_whitelisted {
|
||||||
|
@ -11,9 +11,9 @@ my $r;
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test('test_get_dspam_results', 6);
|
$self->register_test('test_get_dspam_results');
|
||||||
$self->register_test('test_log_and_return', 6);
|
$self->register_test('test_log_and_return');
|
||||||
$self->register_test('test_reject_type', 3);
|
$self->register_test('test_reject_type');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_log_and_return {
|
sub test_log_and_return {
|
||||||
@ -79,7 +79,6 @@ 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)" );
|
||||||
#warn Data::Dumper::Dumper($r);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,14 +8,14 @@ use Qpsmtpd::Constants;
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test('test_reject_type', 3);
|
$self->register_test('test_reject_type');
|
||||||
$self->register_test('test_log_and_pass', 1);
|
$self->register_test('test_log_and_pass');
|
||||||
$self->register_test('test_log_and_deny', 3);
|
$self->register_test('test_log_and_deny');
|
||||||
$self->register_test('test_data_handler', 3);
|
$self->register_test('test_data_handler');
|
||||||
$self->register_test('test_connect_handler', 3);
|
$self->register_test('test_connect_handler');
|
||||||
$self->register_test('test_apr_data_handler', 3);
|
$self->register_test('test_apr_data_handler');
|
||||||
$self->register_test('test_apr_connect_handler', 3);
|
$self->register_test('test_apr_connect_handler');
|
||||||
$self->register_test('test_mail_handler', 4);
|
$self->register_test('test_mail_handler');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_apr_connect_handler {
|
sub test_apr_connect_handler {
|
||||||
|
@ -16,14 +16,14 @@ foreach ( @greydbs ) {
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test('test_hook_data', 4);
|
$self->register_test('test_hook_data');
|
||||||
$self->register_test('test_get_db_key', 4);
|
$self->register_test('test_get_db_key');
|
||||||
$self->register_test('test_get_db_location', 1);
|
$self->register_test('test_get_db_location');
|
||||||
$self->register_test("test_greylist_geoip", 7);
|
$self->register_test("test_greylist_geoip");
|
||||||
$self->register_test("test_greylist_p0f_genre", 2);
|
$self->register_test("test_greylist_p0f_genre");
|
||||||
$self->register_test("test_greylist_p0f_distance", 2);
|
$self->register_test("test_greylist_p0f_distance");
|
||||||
$self->register_test("test_greylist_p0f_link", 2);
|
$self->register_test("test_greylist_p0f_link");
|
||||||
$self->register_test("test_greylist_p0f_uptime", 2);
|
$self->register_test("test_greylist_p0f_uptime");
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_hook_data {
|
sub test_hook_data {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!perl -w
|
#!perl -w
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Data::Dumper;
|
|
||||||
use POSIX qw(strftime);
|
use POSIX qw(strftime);
|
||||||
|
|
||||||
use Qpsmtpd::Address;
|
use Qpsmtpd::Address;
|
||||||
@ -12,8 +11,8 @@ my $test_email = 'matt@example.com';
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test('test_invalid_date_range', 7);
|
$self->register_test('test_invalid_date_range');
|
||||||
$self->register_test("test_hook_data_post", 7);
|
$self->register_test("test_hook_data_post");
|
||||||
}
|
}
|
||||||
|
|
||||||
sub setup_test_headers {
|
sub setup_test_headers {
|
||||||
|
@ -8,18 +8,18 @@ use Qpsmtpd::Constants;
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test('test_init_resolver', 2);
|
$self->register_test('test_init_resolver');
|
||||||
$self->register_test('test_is_in_badhelo', 2);
|
$self->register_test('test_is_in_badhelo');
|
||||||
$self->register_test('test_is_regex_match', 3);
|
$self->register_test('test_is_regex_match');
|
||||||
$self->register_test('test_invalid_localhost', 8);
|
$self->register_test('test_invalid_localhost');
|
||||||
$self->register_test('test_is_plain_ip', 3);
|
$self->register_test('test_is_plain_ip');
|
||||||
$self->register_test('test_is_address_literal', 3);
|
$self->register_test('test_is_address_literal');
|
||||||
$self->register_test('test_no_forward_dns', 2);
|
$self->register_test('test_no_forward_dns');
|
||||||
$self->register_test('test_no_reverse_dns', 3);
|
$self->register_test('test_no_reverse_dns');
|
||||||
$self->register_test('test_no_matching_dns', 2);
|
$self->register_test('test_no_matching_dns');
|
||||||
$self->register_test('test_helo_handler', 1);
|
$self->register_test('test_helo_handler');
|
||||||
$self->register_test('test_check_ip_match', 6);
|
$self->register_test('test_check_ip_match');
|
||||||
$self->register_test('test_check_name_match', 3);
|
$self->register_test('test_check_name_match');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_helo_handler {
|
sub test_helo_handler {
|
||||||
|
@ -14,13 +14,13 @@ sub register_tests {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
$self->register_test('test_geoip_lookup', 2);
|
$self->register_test('test_geoip_lookup');
|
||||||
$self->register_test('test_geoip_load_db', 2);
|
$self->register_test('test_geoip_load_db');
|
||||||
$self->register_test('test_geoip_init_cc', 2);
|
$self->register_test('test_geoip_init_cc');
|
||||||
$self->register_test('test_set_country_code', 3);
|
$self->register_test('test_set_country_code');
|
||||||
$self->register_test('test_set_country_name', 3);
|
$self->register_test('test_set_country_name');
|
||||||
$self->register_test('test_set_continent', 3);
|
$self->register_test('test_set_continent');
|
||||||
$self->register_test('test_set_distance', 3);
|
$self->register_test('test_set_distance');
|
||||||
};
|
};
|
||||||
|
|
||||||
sub test_geoip_lookup {
|
sub test_geoip_lookup {
|
||||||
|
@ -8,10 +8,10 @@ use Qpsmtpd::Constants;
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test('test_get_v2_query', 1);
|
$self->register_test('test_get_v2_query');
|
||||||
$self->register_test('test_get_v3_query', 1);
|
$self->register_test('test_get_v3_query');
|
||||||
$self->register_test('test_store_v2_results', 2);
|
$self->register_test('test_store_v2_results');
|
||||||
$self->register_test('test_store_v3_results', 2);
|
$self->register_test('test_store_v3_results');
|
||||||
};
|
};
|
||||||
|
|
||||||
sub test_query_p0f_v2 {
|
sub test_query_p0f_v2 {
|
||||||
@ -44,7 +44,6 @@ sub test_get_v2_query {
|
|||||||
|
|
||||||
my $r = $self->get_v2_query();
|
my $r = $self->get_v2_query();
|
||||||
ok( $r, 'r +' );
|
ok( $r, 'r +' );
|
||||||
#use Data::Dumper; warn Data::Dumper::Dumper( $r );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sub test_get_v3_query {
|
sub test_get_v3_query {
|
||||||
@ -68,7 +67,6 @@ 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 +" );
|
||||||
#use Data::Dumper; warn Data::Dumper::Dumper( $r );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sub test_store_v3_results {
|
sub test_store_v3_results {
|
||||||
|
@ -8,13 +8,12 @@ use Qpsmtpd::Constants;
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test('test_get_rcpt_host', 7);
|
$self->register_test('test_get_rcpt_host');
|
||||||
$self->register_test('test_is_in_rcpthosts', 3);
|
$self->register_test('test_is_in_rcpthosts');
|
||||||
$self->register_test('test_is_in_morercpthosts', 2);
|
$self->register_test('test_is_in_morercpthosts');
|
||||||
$self->register_test('test_hook_rcpt', 3);
|
$self->register_test('test_hook_rcpt');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub test_hook_rcpt {
|
sub test_hook_rcpt {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@ use Qpsmtpd::Constants;
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test('test_relay_only', 2);
|
$self->register_test('test_relay_only');
|
||||||
$self->register_test('test_is_octet_match', 3);
|
$self->register_test('test_is_octet_match');
|
||||||
$self->register_test('test_is_in_cidr_block', 4);
|
$self->register_test('test_is_in_cidr_block');
|
||||||
$self->register_test('test_is_in_norelayclients', 5);
|
$self->register_test('test_is_in_norelayclients');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_relay_only {
|
sub test_relay_only {
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Data::Dumper;
|
|
||||||
use Net::DNS;
|
use Net::DNS;
|
||||||
use Qpsmtpd::Address;
|
use Qpsmtpd::Address;
|
||||||
use Qpsmtpd::Constants;
|
use Qpsmtpd::Constants;
|
||||||
@ -17,12 +16,12 @@ sub register_tests {
|
|||||||
my %args = ( );
|
my %args = ( );
|
||||||
$self->register( $self->qp, reject => 0 );
|
$self->register( $self->qp, reject => 0 );
|
||||||
|
|
||||||
$self->register_test('test_populate_invalid_networks', 2);
|
$self->register_test('test_populate_invalid_networks');
|
||||||
$self->register_test('test_mx_address_resolves', 2);
|
$self->register_test('test_mx_address_resolves');
|
||||||
$self->register_test('test_get_host_records', 2);
|
$self->register_test('test_get_host_records');
|
||||||
$self->register_test('test_get_and_validate_mx', 2);
|
$self->register_test('test_get_and_validate_mx');
|
||||||
$self->register_test('test_check_dns', 2);
|
$self->register_test('test_check_dns');
|
||||||
$self->register_test('test_hook_mail', 4);
|
$self->register_test('test_hook_mail');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_hook_mail {
|
sub test_hook_mail {
|
||||||
|
@ -13,7 +13,7 @@ sub register_tests {
|
|||||||
eval 'use Mail::SPF';
|
eval 'use Mail::SPF';
|
||||||
return if $@;
|
return if $@;
|
||||||
|
|
||||||
$self->register_test('test_is_special_recipient', 5);
|
$self->register_test('test_is_special_recipient');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_is_special_recipient {
|
sub test_is_special_recipient {
|
||||||
|
@ -23,11 +23,11 @@ my @sample_headers = (
|
|||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
$self->register_test('test_connect_to_spamd', 4);
|
$self->register_test('test_connect_to_spamd');
|
||||||
$self->register_test('test_parse_spam_header', 10);
|
$self->register_test('test_parse_spam_header');
|
||||||
$self->register_test('test_get_spam_results', 20);
|
$self->register_test('test_get_spam_results');
|
||||||
$self->register_test('test_munge_subject', 4);
|
$self->register_test('test_munge_subject');
|
||||||
$self->register_test('test_reject', 2);
|
$self->register_test('test_reject');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_connect_to_spamd {
|
sub test_connect_to_spamd {
|
||||||
@ -48,7 +48,6 @@ sub test_connect_to_spamd {
|
|||||||
$self->print_to_spamd( $SPAMD, $message, $length, $username );
|
$self->print_to_spamd( $SPAMD, $message, $length, $username );
|
||||||
shutdown($SPAMD, 1); # close our side of the socket (tell spamd we're done)
|
shutdown($SPAMD, 1); # close our side of the socket (tell spamd we're done)
|
||||||
my $headers = $self->parse_spamd_response( $SPAMD );
|
my $headers = $self->parse_spamd_response( $SPAMD );
|
||||||
#warn Data::Dumper::Dumper($headers);
|
|
||||||
ok( $headers, "socket response\n");
|
ok( $headers, "socket response\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -61,11 +60,9 @@ sub test_connect_to_spamd {
|
|||||||
$SPAMD = $self->connect_to_spamd();
|
$SPAMD = $self->connect_to_spamd();
|
||||||
if ( $SPAMD ) {
|
if ( $SPAMD ) {
|
||||||
ok( $SPAMD, "tcp/ip");
|
ok( $SPAMD, "tcp/ip");
|
||||||
#warn Data::Dumper::Dumper($SPAMD);
|
|
||||||
$self->print_to_spamd( $SPAMD, $message, $length, $username );
|
$self->print_to_spamd( $SPAMD, $message, $length, $username );
|
||||||
shutdown($SPAMD, 1); # close our side of the socket (tell spamd we're done)
|
shutdown($SPAMD, 1); # close our side of the socket (tell spamd we're done)
|
||||||
my $headers = $self->parse_spamd_response( $SPAMD );
|
my $headers = $self->parse_spamd_response( $SPAMD );
|
||||||
#warn Data::Dumper::Dumper($headers);
|
|
||||||
ok( $headers, "tcp/ip response\n");
|
ok( $headers, "tcp/ip response\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -15,7 +15,7 @@ BEGIN { # need this to happen before anything else
|
|||||||
|
|
||||||
sub register_tests {
|
sub register_tests {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
$self->register_test('test_hook_user_config', 4);
|
$self->register_test('test_hook_user_config');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_hook_user_config {
|
sub test_hook_user_config {
|
||||||
@ -49,10 +49,7 @@ sub test_hook_user_config {
|
|||||||
|
|
||||||
package FakeAddress;
|
package FakeAddress;
|
||||||
|
|
||||||
sub new {
|
sub new { return bless {@_}, shift; }
|
||||||
shift;
|
|
||||||
return bless {@_};
|
|
||||||
}
|
|
||||||
sub address { return shift->{address} }
|
sub address { return shift->{address} }
|
||||||
sub user { return shift->{user} }
|
sub user { return shift->{user} }
|
||||||
sub host { return shift->{host} }
|
sub host { return shift->{host} }
|
||||||
|
@ -3,26 +3,27 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use Mail::Header;
|
||||||
|
|
||||||
use Qpsmtpd::Constants;
|
use Qpsmtpd::Constants;
|
||||||
use Qpsmtpd::Transaction;
|
use Qpsmtpd::Transaction;
|
||||||
use Mail::Header;
|
|
||||||
|
|
||||||
sub register_tests {
|
sub register_tests {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
SKIP: {
|
eval 'use ClamAV::Client'; ## no critic (Stringy)
|
||||||
eval 'use ClamAV::Client'; ## no critic (Stringy)
|
if (!$@) {
|
||||||
skip "Could not load ClamAV::Client", 4
|
warn "Could not load ClamAV::Client";
|
||||||
if $@;
|
$self->register_test('test_register');
|
||||||
$self->register_test('test_register', 6);
|
$self->register_test('test_get_clamd');
|
||||||
$self->register_test('test_get_clamd', 1);
|
};
|
||||||
}
|
|
||||||
$self->register_test('test_err_and_return', 2);
|
$self->register_test('test_err_and_return');
|
||||||
$self->register_test('test_get_filename', 1);
|
$self->register_test('test_get_filename');
|
||||||
$self->register_test('test_set_permission', 1);
|
$self->register_test('test_set_permission');
|
||||||
$self->register_test('test_is_too_big', 2);
|
$self->register_test('test_is_too_big');
|
||||||
$self->register_test('test_is_multipart', 2);
|
$self->register_test('test_is_multipart');
|
||||||
$self->register_test('test_should_scan',4);
|
$self->register_test('test_should_scan');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_register {
|
sub test_register {
|
||||||
|
Loading…
Reference in New Issue
Block a user