File tree Expand file tree Collapse file tree
lib/puppet/provider/firewall Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -438,7 +438,7 @@ def update_args
438438
439439 def delete_args
440440 # Split into arguments
441- line = properties [ :line ] . gsub ( /\- A/ , '-D' ) . split ( /\s (?=(?:[^"]|"[^"]*")*$)/ ) . map { |v | v . gsub ( /"/ , '' ) }
441+ line = properties [ :line ] . gsub ( /\- A / , '-D ' ) . split ( /\s (?=(?:[^"]|"[^"]*")*$)/ ) . map { |v | v . gsub ( /"/ , '' ) }
442442 line . unshift ( "-t" , properties [ :table ] )
443443 end
444444
Original file line number Diff line number Diff line change @@ -2207,4 +2207,43 @@ class { '::firewall': }
22072207 end
22082208 end
22092209
2210+ context 'log_prefix containing -A' do
2211+ it 'adds the rule' do
2212+ pp = <<-EOS
2213+ class { '::firewall': }
2214+ firewall { '700 - test':
2215+ jump => 'LOG',
2216+ log_prefix => 'FW-A-INPUT: ',
2217+ }
2218+ EOS
2219+
2220+ apply_manifest ( pp , :catch_failures => true )
2221+ end
2222+
2223+ it 'should contain the rule' do
2224+ shell ( 'iptables-save' ) do |r |
2225+ expect ( r . stdout ) . to match ( /-A INPUT -p tcp -m comment --comment "100 foo bar" -j LOG --log-prefix "FW-A-INPUT: "/ )
2226+ end
2227+ end
2228+
2229+ it 'removes the rule' do
2230+ pp = <<-EOS
2231+ class { '::firewall': }
2232+ firewall { '700 - test':
2233+ ensure => absent,
2234+ jump => 'LOG',
2235+ log_prefix => 'FW-A-INPUT: ',
2236+ }
2237+ EOS
2238+
2239+ apply_manifest ( pp , :catch_failures => true )
2240+ end
2241+
2242+ it 'should not contain the rule' do
2243+ shell ( 'iptables-save' ) do |r |
2244+ expect ( r . stdout ) . to_not match ( /-A INPUT -p tcp -m comment --comment "100 foo bar" -j LOG --log-prefix "FW-A-INPUT: "/ )
2245+ end
2246+ end
2247+ end
2248+
22102249end
You can’t perform that action at this time.
0 commit comments