2012-05-21 05:04:37 +02:00
|
|
|
#!perl -w
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Qpsmtpd::Constants;
|
|
|
|
|
|
|
|
sub register_tests {
|
|
|
|
my $self = shift;
|
|
|
|
|
2014-09-17 08:16:53 +02:00
|
|
|
$self->register_test('test_hook_unrecognized_command');
|
2014-11-11 23:59:40 +01:00
|
|
|
}
|
2012-05-21 05:04:37 +02:00
|
|
|
|
|
|
|
sub test_hook_unrecognized_command {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
$self->{_unrec_cmd_max} = 2;
|
2012-06-02 06:43:37 +02:00
|
|
|
$self->connection->notes( 'unrec_cmd_count', 0 );
|
2012-05-21 05:04:37 +02:00
|
|
|
|
|
|
|
my ($code, $mess) = $self->hook_unrecognized_command(undef,'hiya');
|
|
|
|
cmp_ok( $code, '==', DECLINED, "good" );
|
|
|
|
|
2012-06-02 06:43:37 +02:00
|
|
|
$self->connection->notes( 'unrec_cmd_count', 2 );
|
2012-05-21 05:04:37 +02:00
|
|
|
($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" );
|
|
|
|
|
2012-06-02 06:43:37 +02:00
|
|
|
cmp_ok( $self->connection->notes( 'unrec_cmd_count'), '==', 4, "correct increment" );
|
2014-11-11 23:59:40 +01:00
|
|
|
}
|