map_index={}
@resource_map.each_pair do |map_k,map_v|
[map_v].flatten.each do |v|
- ind=values.index(/\s#{v}/)
+ ind=values.index(/\s#{v}\s/)
next unless ind
map_index[map_k]=ind
end
it 'should contain the rule' do
shell('iptables-save -t nat') do |r|
- expect(r.stdout).to match(/-A PREROUTING -s 200.200.200.200(\/32)? -p tcp -m comment --comment "611 - test" -j NETMAP --to 192.168.1.1/)
+ expect(r.stdout).to match(/-A PREROUTING -s 200.200.200.200(\/32)? -p tcp -m comment --comment "569 - test" -j NETMAP --to 192.168.1.1/)
end
end
end
+ describe 'reset' do
+ it 'deletes all rules' do
+ shell('ip6tables --flush')
+ shell('iptables --flush; iptables -t nat --flush; iptables -t mangle --flush')
+ end
+ end
+
context 'Source netmap 192.168.1.1' do
it 'applies' do
pp = <<-EOS
it 'should contain the rule' do
shell('iptables-save -t nat') do |r|
- expect(r.stdout).to match(/-A POSTROUTING -d 200.200.200.200(\/32)? -p tcp -m comment --comment "611 - test" -j NETMAP --to 192.168.1.1/)
+ expect(r.stdout).to match(/-A POSTROUTING -d 200.200.200.200(\/32)? -p tcp -m comment --comment "569 - test" -j NETMAP --to 192.168.1.1/)
end
end
end