Skip to content

Commit

Permalink
Merge pull request #479 from mhaskel/MODULES-1453
Browse files Browse the repository at this point in the history
MODULES-1453 - overly aggressive gsub
  • Loading branch information
cmurphy committed Jan 26, 2015
2 parents 4fa0976 + ce98905 commit 0245f51
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/puppet/provider/firewall/iptables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def update_args

def delete_args
# Split into arguments
line = properties[:line].gsub(/\-A/, '-D').split(/\s(?=(?:[^"]|"[^"]*")*$)/).map{|v| v.gsub(/"/, '')}
line = properties[:line].gsub(/\-A /, '-D ').split(/\s(?=(?:[^"]|"[^"]*")*$)/).map{|v| v.gsub(/"/, '')}
line.unshift("-t", properties[:table])
end

Expand Down
39 changes: 39 additions & 0 deletions spec/acceptance/firewall_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2207,4 +2207,43 @@ class { '::firewall': }
end
end

context 'log_prefix containing -A' do
it 'adds the rule' do
pp = <<-EOS
class { '::firewall': }
firewall { '700 - test':
jump => 'LOG',
log_prefix => 'FW-A-INPUT: ',
}
EOS

apply_manifest(pp, :catch_failures => true)
end

it 'should contain the rule' do
shell('iptables-save') do |r|
expect(r.stdout).to match(/-A INPUT -p tcp -m comment --comment "100 foo bar" -j LOG --log-prefix "FW-A-INPUT: "/)
end
end

it 'removes the rule' do
pp = <<-EOS
class { '::firewall': }
firewall { '700 - test':
ensure => absent,
jump => 'LOG',
log_prefix => 'FW-A-INPUT: ',
}
EOS

apply_manifest(pp, :catch_failures => true)
end

it 'should not contain the rule' do
shell('iptables-save') do |r|
expect(r.stdout).to_not match(/-A INPUT -p tcp -m comment --comment "100 foo bar" -j LOG --log-prefix "FW-A-INPUT: "/)
end
end
end

end

0 comments on commit 0245f51

Please sign in to comment.