qpsmtpd/t/plugin_tests/count_unrecognized_commands
Matt Simerson 5e76d66c66 count_unrecognized_commands
simplified logic in a couple places
consolidated duplicated message
added 4 tests
2012-05-20 23:34:58 -07:00

32 lines
853 B
Perl

#!perl -w
use strict;
use warnings;
use Qpsmtpd::Constants;
sub register_tests {
my $self = shift;
$self->register_test('test_hook_unrecognized_command', 4);
};
sub test_hook_unrecognized_command {
my $self = shift;
$self->{_unrec_cmd_max} = 2;
$self->qp->connection->notes( 'unrec_cmd_count', 0 );
my ($code, $mess) = $self->hook_unrecognized_command(undef,'hiya');
cmp_ok( $code, '==', DECLINED, "good" );
$self->qp->connection->notes( 'unrec_cmd_count', 2 );
($code, $mess) = $self->hook_unrecognized_command(undef,'snookums');
cmp_ok( $code, '==', DENY_DISCONNECT, "limit" );
($code, $mess) = $self->hook_unrecognized_command(undef,'wtf');
cmp_ok( $code, '==', DENY_DISCONNECT, "over limit" );
cmp_ok( $self->qp->connection->notes( 'unrec_cmd_count'), '==', 4, "correct increment" );
};