Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Make chef13 compatible #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ provisioner:
data_path: test/shared

platforms:
- name: centos-6.5
- name: ubuntu-16.04

suites:
- name: default
Expand Down
5 changes: 3 additions & 2 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@
node.rm_normal("simple_iptables", "ipv6")
# Then run all the simple_iptables_* resources
run_context.resource_collection.each do |resource|
if resource.kind_of?(Chef::Resource::SimpleIptablesRule)
puts resource.class.resource_name
if resource.class.resource_name.to_s == "simple_iptables_rule"
Chef::Log.debug("about to run simple_iptables_rule[#{resource.chain}]")
resource.run_action(resource.action)
elsif resource.kind_of?(Chef::Resource::SimpleIptablesPolicy)
elsif resource.class.resource_name.to_s == "simple_iptables_policy"
Chef::Log.debug("about to run simple_iptables_policy[#{resource.chain}]")
resource.run_action(resource.action)
end
Expand Down
18 changes: 10 additions & 8 deletions test/integration/default/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
require_relative '../../../kitchen/data/spec_helper'
require "serverspec"

set :backend, :exec

describe iptables do
it { should have_rule('-A INPUT -j simple_rule') }
it { should have_rule('-A simple_rule -p tcp -m tcp --dport 80 -j ACCEPT') }
it { should have_rule('-A INPUT -p tcp -m tcp --dport 81 -j ACCEPT') }
it { should have_rule('-A FORWARD -p tcp -m tcp --dport 82 -j ACCEPT') }
it { should have_rule('-A simple_rule -p tcp -m tcp --dport 80 -m comment --comment simple_rule -j ACCEPT') }
it { should have_rule('-A INPUT -p tcp -m tcp --dport 81 -m comment --comment rule_in_input_chain -j ACCEPT') }
it { should have_rule('-A FORWARD -p tcp -m tcp --dport 82 -m comment --comment rule_in_forward_chain -j ACCEPT') }
it { should have_rule('-A INPUT -m state --state NEW -j jump_with_rule') }
it { should have_rule('-A jump_with_rule -p tcp -m tcp --dport 83 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 84 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 85 -j ACCEPT') }
it { should have_rule('-A jump_with_rule -p tcp -m tcp --dport 83 -m comment --comment jump_with_rule -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 84 -m comment --comment array_of_rules -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 85 -m comment --comment array_of_rules -j ACCEPT') }
it { should have_rule('-A INPUT -j array_of_rules') }
end
end
24 changes: 13 additions & 11 deletions test/integration/ipv6_default/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
require_relative '../../../kitchen/data/spec_helper'
require 'serverspec'

set :backend, :exec

describe iptables do
it { should have_rule('-A INPUT -j simple_rule') }
it { should have_rule('-A simple_rule -p tcp -m tcp --dport 80 -j ACCEPT') }
it { should have_rule('-A INPUT -p tcp -m tcp --dport 81 -j ACCEPT') }
it { should have_rule('-A FORWARD -p tcp -m tcp --dport 82 -j ACCEPT') }
it { should have_rule('-A simple_rule -p tcp -m tcp --dport 80 -m comment --comment simple_rule -j ACCEPT') }
it { should have_rule('-A INPUT -p tcp -m tcp --dport 81 -m comment --comment rule_in_input_chain -j ACCEPT') }
it { should have_rule('-A FORWARD -p tcp -m tcp --dport 82 -m comment --comment rule_in_forward_chain -j ACCEPT') }
it { should have_rule('-A jump_with_rule -p tcp -m tcp --dport 83 -m comment --comment jump_with_rule -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 84 -m comment --comment array_of_rules -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 85 -m comment --comment array_of_rules -j ACCEPT') }
it { should have_rule('-A INPUT -m state --state NEW -j jump_with_rule') }
it { should have_rule('-A jump_with_rule -p tcp -m tcp --dport 83 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 84 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 85 -j ACCEPT') }
it { should have_rule('-A INPUT -j array_of_rules') }
end

describe ip6tables do
it { should have_rule('-A INPUT -j simple_rule') }
it { should have_rule('-A simple_rule -p tcp -m tcp --dport 80 -j ACCEPT') }
it { should have_rule('-A INPUT -p tcp -m tcp --dport 81 -j ACCEPT') }
it { should have_rule('-A simple_rule -p tcp -m tcp --dport 80 -m comment --comment simple_rule -j ACCEPT') }
it { should have_rule('-A INPUT -p tcp -m tcp --dport 81 -m comment --comment rule_in_input_chain -j ACCEPT') }
it { should_not have_rule('-A FORWARD -p tcp -m tcp --dport 82 -j ACCEPT') }
it { should_not have_rule('-A INPUT -m state --state NEW -j jump_with_rule') }
it { should_not have_rule('-A jump_with_rule -p tcp -m tcp --dport 83 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 84 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 85 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 84 -m comment --comment array_of_rules -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 85 -m comment --comment array_of_rules -j ACCEPT') }
it { should have_rule('-A INPUT -j array_of_rules') }
end
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
require_relative '../../../kitchen/data/spec_helper'
require 'serverspec'

