Skip to content

Commit

Permalink
Kitchen test fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Hughes <[email protected]>
  • Loading branch information
bmhughes committed Mar 9, 2021
1 parent e4e34fa commit 546dec4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/cookbooks/test/recipes/rule-line-number.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
end

# This should be the first rule now
iptables_rule 'Allow from loopback interface' do
iptables_rule 'Allow from ethernet interface' do
table :filter
chain :INPUT
ip_version 'ipv4'
Expand Down
3 changes: 3 additions & 0 deletions test/cookbooks/test/recipes/rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
action :enable
delayed_action :start

cookbook 'test'
sensitive false

subscribes :restart, 'template[/etc/sysconfig/iptables]', :delayed
subscribes :restart, 'template[/etc/iptables/rules.v4]', :delayed
end
Expand Down
24 changes: 24 additions & 0 deletions test/cookbooks/test/templates/default/iptables.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Chef Infra Client
# Do NOT modify this file by hand.
#
# I'm from the test cookbook
#

<% unless nil_or_empty?(@iptables) -%>
<% @iptables.each do |table, data| -%>
<% next if nil_or_empty?(data) -%>
*<%= table %>
<% unless nil_or_empty?(data[:chains]) -%>
<% data[:chains].each do |chain, value| -%>
:<%= chain %> <%= value %>
<% end -%>
<% end -%>
<% unless nil_or_empty?(data[:rules]) -%>
<% data[:rules].each do |rule| -%>
<%= rule %>
<% end -%>
<% end -%>
COMMIT

<% end -%>
<% end -%>
4 changes: 4 additions & 0 deletions test/integration/rules/rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
when 'debian', 'ubuntu'
describe file('/etc/iptables/rules.v4') do
it { should exist }
its(:content) { should match /# I'm from the test cookbook/ }
end
describe service('netfilter-persistent') do
it { should be_installed }
it { should be_running }
it { should be_enabled }
end
when 'redhat', 'fedora'
describe file('/etc/sysconfig/iptables') do
its(:content) { should match /# I'm from the test cookbook/ }
end
describe file('/etc/sysconfig/iptables-config') do
its(:content) { should match /IPTABLES_STATUS_VERBOSE="no"/ }
end
Expand Down

0 comments on commit 546dec4

Please sign in to comment.