helo: refine plugin tests
This commit is contained in:
parent
4cf99154ad
commit
5e2336f7da
@ -209,7 +209,7 @@ use Qpsmtpd::Constants;
|
||||
use Net::DNS;
|
||||
|
||||
sub register {
|
||||
my ($self, $qp) = shift, shift;
|
||||
my ($self, $qp) = (shift, shift);
|
||||
$self->{_args} = { @_ };
|
||||
$self->{_args}{reject_type} = 'disconnect';
|
||||
$self->{_args}{policy} ||= 'lenient';
|
||||
@ -262,8 +262,8 @@ sub populate_tests {
|
||||
@{ $self->{_helo_tests} } = qw/ is_in_badhelo invalid_localhost is_forged_literal /;
|
||||
|
||||
if ( $policy eq 'rfc' || $policy eq 'strict' ) {
|
||||
push @{ $self->{_helo_tests} }, qw/ is_plain_ip is_not_fqdn no_forward_dns
|
||||
no_reverse_dns /;
|
||||
push @{ $self->{_helo_tests} }, qw/ is_plain_ip is_not_fqdn
|
||||
no_forward_dns no_reverse_dns /;
|
||||
};
|
||||
|
||||
if ( $policy eq 'strict' ) {
|
||||
|
7
t/misc.t
7
t/misc.t
@ -1,16 +1,11 @@
|
||||
use Test::More tests => 14;
|
||||
use Test::More tests => 12;
|
||||
use strict;
|
||||
use lib 't';
|
||||
use_ok('Test::Qpsmtpd');
|
||||
|
||||
ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");
|
||||
|
||||
# check_spamhelo plugin
|
||||
is(($smtpd->command('HELO yahoo.com'))[0], 550, 'HELO yahoo.com');
|
||||
|
||||
|
||||
# fault method
|
||||
is(($smtpd->command('HELO localhost'))[0], 250, 'HELO localhost');
|
||||
is(($smtpd->fault)->[0], 451, 'fault returns 451');
|
||||
is(($smtpd->fault("test message"))->[1],
|
||||
"Internal error - try again later - test message",
|
||||
|
@ -15,12 +15,11 @@ sub register_tests {
|
||||
$self->register_test('test_is_plain_ip', 3);
|
||||
$self->register_test('test_is_address_literal', 3);
|
||||
$self->register_test('test_no_forward_dns', 2);
|
||||
$self->register_test('test_no_reverse_dns', 2);
|
||||
$self->register_test('test_no_matching_dns', 4);
|
||||
$self->register_test('test_no_matching_dns', 4);
|
||||
$self->register_test('test_no_reverse_dns', 3);
|
||||
$self->register_test('test_no_matching_dns', 2);
|
||||
$self->register_test('test_helo_handler', 1);
|
||||
$self->register_test('test_check_ip_match', 4);
|
||||
$self->register_test('test_check_name_match', 4);
|
||||
$self->register_test('test_check_ip_match', 3);
|
||||
$self->register_test('test_check_name_match', 3);
|
||||
}
|
||||
|
||||
sub test_helo_handler {
|
||||
@ -150,15 +149,15 @@ sub test_check_ip_match {
|
||||
|
||||
$self->connection->notes('helo_forward_match', 0);
|
||||
$self->check_ip_match('192.0.2.1');
|
||||
ok( $self->connection->notes('helo_forward_match'), "exact";
|
||||
ok( $self->connection->notes('helo_forward_match'), "exact");
|
||||
|
||||
$self->connection->notes('helo_forward_match', 0);
|
||||
$self->check_ip_match('192.0.2.2');
|
||||
ok( $self->connection->notes('helo_forward_match'), "network";
|
||||
ok( $self->connection->notes('helo_forward_match'), "network");
|
||||
|
||||
$self->connection->notes('helo_forward_match', 0);
|
||||
$self->check_ip_match('192.0.1.1');
|
||||
ok( ! $self->connection->notes('helo_forward_match'), "miss";
|
||||
ok( ! $self->connection->notes('helo_forward_match'), "miss");
|
||||
};
|
||||
|
||||
sub test_check_name_match {
|
||||
|
Loading…
Reference in New Issue
Block a user