Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#10164) fix ICMP property munging so that 'any' works #52

22 changes: 20 additions & 2 deletions lib/puppet/type/firewall.rb
Expand Up @@ -128,6 +128,10 @@
@resource.string_to_port(value)
end

def is_to_s(value)
should_to_s(value)
end

def should_to_s(value)
value = [value] unless value.is_a?(Array)
value.join(',')
Expand All @@ -154,6 +158,10 @@ def should_to_s(value)
@resource.string_to_port(value)
end

def is_to_s(value)
should_to_s(value)
end

def should_to_s(value)
value = [value] unless value.is_a?(Array)
value.join(',')
Expand All @@ -180,6 +188,10 @@ def should_to_s(value)
@resource.string_to_port(value)
end

def is_to_s(value)
should_to_s(value)
end

def should_to_s(value)
value = [value] unless value.is_a?(Array)
value.join(',')
Expand All @@ -192,7 +204,7 @@ def should_to_s(value)
*tcp*.
EOS

newvalues(:tcp, :udp, :icmp, :"ipv6-icmp", :esp, :ah, :vrrp, :igmp, :ipencap, :all)
newvalues(:tcp, :udp, :icmp, :"ipv6-icmp", :esp, :ah, :vrrp, :igmp, :ipencap, :ospf, :all)
defaultto "tcp"
end

Expand Down Expand Up @@ -354,7 +366,9 @@ def should_to_s(value)

munge do |value|
if value.kind_of?(String)
value = @resource.icmp_name_to_number(value)
if value != "any"
value = @resource.icmp_name_to_number(value)
end
else
value
end
Expand Down Expand Up @@ -387,6 +401,10 @@ def should=(values)
@should = super(values).sort
end

def is_to_s(value)
should_to_s(value)
end

def should_to_s(value)
value = [value] unless value.is_a?(Array)
value.join(',')
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/puppet/type/firewall_spec.rb
Expand Up @@ -74,7 +74,7 @@
end

describe ':proto' do
[:tcp, :udp, :icmp, :esp, :ah, :vrrp, :igmp, :ipencap, :all].each do |proto|
[:tcp, :udp, :icmp, :esp, :ah, :vrrp, :igmp, :ipencap, :ospf, :all].each do |proto|
it "should accept proto value #{proto}" do
@resource[:proto] = proto
@resource[:proto].should == proto
Expand Down