Skip to content

Commit

Permalink
Fix the acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oranenj committed Feb 4, 2017
1 parent 292981a commit 147b778
Showing 1 changed file with 41 additions and 10 deletions.
51 changes: 41 additions & 10 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,44 @@ class { 'selinux': mode => 'enforcing' }
protocol => 'tcp',
}
# with puppet4 I would use a HERE DOC to make this pretty,
# but with puppet3 it's not possible.
# just something simple I found via Google:
file {'/tmp/selinux_simple_policy.te':
ensure => 'file',
content => @("EOF")
module puppet_selinux_simple_policy 1.0;
require {
type httpd_log_t;
type postfix_postdrop_t;
class dir getattr;
class file { read getattr };
}
allow postfix_postdrop_t httpd_log_t:file getattr;
| EOF
}
file {'/tmp/selinux_test_policy.te':
ensure => 'file',
content => @("EOF")
policy_module(puppet_selinux_test_policy, 1.0.0)
gen_tunable(puppet_selinux_test_policy_bool, false)
type puppet_selinux_test_policy_t;
type puppet_selinux_test_policy_exec_t;
init_daemon_domain(puppet_selinux_test_policy_t, puppet_selinux_test_policy_exec_t)
type puppet_selinux_test_policy_port_t;
corenet_port(puppet_selinux_test_policy_port_t)
| EOF
}
selinux::module { 'puppet_selinux_simple_policy':
source_te => 'file:///tmp/selinux_simple_policy.te',
builder => 'simple',
require => File['/tmp/selinux_simple_policy.te']
}
selinux::module { 'puppet_selinux_test_policy':
content => "policy_module(puppet_selinux_test_policy, 1.0.0)\ngen_tunable(puppet_selinux_test_policy_bool, false)\ntype puppet_selinux_test_policy_t;\ntype puppet_selinux_test_policy_exec_t;\ninit_daemon_domain(puppet_selinux_test_policy_t, puppet_selinux_test_policy_exec_t)\ntype puppet_selinux_test_policy_port_t;\ncorenet_port(puppet_selinux_test_policy_port_t)\n",
prefix => '',
syncversion => undef,
source_te => 'file:///tmp/selinux_test_policy.te',
builder => 'refpolicy',
require => File['/tmp/selinux_test_policy.te']
}
Class['selinux'] ->
Expand Down Expand Up @@ -76,14 +108,13 @@ class { 'selinux': mode => 'enforcing' }
its(:stdout) { is_expected.to match(%r{^Enforcing$}) }
end

context 'the test module source should exist and the module should be loaded' do
describe file('/usr/share/selinux/puppet_selinux_test_policy.te') do
it { is_expected.to be_file }
end

context 'the compiled modules should be loaded' do
describe command('semodule -l | grep puppet_selinux_test_policy') do
its(:stdout) { is_expected.to match(%r{puppet_selinux_test_policy}) }
end
describe command('semodule -l | grep puppet_selinux_simple_policy') do
its(:stdout) { is_expected.to match(%r{puppet_selinux_simple_policy}) }
end
end

context 'the test file should have the specified file context' do
Expand Down

0 comments on commit 147b778

Please sign in to comment.