diff options
Diffstat (limited to 'spec/acceptance')
-rw-r--r-- | spec/acceptance/hosts.rb | 39 | ||||
-rw-r--r-- | spec/acceptance/puppet.rb | 19 | ||||
-rw-r--r-- | spec/acceptance/services.rb | 33 |
3 files changed, 42 insertions, 49 deletions
diff --git a/spec/acceptance/hosts.rb b/spec/acceptance/hosts.rb index a7f526a..dabec5a 100644 --- a/spec/acceptance/hosts.rb +++ b/spec/acceptance/hosts.rb @@ -1,28 +1,26 @@ -test_name "Augeas hosts file" do +test_name 'Augeas hosts file' do + tag 'risk:medium', + 'audit:medium', + 'audit:acceptance', + 'audit:refactor' # move to puppet types test directory, this is not testing puppet apply + # reduce to a single manifest and apply -tag 'risk:medium', - 'audit:medium', - 'audit:acceptance', - 'audit:refactor' # move to puppet types test directory, this is not testing puppet apply - # reduce to a single manifest and apply + skip_test 'requires augeas which is included in AIO' if @options[:type] != 'aio' -skip_test 'requires augeas which is included in AIO' if @options[:type] != 'aio' - - confine :except, :platform => [ + confine :except, platform: [ 'windows', - 'cisco_ios', # PUP-7380 + 'cisco_ios', # PUP-7380 ] - confine :to, {}, hosts.select { |host| ! host[:roles].include?('master') } + confine :to, {}, hosts.reject { |host| host[:roles].include?('master') } - step "Backup the hosts file" do + step 'Backup the hosts file' do on hosts, 'cp /etc/hosts /tmp/hosts.bak' end # We have a begin/ensure block here to clean up the hosts file in case # of test failure. begin - - step "Create an entry in the hosts file" do + step 'Create an entry in the hosts file' do manifest = <<EOF augeas { 'add_hosts_entry': context => '/files/etc/hosts', @@ -36,11 +34,11 @@ augeas { 'add_hosts_entry': ] } EOF - on hosts, puppet_apply('--verbose'), :stdin => manifest + on hosts, puppet_apply('--verbose'), stdin: manifest on hosts, "fgrep '192.168.0.1\tpigiron.example.com pigiron piggy' /etc/hosts" end - step "Modify an entry in the hosts file" do + step 'Modify an entry in the hosts file' do manifest = <<EOF augeas { 'mod_hosts_entry': context => '/files/etc/hosts', @@ -52,11 +50,11 @@ augeas { 'mod_hosts_entry': } EOF - on hosts, puppet_apply('--verbose'), :stdin => manifest + on hosts, puppet_apply('--verbose'), stdin: manifest on hosts, "fgrep '192.168.0.1\tpigiron.example.com pigiron piggy oinker' /etc/hosts" end - step "Remove an entry from the hosts file" do + step 'Remove an entry from the hosts file' do manifest = <<EOF augeas { 'del_hosts_entry': context => '/files/etc/hosts', @@ -68,10 +66,9 @@ augeas { 'del_hosts_entry': } EOF - on hosts, puppet_apply('--verbose'), :stdin => manifest - on hosts, "fgrep 'pigiron.example.com' /etc/hosts", :acceptable_exit_codes => [1] + on hosts, puppet_apply('--verbose'), stdin: manifest + on hosts, "fgrep 'pigiron.example.com' /etc/hosts", acceptable_exit_codes: [1] end - ensure on hosts, 'cat /tmp/hosts.bak > /etc/hosts && rm /tmp/hosts.bak' end diff --git a/spec/acceptance/puppet.rb b/spec/acceptance/puppet.rb index 10fb159..048a3db 100644 --- a/spec/acceptance/puppet.rb +++ b/spec/acceptance/puppet.rb @@ -1,14 +1,13 @@ -test_name "Augeas puppet configuration" do - +test_name 'Augeas puppet configuration' do tag 'risk:medium', 'audit:medium', 'audit:acceptance', - 'audit:refactor' # move to types test dir + 'audit:refactor' # move to types test dir skip_test 'requires augeas which is included in AIO' if @options[:type] != 'aio' - confine :except, :platform => 'windows' - confine :to, {}, hosts.select { |host| ! host[:roles].include?('master') } + confine :except, platform: 'windows' + confine :to, {}, hosts.reject { |host| host[:roles].include?('master') } teardown do agents.each do |agent| @@ -17,17 +16,17 @@ test_name "Augeas puppet configuration" do end agents.each do |agent| - step "Backup the puppet config" do + step 'Backup the puppet config' do on agent, "mv #{agent.puppet['confdir']}/puppet.conf /tmp/puppet.conf.bak" end - step "Create a new puppet config that has a master and agent section" do + step 'Create a new puppet config that has a master and agent section' do puppet_conf = <<-CONF [main] CONF on agent, "echo \"#{puppet_conf}\" >> #{agent.puppet['confdir']}/puppet.conf" end - step "Modify the puppet.conf file" do + step 'Modify the puppet.conf file' do manifest = <<-EOF augeas { 'puppet agent noop mode': context => "/files#{agent.puppet['confdir']}/puppet.conf/agent", @@ -36,11 +35,9 @@ test_name "Augeas puppet configuration" do changes => 'set noop true', } EOF - on agent, puppet_apply('--verbose'), :stdin => manifest + on agent, puppet_apply('--verbose'), stdin: manifest on agent, "grep 'noop=true' #{agent.puppet['confdir']}/puppet.conf" end - end - end diff --git a/spec/acceptance/services.rb b/spec/acceptance/services.rb index ec87316..2e48af0 100644 --- a/spec/acceptance/services.rb +++ b/spec/acceptance/services.rb @@ -1,23 +1,22 @@ -test_name "Augeas services file" do - +test_name 'Augeas services file' do tag 'risk:medium', 'audit:medium', 'audit:acceptance', - 'audit:refactor' # move to types test dir - # use single manifest/apply + 'audit:refactor' # move to types test dir + # use single manifest/apply skip_test 'requires augeas which is included in AIO' if @options[:type] != 'aio' - confine :except, :platform => 'windows' - confine :except, :platform => 'osx' - confine :to, {}, hosts.select { |host| ! host[:roles].include?('master') } + confine :except, platform: 'windows' + confine :except, platform: 'osx' + confine :to, {}, hosts.reject { |host| host[:roles].include?('master') } - step "Backup the services file" do - on hosts, "cp /etc/services /tmp/services.bak" + step 'Backup the services file' do + on hosts, 'cp /etc/services /tmp/services.bak' end begin - step "Add an entry to the services file" do + step 'Add an entry to the services file' do manifest = <<EOF augeas { 'add_services_entry': context => '/files/etc/services', @@ -32,11 +31,11 @@ augeas { 'add_services_entry': } EOF - on hosts, puppet_apply('--verbose'), :stdin => manifest + on hosts, puppet_apply('--verbose'), stdin: manifest on hosts, "fgrep 'Doom 666/udp' /etc/services" end - step "Change the protocol to udp" do + step 'Change the protocol to udp' do manifest = <<EOF augeas { 'change_service_protocol': context => '/files/etc/services', @@ -48,11 +47,11 @@ augeas { 'change_service_protocol': } EOF - on hosts, puppet_apply('--verbose'), :stdin => manifest + on hosts, puppet_apply('--verbose'), stdin: manifest on hosts, "fgrep 'Doom 666/tcp' /etc/services" end - step "Remove the services entry" do + step 'Remove the services entry' do manifest = <<EOF augeas { 'del_service_entry': context => '/files/etc/services', @@ -64,10 +63,10 @@ augeas { 'del_service_entry': } EOF - on hosts, puppet_apply('--verbose'), :stdin => manifest - on hosts, "fgrep 'Doom 666/tcp' /etc/services", :acceptable_exit_codes => [1] + on hosts, puppet_apply('--verbose'), stdin: manifest + on hosts, "fgrep 'Doom 666/tcp' /etc/services", acceptable_exit_codes: [1] end ensure - on hosts, "mv /tmp/services.bak /etc/services" + on hosts, 'mv /tmp/services.bak /etc/services' end end |