From dcdda3a5e71170487e2c910307364ef633acdda9 Mon Sep 17 00:00:00 2001 From: Jared Johnson Date: Tue, 3 Feb 2015 17:01:52 -0600 Subject: [PATCH 1/2] Don't interpret invalid return codes as OK --- lib/Qpsmtpd.pm | 4 ++++ t/qpsmtpd.t | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/Qpsmtpd.pm b/lib/Qpsmtpd.pm index a17f242..f77c251 100644 --- a/lib/Qpsmtpd.pm +++ b/lib/Qpsmtpd.pm @@ -302,6 +302,10 @@ sub run_continuation { $self->log(LOGERROR, $log_msg . "undef!"); next; } + if ( !return_code($r[0]) ) { + $self->log(LOGERROR, $log_msg . $r[0]); + next; + } if ($tran) { my $tnotes = $tran->notes($name); diff --git a/t/qpsmtpd.t b/t/qpsmtpd.t index 4c81d8c..982bb67 100644 --- a/t/qpsmtpd.t +++ b/t/qpsmtpd.t @@ -149,12 +149,13 @@ sub __run_continuation { descr => 'DECLINED -> DENY', }, # TODO: ignore invalid return codes rather than treating them like OK - #{ - # hooks => [ [123456,undef], [DENY, 'goaway'] ], - # expected_response => '550/goaway', - # disconnected => 0, - # descr => 'INVALID -> DENY', - #}, + { + hooks => [ [123456,undef], [DENY, 'goaway'] ], + expected_response => '550/goaway', + disconnected => 0, + logged => 'LOGERROR:Plugin ___FakeHook___, hook helo returned 123456', + descr => 'INVALID -> DENY', + }, { hooks => [ sub { die "dead\n" }, [DENY, 'begone'] ], expected_response => '550/begone', From 92d5ff6dc73669750d43364822fc81bdfcd056b7 Mon Sep 17 00:00:00 2001 From: Jared Johnson Date: Tue, 3 Feb 2015 17:11:05 -0600 Subject: [PATCH 2/2] Fix test descriptions --- t/qpsmtpd.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/qpsmtpd.t b/t/qpsmtpd.t index 982bb67..d422dd7 100644 --- a/t/qpsmtpd.t +++ b/t/qpsmtpd.t @@ -183,7 +183,7 @@ sub __run_continuation { $smtpd->run_continuation; my $response = join '/', @{ $smtpd->{_response} || [] }; is( $response, $t->{expected_response}, - "run_continuation(): Respond to $t->{descr} with $response" ); + "run_continuation(): Respond to $t->{descr} with $t->{expected_response}" ); if ( $t->{disconnected} ) { ok( $smtpd->connection->notes('disconnected'), "run_continuation() disconnects on $t->{descr}" );