valrev = values.scan(/("([^"\\]|\\.)*"|\S+)/).transpose[0].reverse
if keys.length != valrev.length then
- raise "Parser error: keys (#{keys.length}) and values (#{valrev.length}) count mismatch on line: #{line}"
+ warning "Skipping unparsable iptables rule: keys (#{keys.length}) and values (#{valrev.length}) count mismatch on line: #{line}"
+ return
end
# Here we generate the main hash by scanning arguments off the values
'parser_sanity_check' => {
:line => '-A INPUT -s 1.2.3.4/32 -p tcp -m tcp --dport 80 --tcp-flags FIN,SYN,RST,ACK SYN -m comment --comment "004 parser sanity check" -j ACCEPT',
:table => 'filter',
- :raise_error => true,
+ :produce_warning => true,
:params => {},
},
}
describe "for test data '#{test_name}'" do
let(:resource) { provider.rule_to_hash(data[:line], data[:table], 0) }
# If this option is enabled, make sure the error was raised
- if data[:raise_error] then
- it "the input rules should raise an error by rules_to_hash" do
- expect{ resource }.to raise_error
+ if data[:produce_warning] then
+ puts data
+ it "the input rules should produce a warning by rules_to_hash" do
+ expect(provider).to receive(:warning).with(/Skipping unparsable iptables rule/)
+ resource # force resource to get evaluated
end
end