Merge pull request #222 from jaredj/invalid-return

Don't interpret invalid return codes as OK
This commit is contained in:
Matt Simerson 2015-02-03 15:16:55 -08:00
commit dfaeb1d795
2 changed files with 12 additions and 7 deletions

View File

@ -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);

View File

@ -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',
@ -182,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}" );