From 4a9ce6d3622d5c539159fef8b925ea04d1e614f9 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 20 May 2014 08:24:31 +0200 Subject: [PATCH] add tests for corosync multicast addrtype rules --- test/fwtester.pl | 14 ++++++++++++-- test/test-default-rules1/tests | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/test/fwtester.pl b/test/fwtester.pl index 17b883d..a99a790 100755 --- a/test/fwtester.pl +++ b/test/fwtester.pl @@ -81,8 +81,16 @@ sub rule_match { die "please implement cstate test '$cstate'"; } - if ($rule =~ s/^-m addrtype\s*//) { - return undef; # simply ignore + if ($rule =~ s/^-m addrtype --src-type (\S+)\s*//) { + my $atype = $1; + die "missing srctype" if !$pkg->{srctype}; + return undef if $atype ne $pkg->{srctype}; + } + + if ($rule =~ s/^-m addrtype --dst-type (\S+)\s*//) { + my $atype = $1; + die "missing dsttype" if !$pkg->{dsttype}; + return undef if $atype ne $pkg->{dsttype}; } if ($rule =~ s/^-i (\S+)\s*//) { @@ -485,6 +493,8 @@ sub simulate_firewall { dport => undef, source => undef, dest => undef, + srctype => 'UNICAST', + dsttype => 'UNICAST', }; while (my ($k,$v) = each %$test) { diff --git a/test/test-default-rules1/tests b/test/test-default-rules1/tests index 58c7743..4aaf7c4 100644 --- a/test/test-default-rules1/tests +++ b/test/test-default-rules1/tests @@ -12,6 +12,8 @@ { from => 'host', to => 'outside', dest => '172.16.1.3', proto => 'udp', dport => 5404, action => 'ACCEPT' } { from => 'host', to => 'outside', dest => '172.16.1.3', proto => 'udp', dport => 5405, action => 'ACCEPT' } { from => 'host', to => 'outside', dest => '172.16.1.3', proto => 'udp', dport => 5406, action => 'DROP' } +{ from => 'host', to => 'outside', dest => '239.192.158.83', proto => 'udp', dport => 5404, dsttype => 'UNICAST', action => 'DROP' } +{ from => 'host', to => 'outside', dest => '239.192.158.83', proto => 'udp', dport => 5404, dsttype => 'MULTICAST', action => 'ACCEPT' } # traffic from other node @@ -26,6 +28,8 @@ { from => 'outside', to => 'host', source => '172.16.1.3', proto => 'udp', dport => 5404, action => 'ACCEPT' } { from => 'outside', to => 'host', source => '172.16.1.3', proto => 'udp', dport => 5405, action => 'ACCEPT' } { from => 'outside', to => 'host', source => '172.16.1.3', proto => 'udp', dport => 5406, action => 'DROP' } +{ from => 'outside', to => 'host', source => '172.16.1.3', dest => '239.192.158.83', proto => 'udp', dport => 5404, dsttype => 'UNICAST', action => 'DROP' } +{ from => 'outside', to => 'host', source => '172.16.1.3', dest => '239.192.158.83', proto => 'udp', dport => 5404, dsttype => 'MULTICAST', action => 'ACCEPT' } { from => 'host', to => 'ct200', action => 'DROP' } -- 2.39.2