Skip to content

Commit 4e5e57d

Browse files
committed
Add "icmpv6" protocol to SecurityGroup class
1 parent 3f8f4a7 commit 4e5e57d

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

app/models/runtime/security_group.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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)

spec/unit/models/runtime/security_group_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)