Debian Codegraph @

t/plugin_tests/count_unrecognized_commands

raw
1 #!perl -w
2
3 use strict;
4 use warnings;
5
6 use Qpsmtpd::Constants;
7
8 sub register_tests {
9 my $self = shift;
10
11 $self->register_test('test_hook_unrecognized_command', 4);
12 };
13
14 sub test_hook_unrecognized_command {
15 my $self = shift;
16
17 $self->{_unrec_cmd_max} = 2;
18 $self->connection->notes( 'unrec_cmd_count', 0 );
19
20 my ($code, $mess) = $self->hook_unrecognized_command(undef,'hiya');
21 cmp_ok( $code, '==', DECLINED, "good" );
22
23 $self->connection->notes( 'unrec_cmd_count', 2 );
24 ($code, $mess) = $self->hook_unrecognized_command(undef,'snookums');
25 cmp_ok( $code, '==', DENY_DISCONNECT, "limit" );
26
27 ($code, $mess) = $self->hook_unrecognized_command(undef,'wtf');
28 cmp_ok( $code, '==', DENY_DISCONNECT, "over limit" );
29
30 cmp_ok( $self->connection->notes( 'unrec_cmd_count'), '==', 4, "correct increment" );
31 };