Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix firewallchain acceptance tests #1205

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
46 changes: 32 additions & 14 deletions spec/acceptance/firewallchain_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,40 @@
end
end

context 'with NAT chain' do
pp3 = <<-PUPPETCODE
firewallchain { 'MY_CHAIN:nat:IPv6':
context 'when NAT chain present' do
pp5 = <<-PUPPETCODE
firewallchain { 'MY_NAT_CHAIN:nat:IPv6':
ensure => present,
}
PUPPETCODE
it 'applies cleanly' do
# Run it twice and test for idempotency
idempotent_apply(pp3)
idempotent_apply(pp5)
end
end

context 'when NAT chain absent' do
pp6 = <<-PUPPETCODE
firewallchain { 'MY_NAT_CHAIN:nat:IPv6':
ensure => absent,
}
PUPPETCODE
it 'applies cleanly' do
# Run it twice and test for idempotency
idempotent_apply(pp6)
end

it 'fails to find the chain' do
run_shell('ip6tables-save') do |r|
expect(r.stdout).not_to match(%r{MY_NAT_CHAIN})
end
end
end
end

# XXX purge => false is not yet implemented
# context 'when adding a firewall rule to a chain:' do
# pp5 = <<-PUPPETCODE
# pp7 = <<-PUPPETCODE
# firewallchain { 'MY_CHAIN:filter:IPv4':
# ensure => present,
# }
Expand All @@ -111,13 +129,13 @@
# PUPPETCODE
# it 'applies cleanly' do
# # Run it twice and test for idempotency
# apply_manifest(pp5, :catch_failures => true)
# apply_manifest(pp5, :catch_changes => do_catch_changes)
# apply_manifest(pp7, :catch_failures => true)
# apply_manifest(pp7, :catch_changes => do_catch_changes)
# end
# end

# context 'when not purge firewallchain chains:' do
# pp6 = <<-PUPPETCODE
# pp8 = <<-PUPPETCODE
# firewallchain { 'MY_CHAIN:filter:IPv4':
# ensure => present,
# purge => false,
Expand All @@ -129,14 +147,14 @@
# PUPPETCODE
# it 'does not purge the rule' do
# # Run it twice and test for idempotency
# apply_manifest(pp6, :catch_failures => true) do |r|
# apply_manifest(pp8, :catch_failures => true) do |r|
# expect(r.stdout).to_not match(/removed/)
# expect(r.stderr).to eq('')
# end
# apply_manifest(pp6, :catch_changes => do_catch_changes)
# apply_manifest(pp8, :catch_changes => do_catch_changes)
# end

# pp7 = <<-PUPPETCODE
# pp9 = <<-PUPPETCODE
# firewall { '100 my rule':
# chain => 'MY_CHAIN',
# action => 'accept',
Expand All @@ -146,7 +164,7 @@
# PUPPETCODE
# it 'still has the rule' do
# # Run it twice and test for idempotency
# apply_manifest(pp7, :catch_changes => do_catch_changes)
# apply_manifest(pp9, :catch_changes => do_catch_changes)
# end
# end

Expand All @@ -156,14 +174,14 @@
end

context 'when DROP' do
pp8 = <<-PUPPETCODE
pp10 = <<-PUPPETCODE
firewallchain { 'FORWARD:filter:IPv4':
policy => 'drop',
}
PUPPETCODE
it 'applies cleanly' do
# Run it twice and test for idempotency
idempotent_apply(pp8)
idempotent_apply(pp10)
end

it 'finds the chain' do
Expand Down
Loading