diff --git a/test/integration/cookbooks/os_prepare/recipes/file.rb b/test/integration/cookbooks/os_prepare/recipes/file.rb index 61a7caed5..9810b76b9 100644 --- a/test/integration/cookbooks/os_prepare/recipes/file.rb +++ b/test/integration/cookbooks/os_prepare/recipes/file.rb @@ -11,6 +11,8 @@ if node['platform_family'] != 'windows' 'system' when 'freebsd' 'wheel' + when 'solaris', 'solaris2' + 'sys' else 'root' end diff --git a/test/integration/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb b/test/integration/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb index ae64f4b3b..1774d9ec3 100644 --- a/test/integration/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb +++ b/test/integration/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb @@ -9,6 +9,8 @@ gid = case node['platform_family'] 'system' when 'freebsd' 'wheel' + when 'solaris', 'solaris2' + 'sys' else 'root' end diff --git a/test/integration/cookbooks/os_prepare/recipes/mount.rb b/test/integration/cookbooks/os_prepare/recipes/mount.rb index 94442ae28..c90fec289 100644 --- a/test/integration/cookbooks/os_prepare/recipes/mount.rb +++ b/test/integration/cookbooks/os_prepare/recipes/mount.rb @@ -4,26 +4,30 @@ # # file mount tests -# copy iso file for mount tests -# NB created using `mkdir empty; mkisofs -o empty.iso empty/` -cookbook_file '/root/empty.iso' do - owner 'root' - group 'root' - mode '0755' - action :create -end +case node['platform'] +when 'ubuntu', 'rhel', 'centos', 'fedora' -# create mount directory -directory '/mnt/iso-disk' do - owner 'root' - group 'root' - mode '0755' - action :create -end + # copy iso file for mount tests + # NB created using `mkdir empty; mkisofs -o empty.iso empty/` + cookbook_file '/root/empty.iso' do + owner 'root' + group 'root' + mode '0755' + action :create + end -# mount -o loop /root/empty.iso /mnt/iso-disk -mount '/mnt/iso-disk' do - device '/root/empty.iso' - options 'loop' - action [:mount, :enable] + # create mount directory + directory '/mnt/iso-disk' do + owner 'root' + group 'root' + mode '0755' + action :create + end + + # mount -o loop /root/empty.iso /mnt/iso-disk + mount '/mnt/iso-disk' do + device '/root/empty.iso' + options 'loop' + action [:mount, :enable] + end end diff --git a/test/integration/test/integration/default/_debug_spec.rb b/test/integration/test/integration/default/_debug_spec.rb index cd3b41f6f..6f2ab06d6 100644 --- a/test/integration/test/integration/default/_debug_spec.rb +++ b/test/integration/test/integration/default/_debug_spec.rb @@ -1 +1 @@ -p "You are currently running on OS family: #{os[:family] || 'unknown'}, OS release: #{os[:release] || 'unknown'}" +p "You are currently running on OS: #{os[:name] || 'unknown'}, OS release: #{os[:release] || 'unknown'}, OS family: #{os[:family] || 'unknown'}" diff --git a/test/integration/test/integration/default/compare_matcher_spec.rb b/test/integration/test/integration/default/compare_matcher_spec.rb index e527e6558..caac90694 100644 --- a/test/integration/test/integration/default/compare_matcher_spec.rb +++ b/test/integration/test/integration/default/compare_matcher_spec.rb @@ -1,19 +1,21 @@ # encoding: utf-8 -# uses the `cmp` matcher instead of the eq matcher -describe sshd_config do - its('Port') { should eq '22' } - its('Port') { should_not eq 22 } +if os.linux? + # uses the `cmp` matcher instead of the eq matcher + describe sshd_config do + its('Port') { should eq '22' } + its('Port') { should_not eq 22 } - its('Port') { should cmp '22' } - its('Port') { should cmp 22 } - its('Port') { should cmp 22.0 } - its('Port') { should_not cmp 22.1 } + its('Port') { should cmp '22' } + its('Port') { should cmp 22 } + its('Port') { should cmp 22.0 } + its('Port') { should_not cmp 22.1 } - its('LogLevel') { should eq 'INFO' } - its('LogLevel') { should_not eq 'info'} + its('LogLevel') { should eq 'INFO' } + its('LogLevel') { should_not eq 'info'} - its('LogLevel') { should cmp 'INFO' } - its('LogLevel') { should cmp 'info' } - its('LogLevel') { should cmp 'InfO' } + its('LogLevel') { should cmp 'INFO' } + its('LogLevel') { should cmp 'info' } + its('LogLevel') { should cmp 'InfO' } + end end diff --git a/test/integration/test/integration/default/etc_group_spec.rb b/test/integration/test/integration/default/etc_group_spec.rb index aa8017418..371b145ff 100644 --- a/test/integration/test/integration/default/etc_group_spec.rb +++ b/test/integration/test/integration/default/etc_group_spec.rb @@ -1,13 +1,14 @@ # encoding: utf-8 -root_group = case os[:family] - when 'aix' - 'system' - when 'freebsd' - 'wheel' - else - 'root' - end +root_group = 'root' + +if os[:family] == 'aix' + root_group = 'system' +elsif os[:family] == 'freebsd' + root_group = 'wheel' +elsif os.solaris? + root_group = 'sys' +end if os.unix? describe etc_group do diff --git a/test/integration/test/integration/default/file_spec.rb b/test/integration/test/integration/default/file_spec.rb index 58a77b97b..5ed03fa9b 100644 --- a/test/integration/test/integration/default/file_spec.rb +++ b/test/integration/test/integration/default/file_spec.rb @@ -1,7 +1,6 @@ # encoding: utf-8 -case os[:family] -when 'freebsd' +if os[:family] == 'freebsd' filedata = { user: 'root', group: 'wheel', @@ -9,7 +8,7 @@ when 'freebsd' dir_md5sum: '598f4fe64aefab8f00bcbea4c9239abf', dir_sha256sum: '9b4fb24edd6d1d8830e272398263cdbf026b97392cc35387b991dc0248a628f9', } -when 'aix' +elsif os[:family] == 'aix' filedata = { user: 'root', group: 'system', @@ -17,6 +16,14 @@ when 'aix' dir_md5sum: nil, dir_sha256sum: nil, } +elsif os.solaris? + filedata = { + user: 'root', + group: 'sys', + dir_content: nil, + dir_md5sum: nil, + dir_sha256sum: nil, + } else filedata = { user: 'root', @@ -116,7 +123,9 @@ if os.unix? its('group') { should eq filedata[:group] } its('type') { should eq :directory } end +end +if os.linux? # for server spec compatibility # Do not use `.with` or `.only_with`, this syntax is deprecated and will be removed # in InSpec version 1 @@ -140,8 +149,9 @@ if os.unix? }) } end +end -elsif os.windows? +if os.windows? describe file('C:\\Windows') do it { should exist } it { should be_directory } diff --git a/test/integration/test/integration/default/group_spec.rb b/test/integration/test/integration/default/group_spec.rb index 2d45009b5..03809c35b 100644 --- a/test/integration/test/integration/default/group_spec.rb +++ b/test/integration/test/integration/default/group_spec.rb @@ -11,10 +11,7 @@ if os.linux? it { should_not exist } its('gid') { should eq nil } end -end - -if os[:family] == 'freebsd' - +elsif os[:family] == 'freebsd' describe group('wheel') do it { should exist } its('gid') { should eq 0 } @@ -29,9 +26,7 @@ if os[:family] == 'freebsd' it { should_not exist } its('gid') { should eq nil } end -end - -if os[:family] == 'aix' +elsif os[:family] == 'aix' describe group('system') do it { should exist } its('gid') { should eq 0 } @@ -42,6 +37,21 @@ if os[:family] == 'aix' its('gid') { should eq 2 } end + describe group('noroot') do + it { should_not exist } + its('gid') { should eq nil } + end +elsif os.solaris? + describe group('root') do + it { should exist } + its('gid') { should eq 0 } + end + + describe group('bin') do + it { should exist } + its('gid') { should eq 2 } + end + describe group('noroot') do it { should_not exist } its('gid') { should eq nil } diff --git a/test/integration/test/integration/default/mount_spec.rb b/test/integration/test/integration/default/mount_spec.rb index bed60b5ab..e4fca6a95 100644 --- a/test/integration/test/integration/default/mount_spec.rb +++ b/test/integration/test/integration/default/mount_spec.rb @@ -1,10 +1,12 @@ # encoding: utf-8 -# instead of `.with` or `.only_with` we recommend to use the `mount` resource -describe mount '/mnt/iso-disk' do - it { should be_mounted } - its('count') { should eq 1 } - its('device') { should eq '/root/empty.iso' } - its('type') { should eq 'iso9660' } - its('options') { should eq ['ro'] } +if os.linux? + # instead of `.with` or `.only_with` we recommend to use the `mount` resource + describe mount '/mnt/iso-disk' do + it { should be_mounted } + its('count') { should eq 1 } + its('device') { should eq '/root/empty.iso' } + its('type') { should eq 'iso9660' } + its('options') { should eq ['ro'] } + end end diff --git a/test/integration/test/integration/default/package_spec.rb b/test/integration/test/integration/default/package_spec.rb index 165ad6317..7f41aab15 100644 --- a/test/integration/test/integration/default/package_spec.rb +++ b/test/integration/test/integration/default/package_spec.rb @@ -10,6 +10,22 @@ when 'aix' it { should be_installed } its('version') { should match /^(6|7)[.|\d]+\d$/ } end +when 'solaris' + + if os[:release] == '11' + pkg = 'system/file-system/zfs' + ver = /^0\.5.+$/ + else + pkg = 'SUNWzfsr' + ver = /^11\.10.+$/ + end + + describe package(pkg) do + it { should be_installed } + its('version') { should match ver } + end + + end describe package('nginx') do diff --git a/test/integration/test/integration/default/port_spec.rb b/test/integration/test/integration/default/port_spec.rb index d97faaaa2..f6401a73a 100644 --- a/test/integration/test/integration/default/port_spec.rb +++ b/test/integration/test/integration/default/port_spec.rb @@ -1,15 +1,21 @@ # encoding: utf-8 +# check that ssh runs if os.unix? - # check that ssh runs describe port(22) do it { should be_listening } its('protocols') { should include('tcp') } its('protocols') { should_not include('udp') } - its('processes') { should include 'sshd' } end describe port(65432) do it { should_not be_listening } end end + +# extra test for linux +if os.linux? + describe port(22) do + its('processes') { should include 'sshd' } + end +end diff --git a/test/integration/test/integration/default/service_spec.rb b/test/integration/test/integration/default/service_spec.rb index a617c8121..80c4b285b 100644 --- a/test/integration/test/integration/default/service_spec.rb +++ b/test/integration/test/integration/default/service_spec.rb @@ -13,13 +13,16 @@ elsif ['ubuntu'].include?(os[:family]) # Ubuntu unavailable_service = 'sshd' available_service = 'ssh' -elsif ['windows'].include?(os[:family]) +elsif os.windows? # Ubuntu unavailable_service = 'sshd' available_service = 'dhcp' elsif ['aix'].include?(os[:family]) unavailable_service = 'clamav' available_service = 'xntpd' +elsif os.solaris? + unavailable_service = 'clamav' + available_service = 'ssh' end describe service(unavailable_service) do diff --git a/test/integration/test/integration/default/user_spec.rb b/test/integration/test/integration/default/user_spec.rb index 7cea43955..0c7fced97 100644 --- a/test/integration/test/integration/default/user_spec.rb +++ b/test/integration/test/integration/default/user_spec.rb @@ -1,7 +1,6 @@ # encoding: utf-8 -case os[:family] -when 'centos', 'redhat', 'fedora', 'opensuse', 'debian', 'ubuntu' +if ['centos', 'redhat', 'fedora', 'opensuse', 'debian', 'ubuntu'].include?(os[:family]) userinfo = { name: 'root', group: 'root', @@ -15,19 +14,17 @@ when 'centos', 'redhat', 'fedora', 'opensuse', 'debian', 'ubuntu' # different groupset for centos 5 userinfo[:groups] = ["root", "bin", "daemon", "sys", "adm", "disk", "wheel"] \ if os[:release].to_i == 5 - -when 'freebsd' +elsif ['freebsd'].include?(os[:family]) userinfo = { name: 'root', group: 'wheel', uid: 0, gid: 0, - groups: ["wheel", "operator"], + groups: "wheel", # at least this group should be there home: '/root', shell: '/bin/csh', } - -when 'windows' +elsif os.windows? userinfo = { name: 'Administrator', group: nil, @@ -37,27 +34,46 @@ when 'windows' home: nil, shell: nil, } - -when 'aix' +elsif os[:family] == 'aix' userinfo = { name: 'bin', group: 'bin', uid: 2, gid: 2, - groups: %w{bin sys adm}, + groups: "adm", # at least this group should be there home: '/bin', shell: nil, #mindays: 0, #maxdays: 0, warndays: 0, } - +elsif os.solaris? + if os[:release].to_i > 10 + userinfo = { + name: 'root', + group: 'root', + uid: 0, + gid: 0, + groups: "sys", # at least this group should be there + home: '/root', + shell: '/usr/bin/bash', + } + else + userinfo = { + name: 'root', + group: 'root', + uid: 0, + gid: 0, + groups: "sys", # at least this group should be there + home: '/', + shell: '/sbin/sh', + } + end else userinfo = {} end -case os[:family] -when 'windows' +if os.windows? describe user(userinfo[:name]) do it { should exist } end @@ -66,7 +82,14 @@ else it { should exist } userinfo.each do |k, v| next if k.to_sym == :name - its(k) { should eq v } + + # check that the user is part of the groups + if k.to_s == 'groups' + its(k) { should include v } + # default eq comparison + else + its(k) { should eq v } + end end end end