forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #474 from jonnytpuppet/uid_negation_fix
Uid negation fix
- Loading branch information
Showing
2 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'firewall type', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do | ||
|
||
describe 'reset' do | ||
it 'deletes all rules' do | ||
shell('iptables --flush; iptables -t nat --flush; iptables -t mangle --flush') | ||
end | ||
it 'deletes all ip6tables rules' do | ||
shell('ip6tables --flush; ip6tables -t nat --flush; ip6tables -t mangle --flush') | ||
end | ||
end | ||
|
||
describe "uid tests" do | ||
context 'uid set to root' do | ||
it 'applies' do | ||
pp = <<-EOS | ||
class { '::firewall': } | ||
firewall { '801 - test': | ||
chain => 'OUTPUT', | ||
action => accept, | ||
uid => 'root', | ||
proto => 'all', | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
unless fact('selinux') == 'true' | ||
apply_manifest(pp, :catch_changes => true) | ||
end | ||
end | ||
|
||
it 'should contain the rule' do | ||
shell('iptables-save') do |r| | ||
expect(r.stdout).to match(/-A OUTPUT -m owner --uid-owner (0|root) -m comment --comment "801 - test" -j ACCEPT/) | ||
end | ||
end | ||
end | ||
|
||
context 'uid set to !root' do | ||
it 'applies' do | ||
pp = <<-EOS | ||
class { '::firewall': } | ||
firewall { '802 - test': | ||
chain => 'OUTPUT', | ||
action => accept, | ||
uid => '!root', | ||
proto => 'all', | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
unless fact('selinux') == 'true' | ||
apply_manifest(pp, :catch_changes => true) | ||
end | ||
end | ||
|
||
it 'should contain the rule' do | ||
shell('iptables-save') do |r| | ||
expect(r.stdout).to match(/-A OUTPUT -m owner ! --uid-owner (0|root) -m comment --comment "802 - test" -j ACCEPT/) | ||
end | ||
end | ||
end | ||
|
||
context 'uid set to 0' do | ||
it 'applies' do | ||
pp = <<-EOS | ||
class { '::firewall': } | ||
firewall { '803 - test': | ||
chain => 'OUTPUT', | ||
action => accept, | ||
uid => '0', | ||
proto => 'all', | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
unless fact('selinux') == 'true' | ||
apply_manifest(pp, :catch_changes => true) | ||
end | ||
end | ||
|
||
it 'should contain the rule' do | ||
shell('iptables-save') do |r| | ||
expect(r.stdout).to match(/-A OUTPUT -m owner --uid-owner (0|root) -m comment --comment "803 - test" -j ACCEPT/) | ||
end | ||
end | ||
end | ||
|
||
context 'uid set to !0' do | ||
it 'applies' do | ||
pp = <<-EOS | ||
class { '::firewall': } | ||
firewall { '804 - test': | ||
chain => 'OUTPUT', | ||
action => accept, | ||
uid => '!0', | ||
proto => 'all', | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
unless fact('selinux') == 'true' | ||
apply_manifest(pp, :catch_changes => true) | ||
end | ||
end | ||
|
||
it 'should contain the rule' do | ||
shell('iptables-save') do |r| | ||
expect(r.stdout).to match(/-A OUTPUT -m owner ! --uid-owner (0|root) -m comment --comment "804 - test" -j ACCEPT/) | ||
end | ||
end | ||
end | ||
|
||
end | ||
|
||
end |