From e2c84987f300bca753fb06296a226aca0d6feec4 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Fri, 22 Jun 2012 19:24:16 -0400 Subject: [PATCH] helo: refine plugin tests --- plugins/helo | 6 +++--- t/misc.t | 7 +------ t/plugin_tests/helo | 15 +++++++-------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/plugins/helo b/plugins/helo index 55e8e8e..58748c7 100644 --- a/plugins/helo +++ b/plugins/helo @@ -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' ) { diff --git a/t/misc.t b/t/misc.t index 96b80f8..82526bf 100644 --- a/t/misc.t +++ b/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", diff --git a/t/plugin_tests/helo b/t/plugin_tests/helo index 20fa763..25ba153 100644 --- a/t/plugin_tests/helo +++ b/t/plugin_tests/helo @@ -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 {