From 0a7c6f0f08c8796120e9f9e3740c81f32faaed2c Mon Sep 17 00:00:00 2001 From: Jared Johnson Date: Thu, 11 Dec 2014 16:06:54 -0600 Subject: [PATCH] Tests for ident/p0f register_genre_blocking() --- t/plugin_tests/ident/p0f | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/t/plugin_tests/ident/p0f b/t/plugin_tests/ident/p0f index fd25ded..509d14c 100644 --- a/t/plugin_tests/ident/p0f +++ b/t/plugin_tests/ident/p0f @@ -59,6 +59,34 @@ sub test_register_headers { } sub test_register_genre_blocking { + my ( $self ) = @_; + + $self->register_hook(); + $self->register_genre_blocking(); + is( $self->{_lastreg}, '', + 'rcpt_handler not registered when no blocked genres are configured' ); + + $self->register_hook(); + $self->fake_config( p0f_blocked_operating_systems => 'Crapple Macintawsh' ); + $self->register_genre_blocking(); + is( $self->{_lastreg}, 'rcpt,rcpt_handler', + 'rcpt_handler registered when blocked genre phrases are configured' ); + is( join('|', @{ delete $self->{os_block} || [] }), 'Crapple Macintawsh', + 'blocked OS phrases processed correctly' ); + is( join('|', @{ delete $self->{os_block_re} || [] }), '', + 'no blocked OS regexes' ); + + $self->register_hook(); + $self->fake_config( p0f_blocked_operating_systems => '/windoze/' ); + $self->register_genre_blocking(); + is( $self->{_lastreg}, 'rcpt,rcpt_handler', + 'rcpt_handler registered when blocked genre regexes are configured' ); + is( join('|', @{ delete $self->{os_block} || [] }), '', + 'no blocked OS phrases' ); + is( join('|', @{ delete $self->{os_block_re} || [] }), qr/windoze/i, + 'blocked OS regexes processed correctly' ); + + $self->unfake_config; } sub test_rcpt_handler {