set :backend, :exec

describe iptables do
it { should have_rule('-A INPUT -j simple_rule') }
it { should have_rule('-A simple_rule -p tcp -m tcp --dport 80 -j ACCEPT') }
it { should have_rule('-A INPUT -p tcp -m tcp --dport 81 -j ACCEPT') }
it { should have_rule('-A FORWARD -p tcp -m tcp --dport 82 -j ACCEPT') }
it { should have_rule('-A simple_rule -p tcp -m tcp --dport 80 -m comment --comment simple_rule -j ACCEPT') }
it { should have_rule('-A INPUT -p tcp -m tcp --dport 81 -m comment --comment rule_in_input_chain -j ACCEPT') }
it { should have_rule('-A FORWARD -p tcp -m tcp --dport 82 -m comment --comment rule_in_forward_chain -j ACCEPT') }
it { should have_rule('-A INPUT -m state --state NEW -j jump_with_rule') }
it { should have_rule('-A jump_with_rule -p tcp -m tcp --dport 83 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 84 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 85 -j ACCEPT') }
it { should have_rule('-A jump_with_rule -p tcp -m tcp --dport 83 -m comment --comment jump_with_rule -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 84 -m comment --comment array_of_rules -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 85 -m comment --comment array_of_rules -j ACCEPT') }
it { should have_rule('-A INPUT -j array_of_rules') }
it { should_not have_rule('*nat') }
it { should have_rule('*mangle') }
Expand All @@ -18,13 +20,13 @@

describe ip6tables do
it { should have_rule('-A INPUT -j simple_rule') }
it { should have_rule('-A simple_rule -p tcp -m tcp --dport 80 -j ACCEPT') }
it { should have_rule('-A INPUT -p tcp -m tcp --dport 81 -j ACCEPT') }
it { should have_rule('-A simple_rule -p tcp -m tcp --dport 80 -m comment --comment simple_rule -j ACCEPT') }
it { should have_rule('-A INPUT -p tcp -m tcp --dport 81 -m comment --comment rule_in_input_chain -j ACCEPT') }
it { should_not have_rule('-A FORWARD -p tcp -m tcp --dport 82 -j ACCEPT') }
it { should_not have_rule('-A INPUT -m state --state NEW -j jump_with_rule') }
it { should_not have_rule('-A jump_with_rule -p tcp -m tcp --dport 83 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 84 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 85 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 84 -m comment --comment array_of_rules -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 85 -m comment --comment array_of_rules -j ACCEPT') }
it { should have_rule('-A INPUT -j array_of_rules') }
it { should_not have_rule('*nat') }
it { should have_rule('*mangle') }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
require_relative '../../../kitchen/data/spec_helper'
require 'serverspec'

set :backend, :exec

describe iptables do
it { should have_rule('-A INPUT -j simple_rule') }
it { should have_rule('-A simple_rule -p tcp -m tcp --dport 80 -j ACCEPT') }
it { should have_rule('-A INPUT -p tcp -m tcp --dport 81 -j ACCEPT') }
it { should have_rule('-A FORWARD -p tcp -m tcp --dport 82 -j ACCEPT') }
it { should have_rule('-A simple_rule -p tcp -m tcp --dport 80 -m comment --comment simple_rule -j ACCEPT') }
it { should have_rule('-A INPUT -p tcp -m tcp --dport 81 -m comment --comment rule_in_input_chain -j ACCEPT') }
it { should have_rule('-A FORWARD -p tcp -m tcp --dport 82 -m comment --comment rule_in_forward_chain -j ACCEPT') }
it { should have_rule('-A INPUT -m state --state NEW -j jump_with_rule') }
it { should have_rule('-A jump_with_rule -p tcp -m tcp --dport 83 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 84 -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 85 -j ACCEPT') }
it { should have_rule('-A jump_with_rule -p tcp -m tcp --dport 83 -m comment --comment jump_with_rule -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 84 -m comment --comment array_of_rules -j ACCEPT') }
it { should have_rule('-A array_of_rules -p tcp -m tcp --dport 85 -m comment --comment array_of_rules -j ACCEPT') }
it { should have_rule('-A INPUT -j array_of_rules') }
it { should_not have_rule('*nat') }
it { should have_rule('*mangle') }
Expand Down