forked from voxpupuli/puppet-selinux
-
-
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.
- Loading branch information
1 parent
424ae8f
commit 28bc41b
Showing
5 changed files
with
42 additions
and
76 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
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 |
---|---|---|
@@ -1,71 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'beaker-rspec' | ||
require 'beaker-puppet' | ||
require 'beaker/puppet_install_helper' | ||
require 'beaker/module_install_helper' | ||
require 'voxpupuli/acceptance/spec_helper_acceptance' | ||
|
||
def policy_package_for(hosts) | ||
case hosts[0]['platform'] | ||
when %r{^debian} | ||
'selinux-policy-default' | ||
else | ||
'selinux-policy-targeted' | ||
end | ||
end | ||
configure_beaker | ||
|
||
def have_selinux_ruby_library(hosts) | ||
hosts[0]['platform'] !~ %r{^debian} | ||
end | ||
|
||
run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no' | ||
|
||
RSpec.configure do |c| | ||
# Readable test descriptions | ||
c.formatter = :documentation | ||
|
||
# Configure all nodes in nodeset | ||
c.before :suite do | ||
install_module | ||
install_module_dependencies | ||
|
||
# Relabelling fails because systemd tries to connect the script's STDIN to | ||
# a serial port that doesn't exist (in Vagrant, at least). Work around like | ||
# in https://bugs.centos.org/view.php?id=13213 | ||
hosts.each do |host| | ||
next unless host['platform'] =~ %r{^el-7} | ||
|
||
on host, 'sed -i -e "s/console=tty0 console=ttyS0,115200/console=tty0/" /etc/default/grub' | ||
on host, 'cat /etc/default/grub' | ||
on host, 'grub2-mkconfig -o /boot/grub2/grub.cfg' | ||
end | ||
end | ||
|
||
c.filter_run_excluding requires_selinux_ruby_library: true unless have_selinux_ruby_library(hosts) | ||
end | ||
|
||
shared_examples 'a idempotent resource' do | ||
it 'applies with no errors' do | ||
apply_manifest(pp, catch_failures: true) | ||
end | ||
|
||
it 'applies a second time without changes' do | ||
apply_manifest(pp, catch_changes: true) | ||
end | ||
end | ||
|
||
def ensure_permissive_mode_on(hosts) | ||
hosts.each do |host| | ||
host.execute('getenforce') do |result| | ||
mode = result.stdout.strip | ||
if mode != 'Permissive' | ||
host.execute('sed -i "s/SELINUX=.*/SELINUX=permissive/" /etc/selinux/config') | ||
if mode == 'Disabled' | ||
host.reboot | ||
else | ||
host.execute('setenforce Permissive && test "$(getenforce)" = "Permissive"') | ||
end | ||
end | ||
end | ||
end | ||
end | ||
Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f } |
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,30 @@ | ||
# frozen_string_literal: true | ||
|
||
def policy_package_for(hosts) | ||
case hosts[0]['platform'] | ||
when %r{^debian} | ||
'selinux-policy-default' | ||
else | ||
'selinux-policy-targeted' | ||
end | ||
end | ||
|
||
def have_selinux_ruby_library(hosts) | ||
hosts[0]['platform'] !~ %r{^debian} | ||
end | ||
|
||
def ensure_permissive_mode_on(hosts) | ||
hosts.each do |host| | ||
host.execute('getenforce') do |result| | ||
mode = result.stdout.strip | ||
if mode != 'Permissive' | ||
host.execute('sed -i "s/SELINUX=.*/SELINUX=permissive/" /etc/selinux/config') | ||
if mode == 'Disabled' | ||
host.reboot | ||
else | ||
host.execute('setenforce Permissive && test "$(getenforce)" = "Permissive"') | ||
end | ||
end | ||
end | ||
end | ||
end |