simp-beaker-helpers 1.18.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.fixtures.yml +8 -0
  3. data/.gitignore +8 -0
  4. data/.gitlab-ci.yml +163 -0
  5. data/.rspec +4 -0
  6. data/.rubocop.yml +546 -0
  7. data/.travis.yml +36 -0
  8. data/CHANGELOG.md +231 -0
  9. data/Gemfile +51 -0
  10. data/LICENSE +27 -0
  11. data/README.md +543 -0
  12. data/Rakefile +151 -0
  13. data/files/pki/clean.sh +1 -0
  14. data/files/pki/make.sh +101 -0
  15. data/files/pki/template_ca.cnf +259 -0
  16. data/files/pki/template_host.cnf +263 -0
  17. data/files/puppet-agent-versions.yaml +46 -0
  18. data/lib/simp/beaker_helpers.rb +1231 -0
  19. data/lib/simp/beaker_helpers/constants.rb +25 -0
  20. data/lib/simp/beaker_helpers/inspec.rb +328 -0
  21. data/lib/simp/beaker_helpers/snapshot.rb +156 -0
  22. data/lib/simp/beaker_helpers/ssg.rb +383 -0
  23. data/lib/simp/beaker_helpers/version.rb +5 -0
  24. data/lib/simp/beaker_helpers/windows.rb +16 -0
  25. data/lib/simp/rake/beaker.rb +269 -0
  26. data/simp-beaker-helpers.gemspec +38 -0
  27. data/spec/acceptance/nodesets/default.yml +32 -0
  28. data/spec/acceptance/suites/default/check_puppet_version_spec.rb +23 -0
  29. data/spec/acceptance/suites/default/enable_fips_spec.rb +23 -0
  30. data/spec/acceptance/suites/default/fixture_modules_spec.rb +22 -0
  31. data/spec/acceptance/suites/default/install_simp_deps_repo_spec.rb +43 -0
  32. data/spec/acceptance/suites/default/nodesets +1 -0
  33. data/spec/acceptance/suites/default/pki_tests_spec.rb +55 -0
  34. data/spec/acceptance/suites/default/set_hieradata_on_spec.rb +33 -0
  35. data/spec/acceptance/suites/default/write_hieradata_to_spec.rb +33 -0
  36. data/spec/acceptance/suites/fips_from_fixtures/00_default_spec.rb +63 -0
  37. data/spec/acceptance/suites/fips_from_fixtures/metadata.yml +2 -0
  38. data/spec/acceptance/suites/fips_from_fixtures/nodesets +1 -0
  39. data/spec/acceptance/suites/offline/00_default_spec.rb +165 -0
  40. data/spec/acceptance/suites/offline/README +2 -0
  41. data/spec/acceptance/suites/offline/nodesets/default.yml +26 -0
  42. data/spec/acceptance/suites/puppet_collections/00_default_spec.rb +25 -0
  43. data/spec/acceptance/suites/puppet_collections/metadata.yml +2 -0
  44. data/spec/acceptance/suites/puppet_collections/nodesets/default.yml +30 -0
  45. data/spec/acceptance/suites/snapshot/00_snapshot_test_spec.rb +82 -0
  46. data/spec/acceptance/suites/snapshot/10_general_usage_spec.rb +56 -0
  47. data/spec/acceptance/suites/snapshot/nodesets +1 -0
  48. data/spec/acceptance/suites/windows/00_default_spec.rb +119 -0
  49. data/spec/acceptance/suites/windows/metadata.yml +2 -0
  50. data/spec/acceptance/suites/windows/nodesets/default.yml +33 -0
  51. data/spec/acceptance/suites/windows/nodesets/win2016.yml +35 -0
  52. data/spec/acceptance/suites/windows/nodesets/win2019.yml +34 -0
  53. data/spec/lib/simp/beaker_helpers_spec.rb +216 -0
  54. data/spec/spec_helper.rb +100 -0
  55. data/spec/spec_helper_acceptance.rb +25 -0
  56. metadata +243 -0
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
3
+ require 'simp/beaker_helpers/version'
4
+ require 'date'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'simp-beaker-helpers'
8
+ s.date = Date.today.to_s
9
+ s.summary = 'beaker helper methods for SIMP'
10
+ s.description = <<-EOF
11
+ Beaker helper methods to help scaffold SIMP acceptance tests
12
+ EOF
13
+ s.version = Simp::BeakerHelpers::VERSION
14
+ s.license = 'Apache-2.0'
15
+ s.authors = ['Chris Tessmer','Trevor Vaughan']
16
+ s.email = 'simp@simp-project.org'
17
+ s.homepage = 'https://github.com/simp/rubygem-simp-beaker-helpers'
18
+ s.metadata = {
19
+ 'issue_tracker' => 'https://simp-project.atlassian.net'
20
+ }
21
+ s.add_runtime_dependency 'beaker' , ['>= 4.17.0', '< 5.0.0']
22
+ s.add_runtime_dependency 'beaker-rspec' , '~> 6.2'
23
+ s.add_runtime_dependency 'beaker-puppet' , ['>= 1.18.14', '< 2.0.0']
24
+ s.add_runtime_dependency 'beaker-docker' , '~> 0.3'
25
+ s.add_runtime_dependency 'beaker-vagrant' , ['>= 0.6.4', '< 2.0.0']
26
+ s.add_runtime_dependency 'beaker-puppet_install_helper', '~> 0.9'
27
+ s.add_runtime_dependency 'highline' , '~> 2.0'
28
+ s.add_runtime_dependency 'nokogiri' , '~> 1.8'
29
+
30
+ # Because net-telnet dropped support for Ruby < 2.3.0
31
+ # TODO: Update this when we no longer support Ruby 2.1.9 (should be October 2018)
32
+ s.add_runtime_dependency 'net-telnet', '~> 0.1.1'
33
+
34
+ ### s.files = Dir['Rakefile', '{bin,lib,spec}/**/*', 'README*', 'LICENSE*'] & `git ls-files -z .`.split("\0")
35
+ s.files = `git ls-files`.split("\n")
36
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
37
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
38
+ end
@@ -0,0 +1,32 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
8
+ HOSTS:
9
+ server-el7:
10
+ roles:
11
+ - server
12
+ - default
13
+ - master
14
+ - el7
15
+ platform: el-7-x86_64
16
+ box: centos/7
17
+ hypervisor: <%= hypervisor %>
18
+
19
+ server-el6:
20
+ roles:
21
+ - el6
22
+ platform: el-6-x86_64
23
+ box: centos/6
24
+ hypervisor: <%= hypervisor %>
25
+
26
+ CONFIG:
27
+ log_level: verbose
28
+ type: aio
29
+ vagrant_memsize: 256
30
+ <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
31
+ puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
32
+ <% end -%>
@@ -0,0 +1,23 @@
1
+ require 'spec_helper_acceptance'
2
+
3
+ hosts.each do |host|
4
+ describe 'make sure puppet version is valid' do
5
+ context "on #{host}" do
6
+ puppet_collection = host.options[:puppet_collection]
7
+
8
+ client_puppet_version = on(host, 'puppet --version').output.strip
9
+
10
+ if puppet_collection =~ /puppet(\d+)/
11
+ puppet_collection_version = $1
12
+
13
+ it "should be running puppet version #{puppet_collection_version}" do
14
+ expect(client_puppet_version.split('.').first).to eq(puppet_collection_version)
15
+ end
16
+ else
17
+ it 'should not be running puppet 5' do
18
+ expect(client_puppet_version.split('.').first).to eq '5'
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper_acceptance'
2
+
3
+ hosts.each do |host|
4
+ describe 'FIPS enabled from Forge' do
5
+ context "on #{host}" do
6
+ if ENV['BEAKER_fips'] == 'yes'
7
+ it 'creates an alternate apply directory' do
8
+ on(host, 'test -d /root/.beaker_fips/modules')
9
+ end
10
+
11
+ it 'has fips enabled' do
12
+ stdout = on(host, 'cat /proc/sys/crypto/fips_enabled').stdout.strip
13
+ expect(stdout).to eq('1')
14
+ end
15
+ else
16
+ it 'has fips disabled' do
17
+ stdout = on(host, 'cat /proc/sys/crypto/fips_enabled').stdout.strip
18
+ expect(stdout).to eq('0')
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper_acceptance'
2
+
3
+ context 'after copy_fixture_modules_to( hosts )' do
4
+ before(:all) do
5
+ # This should automatically run pluginsync_on hosts
6
+ copy_fixture_modules_to( hosts )
7
+ end
8
+
9
+ describe "fact_on(master,'root_home')" do
10
+ it 'should not return value of `root_home`' do
11
+ puts fact = fact_on(master, 'root_home')
12
+ expect( fact ).to eq ''
13
+ end
14
+ end
15
+
16
+ describe "pfact_on(master,'root_home')" do
17
+ it 'should return value of `root_home`' do
18
+ puts fact = pfact_on(master, 'root_home')
19
+ expect( fact ).to eq '/root'
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper_acceptance'
2
+
3
+ hosts.each do |host|
4
+ describe '#write_hieradata_to' do
5
+
6
+ it 'should install yum utils' do
7
+ host.install_package('yum-utils')
8
+ end
9
+
10
+ context 'defailt settings' do
11
+ before(:all) { install_simp_repos(host) }
12
+
13
+ it 'creates the repo' do
14
+ on host, 'test -f /etc/yum.repos.d/simp.repo'
15
+ on host, 'test -f /etc/yum.repos.d/simp_deps.repo'
16
+ end
17
+
18
+ it 'enables the correct repos' do
19
+ simp6info = on(host, '/usr/bin/yum repolist -v simp | grep ^Repo-status').stdout.strip
20
+ expect(simp6info).to match(/.*Repo-status.*enabled.*/)
21
+ simp6depsinfo = on(host, 'yum repolist -v simp_deps| grep ^Repo-status').stdout.strip
22
+ expect(simp6depsinfo).to match(/.*Repo-status.*enabled.*/)
23
+ end
24
+ end
25
+
26
+ context 'when passed a disabled list ' do
27
+ before(:all) { install_simp_repos(host, ['simp'] ) }
28
+
29
+ it 'creates the repo' do
30
+ on host, 'test -f /etc/yum.repos.d/simp.repo'
31
+ on host, 'test -f /etc/yum.repos.d/simp_deps.repo'
32
+ end
33
+
34
+ it 'enables the correct repos' do
35
+ simp6info = on(host, 'yum repolist -v simp | grep ^Repo-status').stdout.strip
36
+ expect(simp6info).to match(/.*Repo-status.*disabled.*/)
37
+ simp6depsinfo = on(host, 'yum repolist -v simp_deps| grep ^Repo-status').stdout.strip
38
+ expect(simp6depsinfo).to match(/.*Repo-status.*enabled.*/)
39
+ end
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1 @@
1
+ spec/acceptance/suites/default/../../nodesets
@@ -0,0 +1,55 @@
1
+ require 'spec_helper_acceptance'
2
+ require 'tmpdir'
3
+
4
+
5
+ context 'PKI operations' do
6
+
7
+ context 'after run_fake_pki_ca_on(master,hosts)' do
8
+ before(:all) do
9
+ copy_fixture_modules_to( hosts )
10
+ end
11
+
12
+ shared_examples_for 'a correctly copied keydist/ tree' do |test_dir|
13
+ it 'correctly copies keydist/ tree' do
14
+ on(master, "ls -d #{test_dir}" +
15
+ " #{test_dir}/cacerts" +
16
+ " #{test_dir}/cacerts/cacert_*.pem"
17
+ )
18
+
19
+ hosts.each do |host|
20
+ name = host.node_name
21
+ on(master, "ls -d #{test_dir}/#{name}/cacerts" +
22
+ " #{test_dir}/#{name}/#{name}.pem" +
23
+ " #{test_dir}/#{name}/#{name}.pub" +
24
+ " #{test_dir}/cacerts/cacert_*.pem"
25
+ )
26
+ end
27
+ end
28
+ end
29
+
30
+ describe 'a Fake CA under /root' do
31
+ tmp_keydist_dir = Dir.mktmpdir 'simp-beaker-helpers__pki-tests'
32
+ run_fake_pki_ca_on( master, hosts, tmp_keydist_dir )
33
+
34
+ it 'should create /root/pki' do
35
+ on(master, 'test -d /root/pki')
36
+ end
37
+
38
+ it_behaves_like 'a correctly copied keydist/ tree', '/root/pki/keydist'
39
+
40
+ end
41
+
42
+ describe 'after copy_keydist_to' do
43
+ test_dir = '/etc/puppetlabs/code/environments/production/modules/pki/files/keydist'
44
+ copy_keydist_to(master)
45
+ it_behaves_like 'a correctly copied keydist/ tree', test_dir
46
+ end
47
+
48
+ describe 'after copy_keydist_to(master,"/tmp/foo")' do
49
+ test_dir = '/tmp/foo'
50
+ copy_keydist_to(master, test_dir)
51
+ it_behaves_like 'a correctly copied keydist/ tree', test_dir
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper_acceptance'
2
+
3
+ hosts.each do |host|
4
+ describe '#set_hieradata_on' do
5
+ context 'when passed a YAML string' do
6
+ before(:all) { set_hieradata_on(host, "---\n") }
7
+ after(:all) { on(host, "rm -rf #{hiera_datadir(host)}") }
8
+
9
+ it 'creates the datadir' do
10
+ on host, "test -d #{hiera_datadir(host)}"
11
+ end
12
+
13
+ it 'writes the correct contents to the correct file' do
14
+ stdout = on(host, "cat #{hiera_datadir(host)}/common.yaml").stdout
15
+ expect(stdout).to eq("---\n")
16
+ end
17
+ end
18
+
19
+ context 'when passed a hash' do
20
+ before(:all) { set_hieradata_on(host, { 'foo' => 'bar' }) }
21
+ after(:all) { on(host, "rm -rf #{hiera_datadir(host)}") }
22
+
23
+ it 'creates the datadir' do
24
+ on host, "test -d #{hiera_datadir(host)}"
25
+ end
26
+
27
+ it 'writes the correct contents to the correct file' do
28
+ stdout = on(host, "cat #{hiera_datadir(host)}/common.yaml").stdout
29
+ expect(stdout).to eq("---\nfoo: bar\n")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper_acceptance'
2
+
3
+ hosts.each do |host|
4
+ describe '#write_hieradata_to' do
5
+ context 'when passed a YAML string' do
6
+ before(:all) { set_hieradata_on(host, "---\n") }
7
+ after(:all) { on(host, "rm -rf #{hiera_datadir(host)}") }
8
+
9
+ it 'creates the datadir' do
10
+ on host, "test -d #{hiera_datadir(host)}"
11
+ end
12
+
13
+ it 'writes the correct contents to the correct file' do
14
+ stdout = on(host, "cat #{hiera_datadir(host)}/common.yaml").stdout
15
+ expect(stdout).to eq("---\n")
16
+ end
17
+ end
18
+
19
+ context 'when passed a hash' do
20
+ before(:all) { set_hieradata_on(host, { 'foo' => 'bar' }) }
21
+ after(:all) { on(host, "rm -rf #{hiera_datadir(host)}") }
22
+
23
+ it 'creates the datadir' do
24
+ on host, "test -d #{hiera_datadir(host)}"
25
+ end
26
+
27
+ it 'writes the correct contents to the correct file' do
28
+ stdout = on(host, "cat #{hiera_datadir(host)}/common.yaml").stdout
29
+ expect(stdout).to eq("---\nfoo: bar\n")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,63 @@
1
+ class ScrubFixtures
2
+ require 'simp/beaker_helpers'
3
+ include Simp::BeakerHelpers
4
+
5
+ def initialize
6
+ FileUtils.rm_rf(File.join(fixtures_path, 'modules'))
7
+ end
8
+ end
9
+
10
+ require 'yaml'
11
+ require 'tempfile'
12
+
13
+ alt_fixtures = File.absolute_path('.fips_fixtures.yml')
14
+
15
+ new_fixtures = {
16
+ 'fixtures' => {
17
+ 'repositories' => {}
18
+ }
19
+ }
20
+
21
+ new_fixtures['fixtures']['repositories']['fips'] = 'https://github.com/simp/pupmod-simp-fips'
22
+ new_fixtures['fixtures']['repositories']['augeasproviders_core'] = 'https://github.com/simp/augeasproviders_core'
23
+ new_fixtures['fixtures']['repositories']['augeasproviders_grub'] = 'https://github.com/simp/augeasproviders_grub'
24
+ new_fixtures['fixtures']['repositories']['simplib'] = 'https://github.com/simp/pupmod-simp-simplib'
25
+ new_fixtures['fixtures']['repositories']['stdlib'] = 'https://github.com/simp/puppetlabs-stdlib'
26
+
27
+ File.open(alt_fixtures, 'w'){ |fh| fh.puts(new_fixtures.to_yaml) }
28
+
29
+ ScrubFixtures.new
30
+
31
+ ENV['BEAKER_fips'] = 'yes'
32
+ ENV['FIXTURES_YML'] = alt_fixtures
33
+
34
+ Bundler.with_clean_env{
35
+ ENV['FIXTURES_YML'] = alt_fixtures
36
+
37
+ %x{bundle exec rake spec_prep}
38
+ }
39
+
40
+ require 'spec_helper_acceptance'
41
+
42
+ describe 'FIPS pre-installed' do
43
+ after(:all) do
44
+ if alt_fixtures && File.exist?(alt_fixtures)
45
+ FileUtils.rm(alt_fixtures)
46
+
47
+ ScrubFixtures.new
48
+ end
49
+ end
50
+
51
+ hosts.each do |host|
52
+ context "on #{host}" do
53
+ it 'does not create an alternate apply directory' do
54
+ on(host, 'test ! -d /root/.beaker_fips/modules')
55
+ end
56
+
57
+ it 'has fips enabled' do
58
+ stdout = on(host, 'cat /proc/sys/crypto/fips_enabled').stdout.strip
59
+ expect(stdout).to eq('1')
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ 'default_run': true
@@ -0,0 +1 @@
1
+ spec/acceptance/suites/fips_from_fixtures/../../nodesets
@@ -0,0 +1,165 @@
1
+ require 'spec_helper_acceptance'
2
+
3
+ describe 'Offline mode' do
4
+ hosts.each do |host|
5
+ context "on #{host}" do
6
+ let(:vagrant_version) { '2.2.5' }
7
+ let(:vagrant_rpm) { "https://releases.hashicorp.com/vagrant/#{vagrant_version}/vagrant_#{vagrant_version}_x86_64.rpm" }
8
+ let(:virtualbox_repo) { 'http://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo' }
9
+ let(:build_user) { 'build_user' }
10
+ let(:build_user_cmd) { "runuser #{build_user} -l -c" }
11
+
12
+ # Not sure if this is a QEMU thing with the image or something else
13
+ it 'works around a CentOS curl bug with libvirt' do
14
+ on(host, %(touch /etc/sysconfig/64bit_strstr_via_64bit_strstr_sse2_unaligned))
15
+ end
16
+
17
+ it 'adds the build user' do
18
+ on(host, %(useradd -b /home -G wheel -m -c "Build User" -s /bin/bash -U #{build_user}))
19
+
20
+ # Allow the build user to perform privileged operations
21
+ on(host, %(echo 'Defaults:build_user !requiretty' >> /etc/sudoers))
22
+ end
23
+
24
+ it 'installs required packages' do
25
+ host.install_package('epel-release')
26
+
27
+ required_packages = [
28
+ 'augeas-devel',
29
+ 'autoconf',
30
+ 'automake',
31
+ 'bison',
32
+ 'createrepo',
33
+ 'curl',
34
+ 'dkms',
35
+ 'initscripts',
36
+ 'gcc',
37
+ 'gcc-c++',
38
+ 'genisoimage',
39
+ 'git',
40
+ 'glibc-devel',
41
+ 'glibc-headers',
42
+ 'gnupg2',
43
+ 'kernel-devel',
44
+ 'libffi-devel',
45
+ 'libicu-devel',
46
+ 'libtool',
47
+ 'libvirt',
48
+ 'libvirt-client',
49
+ 'libvirt-devel',
50
+ 'libxml2',
51
+ 'libxml2-devel',
52
+ 'libxslt',
53
+ 'libxslt-devel',
54
+ 'libyaml-devel',
55
+ 'make',
56
+ 'ntpdate',
57
+ 'openssl',
58
+ 'openssl-devel',
59
+ 'qemu',
60
+ 'readline-devel',
61
+ 'rpm-build',
62
+ 'rpm-sign',
63
+ 'rpmdevtools',
64
+ 'ruby-devel',
65
+ 'rubygems',
66
+ 'seabios',
67
+ 'sqlite-devel',
68
+ 'util-linux',
69
+ 'which'
70
+ ]
71
+
72
+ on(host, %(yum -y install #{required_packages.join(' ')}))
73
+ on(host, %(yum -y update))
74
+ end
75
+
76
+ it 'removes limits from the system' do
77
+ # Remove system limits
78
+ on(host, %(rm -rf /etc/security/limits.d/*.conf))
79
+ end
80
+
81
+ it 'installs the latest VirtualBox' do
82
+ on(host, %(curl "#{virtualbox_repo}" -o /etc/yum.repos.d/virtualbox.repo))
83
+ on(host, 'yum -y install $(yum -y list | grep VirtualBox | sort | tail -1 | cut -f 1 -d " ")')
84
+ end
85
+
86
+ it 'installs the VirtualBox extension pack' do
87
+ on(host, 'VERSION=$(VBoxManage --version | tail -1 | cut -f 1 -d "r") && curl -Lo ${TMPDIR}/Oracle_VM_VirtualBox_Extension_Pack-${VERSION}.vbox-extpack http://download.virtualbox.org/virtualbox/${VERSION}/Oracle_VM_VirtualBox_Extension_Pack-${VERSION}.vbox-extpack && yes | VBoxManage extpack install ${TMPDIR}/Oracle_VM_VirtualBox_Extension_Pack-${VERSION}.vbox-extpack && rm -rf ${TMPDIR}/Oracle_VM_VirtualBox_Extension_Pack-${VERSION}.vbox-extpack')
88
+ end
89
+
90
+ it 'adds the build user to the vboxusers group' do
91
+ on(host, %(usermod -a -G vboxusers #{build_user}))
92
+ end
93
+
94
+ it 'reboots the system to finalize VirtualBox' do
95
+ host.reboot
96
+ end
97
+
98
+ it 'installs RPM for the build user' do
99
+ # Install RVM
100
+ on(host, %(#{build_user_cmd} "for i in {1..5}; do { gpg2 --keyserver hkp://pgp.mit.edu --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 || gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 || gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3; } && { gpg2 --keyserver hkp://pgp.mit.edu --recv-keys 7D2BAF1CF37B13E2069D6956105BD0E739499BDB || gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 7D2BAF1CF37B13E2069D6956105BD0E739499BDB; } && break || sleep 1; done"))
101
+ on(host, %(#{build_user_cmd} "gpg2 --refresh-keys"))
102
+ on(host, %(#{build_user_cmd} "curl -sSL https://raw.githubusercontent.com/rvm/rvm/stable/binscripts/rvm-installer -o rvm-installer && curl -sSL https://raw.githubusercontent.com/rvm/rvm/stable/binscripts/rvm-installer.asc -o rvm-installer.asc && gpg2 --verify rvm-installer.asc rvm-installer && bash rvm-installer"))
103
+ on(host, %(#{build_user_cmd} "rvm install 2.4.4 --disable-binary"))
104
+ on(host, %(#{build_user_cmd} "rvm use --default 2.4.4"))
105
+ on(host, %(#{build_user_cmd} "rvm all do gem install bundler -v '~> 1.16' --no-document"))
106
+ end
107
+
108
+ it 'installs vagrant' do
109
+ on(host, %(yum -y install #{vagrant_rpm}))
110
+ end
111
+
112
+ it 'preps for testing by downloading boxes for tests' do
113
+ on(host, %(#{build_user_cmd} "vagrant box add --provider virtualbox centos/6"))
114
+ on(host, %(#{build_user_cmd} "vagrant box add --provider virtualbox centos/7"))
115
+ end
116
+
117
+ it 'runs a simple nested virt test' do
118
+ build_user_homedir = on(host, "readlink -f ~#{build_user}").output.strip
119
+ vagrant_testdir = "#{build_user_homedir}/vagrant_test"
120
+
121
+ vagrant_test_file = <<-EOM
122
+ Vagrant.configure("2") do |c|
123
+ c.vm.define 'test' do |v|
124
+ v.vm.hostname = 'centos7.test.net'
125
+ v.vm.box = 'centos/7'
126
+ v.vm.box_check_update = 'false'
127
+ end
128
+ end
129
+ EOM
130
+
131
+ host.mkdir_p(vagrant_testdir)
132
+
133
+ create_remote_file(host, "#{vagrant_testdir}/Vagrantfile", vagrant_test_file)
134
+
135
+ on(host, %(chown -R #{build_user} #{vagrant_testdir}))
136
+
137
+ on(host, %(#{build_user_cmd} "cd #{vagrant_testdir} && vagrant up"))
138
+ on(host, %(#{build_user_cmd} "cd #{vagrant_testdir} && vagrant destroy -f"))
139
+ end
140
+
141
+ # We're testing a real module since that has the widest set of
142
+ # repercussions for reaching out to the internet
143
+ it 'downloads a module to test' do
144
+ on(host, %(#{build_user_cmd} "git clone https://github.com/simp/pupmod-simp-at"))
145
+ end
146
+
147
+ it 'preps the module for building' do
148
+ on(host, %(#{build_user_cmd} "cd pupmod-simp-at; bundle update"))
149
+ end
150
+
151
+ it 'runs a network-connected test' do
152
+ on(host, %(#{build_user_cmd} "cd pupmod-simp-at; rake beaker:suites"))
153
+ end
154
+
155
+ it 'disables all internet network traffic via iptables' do
156
+ on(host, %(iptables -I OUTPUT -d `ip route | awk '/default/ {print $3}'`/16 -j ACCEPT))
157
+ on(host, 'iptables -A OUTPUT -j DROP')
158
+ end
159
+
160
+ xit 'runs a network-disconnected test' do
161
+ on(host, %(#{build_user_cmd} "cd pupmod-simp-at; rake beaker:suites"))
162
+ end
163
+ end
164
+ end
165
+ end