Merge pull request #229 from jaredj/more-test

A little more testing for run_continuation()
This commit is contained in:
Matt Simerson 2015-02-11 13:17:01 -08:00
commit 1ef0aa1008

View File

@ -148,7 +148,6 @@ sub __run_continuation {
disconnected => 0, disconnected => 0,
descr => 'DECLINED -> DENY', descr => 'DECLINED -> DENY',
}, },
# TODO: ignore invalid return codes rather than treating them like OK
{ {
hooks => [ [123456,undef], [DENY, 'goaway'] ], hooks => [ [123456,undef], [DENY, 'goaway'] ],
expected_response => '550/goaway', expected_response => '550/goaway',
@ -170,8 +169,16 @@ sub __run_continuation {
logged => 'LOGERROR:Plugin ___FakeHook___, hook helo returned undef!', logged => 'LOGERROR:Plugin ___FakeHook___, hook helo returned undef!',
descr => 'undef -> DENY', descr => 'undef -> DENY',
}, },
{
hooks => [ [OK, 'bemyguest'], [DENY, 'seeya'] ],
expected_response => '250/fqdn Hi test@localhost [127.0.0.1];'
. ' I am so happy to meet you.',
disconnected => 0,
descr => 'OK -> DENY',
},
); );
for my $t (@test_data) { for my $t (@test_data) {
$smtpd->fake_config( me => 'fqdn' );
for my $h ( reverse @{ $t->{hooks} } ) { for my $h ( reverse @{ $t->{hooks} } ) {
my $sub = ( ref $h eq 'ARRAY' ? sub { return @$h } : $h ); my $sub = ( ref $h eq 'ARRAY' ? sub { return @$h } : $h );
$smtpd->fake_hook( 'helo', $sub ); $smtpd->fake_hook( 'helo', $sub );
@ -197,6 +204,7 @@ sub __run_continuation {
"run_continuation() logging on $t->{descr}" ); "run_continuation() logging on $t->{descr}" );
} }
$smtpd->unfake_hook('helo'); $smtpd->unfake_hook('helo');
$smtpd->unfake_config();
} }
} }