File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ def validate_rules
7171 validation_errors = case protocol
7272 when 'tcp' , 'udp'
7373 CloudController ::TransportRuleValidator . validate ( stringified_rule )
74- when 'icmp'
74+ when 'icmp' , 'icmpv6'
7575 CloudController ::ICMPRuleValidator . validate ( stringified_rule )
7676 when 'all'
7777 CloudController ::RuleValidator . validate ( stringified_rule )
Original file line number Diff line number Diff line change @@ -19,6 +19,15 @@ def build_icmp_rule(attrs={})
1919 } . merge ( attrs )
2020 end
2121
22+ def build_icmpv6_rule ( attrs = { } )
23+ {
24+ 'protocol' => 'icmpv6' ,
25+ 'type' => 0 ,
26+ 'code' => 0 ,
27+ 'destination' => '::/0'
28+ } . merge ( attrs )
29+ end
30+
2231 def build_all_rule ( attrs = { } )
2332 {
2433 'protocol' => 'all' ,
@@ -601,13 +610,37 @@ def build_all_rule(attrs={})
601610 end
602611 end
603612
613+ context 'when it is a valid IPv6 CIDR' do
614+ before do
615+ TestConfig . config [ :enable_ipv6 ] = true
616+ end
617+
618+ let ( :rule ) { build_icmpv6_rule ( 'destination' => '2001:db8::/32' ) }
619+
620+ it 'is valid' do
621+ expect ( subject ) . to be_valid
622+ end
623+ end
624+
604625 context 'when it is a valid range' do
605626 let ( :rule ) { build_icmp_rule ( 'destination' => '1.1.1.1-2.2.2.2' ) }
606627
607628 it 'is valid' do
608629 expect ( subject ) . to be_valid
609630 end
610631 end
632+
633+ context 'when it is a valid IPv6 range' do
634+ before do
635+ TestConfig . config [ :enable_ipv6 ] = true
636+ end
637+
638+ let ( :rule ) { build_icmpv6_rule ( 'destination' => '2001:0db8::1-2001:0db8::ff' ) }
639+
640+ it 'is valid' do
641+ expect ( subject ) . to be_valid
642+ end
643+ end
611644 end
612645
613646 context 'bad' do
You can’t perform that action at this time.
0 commit comments