From: Patrick Hemmer Date: Fri, 20 Dec 2013 20:30:50 +0000 (-0500) Subject: update spec for host_to_mask to override Resolv X-Git-Tag: 0.5.0~18^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=bc466f5d1bf557fca1c8f1f17d8c3c6b44ef1f3b;p=puppet-modules%2Fpuppetlabs-firewall.git update spec for host_to_mask to override Resolv --- diff --git a/lib/puppet/provider/firewall/iptables.rb b/lib/puppet/provider/firewall/iptables.rb index 05cbdfc..1b9788e 100644 --- a/lib/puppet/provider/firewall/iptables.rb +++ b/lib/puppet/provider/firewall/iptables.rb @@ -167,7 +167,7 @@ Puppet::Type.type(:firewall).provide :iptables, :parent => Puppet::Provider::Fir # --tcp-flags takes two values; we cheat by adding " around it # so it behaves like --comment values = values.sub(/--tcp-flags (\S*) (\S*)/, '--tcp-flags "\1 \2"') - # we do a simular thing for negated address masks (source and destination). + # we do a similar thing for negated address masks (source and destination). values = values.sub(/(-\S+) (!)\s?(\S*)/,'\1 "\2 \3"') # the actual rule will have the ! mark before the option. values = values.sub(/(!)\s*(-\S+)\s*(\S*)/, '\2 "\1 \3"') diff --git a/spec/unit/puppet/util/firewall_spec.rb b/spec/unit/puppet/util/firewall_spec.rb index 2d1ddb0..ef16be1 100644 --- a/spec/unit/puppet/util/firewall_spec.rb +++ b/spec/unit/puppet/util/firewall_spec.rb @@ -27,8 +27,11 @@ describe 'Puppet::Util::Firewall' do describe '#host_to_mask' do subject { resource } - specify { subject.host_to_mask('puppetlabs.com').should == '96.126.112.51/32' } - specify { subject.host_to_mask('!puppetlabs.com').should == '! 96.126.112.51/32' } + specify { + expect(Resolv).to receive(:getaddress).any_number_of_times.with('puppetlabs.com').and_return('96.126.112.51') + subject.host_to_mask('puppetlabs.com').should == '96.126.112.51/32' + subject.host_to_mask('!puppetlabs.com').should == '! 96.126.112.51/32' + } specify { subject.host_to_mask('96.126.112.51').should == '96.126.112.51/32' } specify { subject.host_to_mask('!96.126.112.51').should == '! 96.126.112.51/32' } specify { subject.host_to_mask('96.126.112.51/32').should == '96.126.112.51/32' }