mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
Update inspec for os[:family] change in Train
Signed-off-by: Steven Danna <steve@chef.io>
This commit is contained in:
parent
b16ea5f89f
commit
57d7275857
19 changed files with 105 additions and 95 deletions
7
Gemfile
7
Gemfile
|
@ -8,6 +8,13 @@ if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new('1.9.3')
|
||||||
gem 'net-ssh', '~> 2.9'
|
gem 'net-ssh', '~> 2.9'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# This has to be merged someone concurrently with a a version bump in
|
||||||
|
# train to avoid breaking users.
|
||||||
|
#
|
||||||
|
gem 'train', github: 'chef/train'
|
||||||
|
|
||||||
# TODO: ffi 1.9.11 is currently erroneous on windows tests
|
# TODO: ffi 1.9.11 is currently erroneous on windows tests
|
||||||
gem 'ffi', '= 1.9.10'
|
gem 'ffi', '= 1.9.10'
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ module Inspec
|
||||||
end
|
end
|
||||||
|
|
||||||
if !profile.metadata.supports_transport?(@backend)
|
if !profile.metadata.supports_transport?(@backend)
|
||||||
os_info = @backend.os[:family].to_s
|
os_info = @backend.os[:name].to_s
|
||||||
fail "This OS/platform (#{os_info}) is not supported by this profile."
|
fail "This OS/platform (#{os_info}) is not supported by this profile."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,7 @@ module Inspec::Resources
|
||||||
|
|
||||||
attr_reader :service, :conf_dir, :conf_path, :user
|
attr_reader :service, :conf_dir, :conf_path, :user
|
||||||
def initialize
|
def initialize
|
||||||
case inspec.os[:family]
|
if inspec.os.debian?
|
||||||
when 'ubuntu', 'debian'
|
|
||||||
@service = 'apache2'
|
@service = 'apache2'
|
||||||
@conf_dir = '/etc/apache2/'
|
@conf_dir = '/etc/apache2/'
|
||||||
@conf_path = File.join @conf_dir, 'apache2.conf'
|
@conf_path = File.join @conf_dir, 'apache2.conf'
|
||||||
|
|
|
@ -80,7 +80,7 @@ module Inspec::Resources
|
||||||
|
|
||||||
if @content =~ /^LIST_RULES:/
|
if @content =~ /^LIST_RULES:/
|
||||||
# do not warn on centos 5
|
# do not warn on centos 5
|
||||||
unless inspec.os[:family] == 'centos' && inspec.os[:release].to_i == 5
|
unless inspec.os[:name] == 'centos' && inspec.os[:release].to_i == 5
|
||||||
warn '[WARN] this version of auditd is outdated. Updating it allows for using more precise matchers.'
|
warn '[WARN] this version of auditd is outdated. Updating it allows for using more precise matchers.'
|
||||||
end
|
end
|
||||||
@legacy = AuditdRulesLegacy.new(@content)
|
@legacy = AuditdRulesLegacy.new(@content)
|
||||||
|
|
|
@ -45,7 +45,7 @@ module Inspec::Resources
|
||||||
|
|
||||||
def exist?
|
def exist?
|
||||||
# silent for mock resources
|
# silent for mock resources
|
||||||
return false if inspec.os[:family].to_s == 'unknown'
|
return false if inspec.os[:name].to_s == 'unknown'
|
||||||
|
|
||||||
if inspec.os.linux?
|
if inspec.os.linux?
|
||||||
res = inspec.backend.run_command("bash -c 'type \"#{@command}\"'")
|
res = inspec.backend.run_command("bash -c 'type \"#{@command}\"'")
|
||||||
|
@ -54,7 +54,7 @@ module Inspec::Resources
|
||||||
elsif inspec.os.unix?
|
elsif inspec.os.unix?
|
||||||
res = inspec.backend.run_command("type \"#{@command}\"")
|
res = inspec.backend.run_command("type \"#{@command}\"")
|
||||||
else
|
else
|
||||||
warn "`command(#{@command}).exist?` is not suported on your OS: #{inspec.os[:family]}"
|
warn "`command(#{@command}).exist?` is not suported on your OS: #{inspec.os[:name]}"
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
res.exit_status.to_i == 0
|
res.exit_status.to_i == 0
|
||||||
|
|
|
@ -21,28 +21,40 @@ class GrubConfig < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
|
||||||
end
|
end
|
||||||
"
|
"
|
||||||
|
|
||||||
|
class UnknownGrubConfig < StandardError; end
|
||||||
|
|
||||||
def initialize(path = nil, kernel = nil)
|
def initialize(path = nil, kernel = nil)
|
||||||
family = inspec.os[:family]
|
config_for_platform(path)
|
||||||
case family
|
@kernel = kernel || 'default'
|
||||||
when 'redhat', 'fedora', 'centos'
|
rescue UnknownGrubConfig
|
||||||
release = inspec.os[:release].to_f
|
return skip_resource 'The `grub_config` resource is not supported on your OS yet.'
|
||||||
supported = true
|
end
|
||||||
if release < 7
|
|
||||||
@conf_path = path || '/etc/grub.conf'
|
def config_for_platform(path)
|
||||||
@version = 'legacy'
|
os = inspec.os
|
||||||
else
|
if os.redhat? || os[:name] == 'fedora'
|
||||||
@conf_path = path || '/boot/grub/grub.cfg'
|
config_for_redhatish(path)
|
||||||
@defaults_path = '/etc/default/grub'
|
elsif os.debian?
|
||||||
@version = 'grub2'
|
@conf_path = path || '/boot/grub/grub.cfg'
|
||||||
end
|
@defaults_path = '/etc/default/grub'
|
||||||
when 'ubuntu'
|
@version = 'grub2'
|
||||||
|
elsif os[:name] == 'amazon' # rubocop:disable Style/GuardClause
|
||||||
|
@conf_path = path || '/etc/grub.conf'
|
||||||
|
@version = 'legacy'
|
||||||
|
else
|
||||||
|
fail UnknownGrubConfig
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def config_for_redhatish(path)
|
||||||
|
if inspec.os[:release].to_f < 7
|
||||||
|
@conf_path = path || '/etc/grub.conf'
|
||||||
|
@version = 'legacy'
|
||||||
|
else
|
||||||
@conf_path = path || '/boot/grub/grub.cfg'
|
@conf_path = path || '/boot/grub/grub.cfg'
|
||||||
@defaults_path = '/etc/default/grub'
|
@defaults_path = '/etc/default/grub'
|
||||||
@version = 'grub2'
|
@version = 'grub2'
|
||||||
supported = true
|
|
||||||
end
|
end
|
||||||
@kernel = kernel || 'default'
|
|
||||||
return skip_resource 'The `grub_config` resource is not supported on your OS yet.' if supported.nil?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_missing(name)
|
def method_missing(name)
|
||||||
|
|
|
@ -24,7 +24,7 @@ module Inspec::Resources
|
||||||
# default lsmod command
|
# default lsmod command
|
||||||
lsmod_cmd = 'lsmod'
|
lsmod_cmd = 'lsmod'
|
||||||
# special care for CentOS 5 and sudo
|
# special care for CentOS 5 and sudo
|
||||||
lsmod_cmd = '/sbin/lsmod' if inspec.os[:family] == 'centos' && inspec.os[:release].to_i == 5
|
lsmod_cmd = '/sbin/lsmod' if inspec.os[:name] == 'centos' && inspec.os[:release].to_i == 5
|
||||||
|
|
||||||
# get list of all modules
|
# get list of all modules
|
||||||
cmd = inspec.command(lsmod_cmd)
|
cmd = inspec.command(lsmod_cmd)
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Inspec::Resources
|
||||||
def initialize
|
def initialize
|
||||||
# set OS-dependent filenames and paths
|
# set OS-dependent filenames and paths
|
||||||
case inspec.os[:family]
|
case inspec.os[:family]
|
||||||
when 'ubuntu', 'debian'
|
when 'debian'
|
||||||
init_ubuntu
|
init_ubuntu
|
||||||
when 'redhat', 'fedora'
|
when 'redhat', 'fedora'
|
||||||
init_redhat
|
init_redhat
|
||||||
|
|
|
@ -23,7 +23,7 @@ module Inspec::Resources
|
||||||
@package_name = package_name
|
@package_name = package_name
|
||||||
|
|
||||||
# verify that this resource is only supported on Windows
|
# verify that this resource is only supported on Windows
|
||||||
return skip_resource 'The `oneget` resource is not supported on your OS.' if inspec.os[:family] != 'windows'
|
return skip_resource 'The `oneget` resource is not supported on your OS.' if !inspec.os.windows?
|
||||||
end
|
end
|
||||||
|
|
||||||
def info
|
def info
|
||||||
|
|
|
@ -59,7 +59,7 @@ module Inspec::Resources
|
||||||
out = inspec.command(command)
|
out = inspec.command(command)
|
||||||
|
|
||||||
unless out.exit_status == 0
|
unless out.exit_status == 0
|
||||||
skip_resource "Can't read environment variables on #{os[:family]}. "\
|
skip_resource "Can't read environment variables on #{os[:name]}. "\
|
||||||
"Tried `#{command}` which returned #{out.exit_status}"
|
"Tried `#{command}` which returned #{out.exit_status}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ module Inspec::Resources
|
||||||
os = inspec.os
|
os = inspec.os
|
||||||
if os.debian?
|
if os.debian?
|
||||||
@pkgman = Deb.new(inspec)
|
@pkgman = Deb.new(inspec)
|
||||||
elsif os.redhat? || os.suse?
|
elsif %w{redhat suse amazon fedora}.include?(os[:family])
|
||||||
@pkgman = Rpm.new(inspec)
|
@pkgman = Rpm.new(inspec)
|
||||||
elsif ['arch'].include?(os[:family])
|
elsif ['arch'].include?(os[:family])
|
||||||
@pkgman = Pacman.new(inspec)
|
@pkgman = Pacman.new(inspec)
|
||||||
|
|
|
@ -57,9 +57,7 @@ module Inspec::Resources
|
||||||
def pip_cmd
|
def pip_cmd
|
||||||
# Pip is not on the default path for Windows, therefore we do some logic
|
# Pip is not on the default path for Windows, therefore we do some logic
|
||||||
# to find the binary on Windows
|
# to find the binary on Windows
|
||||||
family = inspec.os[:family]
|
if inspec.os.windows?
|
||||||
case family
|
|
||||||
when 'windows'
|
|
||||||
# we need to detect the pip command on Windows
|
# we need to detect the pip command on Windows
|
||||||
cmd = inspec.command('New-Object -Type PSObject | Add-Member -MemberType NoteProperty -Name Pip -Value (Invoke-Command -ScriptBlock {where.exe pip}) -PassThru | Add-Member -MemberType NoteProperty -Name Python -Value (Invoke-Command -ScriptBlock {where.exe python}) -PassThru | ConvertTo-Json')
|
cmd = inspec.command('New-Object -Type PSObject | Add-Member -MemberType NoteProperty -Name Pip -Value (Invoke-Command -ScriptBlock {where.exe pip}) -PassThru | Add-Member -MemberType NoteProperty -Name Python -Value (Invoke-Command -ScriptBlock {where.exe python}) -PassThru | ConvertTo-Json')
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -10,33 +10,27 @@ module Inspec::Resources
|
||||||
|
|
||||||
attr_reader :service, :data_dir, :conf_dir, :conf_path
|
attr_reader :service, :data_dir, :conf_dir, :conf_path
|
||||||
def initialize
|
def initialize
|
||||||
case inspec.os[:family]
|
os = inspec.os
|
||||||
when 'ubuntu', 'debian'
|
if os.debian?
|
||||||
@service = 'postgresql'
|
@service = 'postgresql'
|
||||||
@data_dir = '/var/lib/postgresql'
|
@data_dir = '/var/lib/postgresql'
|
||||||
@version = inspec.command('ls /etc/postgresql/').stdout.chomp
|
@version = inspec.command('ls /etc/postgresql/').stdout.chomp
|
||||||
@conf_dir = "/etc/postgresql/#{@version}/main"
|
@conf_dir = "/etc/postgresql/#{@version}/main"
|
||||||
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
elsif os.redhat?
|
||||||
|
|
||||||
when 'arch'
|
|
||||||
@service = 'postgresql'
|
|
||||||
@data_dir = '/var/lib/postgres/data'
|
|
||||||
@conf_dir = '/var/lib/postgres/data'
|
|
||||||
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
|
||||||
|
|
||||||
when 'centos', 'redhat'
|
|
||||||
@service = 'postgresql'
|
@service = 'postgresql'
|
||||||
@version = inspec.command('ls /var/lib/pgsql/').stdout.chomp
|
@version = inspec.command('ls /var/lib/pgsql/').stdout.chomp
|
||||||
@data_dir = "/var/lib/pgsql/#{@version}/data"
|
@data_dir = "/var/lib/pgsql/#{@version}/data"
|
||||||
@conf_dir = "/var/lib/pgsql/#{@version}/data"
|
elsif os[:name] == 'arch'
|
||||||
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
@service = 'postgresql'
|
||||||
|
@data_dir = '/var/lib/postgres/data'
|
||||||
|
@conf_dir = '/var/lib/postgres/data'
|
||||||
else
|
else
|
||||||
@service = 'postgresql'
|
@service = 'postgresql'
|
||||||
@data_dir = '/var/lib/postgresql'
|
@data_dir = '/var/lib/postgresql'
|
||||||
@conf_dir = '/var/lib/pgsql/data'
|
@conf_dir = '/var/lib/pgsql/data'
|
||||||
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
|
|
@ -102,7 +102,7 @@ module Inspec::Resources
|
||||||
|
|
||||||
def select_service_mgmt # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
|
def select_service_mgmt # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
|
||||||
os = inspec.os
|
os = inspec.os
|
||||||
family = os[:family]
|
platform = os[:name]
|
||||||
|
|
||||||
# Ubuntu
|
# Ubuntu
|
||||||
# @see: https://wiki.ubuntu.com/SystemdForUpstartUsers
|
# @see: https://wiki.ubuntu.com/SystemdForUpstartUsers
|
||||||
|
@ -112,46 +112,46 @@ module Inspec::Resources
|
||||||
# Ubuntu < 15.04 : Upstart
|
# Ubuntu < 15.04 : Upstart
|
||||||
# Upstart runs with PID 1 as /sbin/init.
|
# Upstart runs with PID 1 as /sbin/init.
|
||||||
# Systemd runs with PID 1 as /lib/systemd/systemd.
|
# Systemd runs with PID 1 as /lib/systemd/systemd.
|
||||||
if %w{ubuntu}.include?(family)
|
if %w{ubuntu}.include?(platform)
|
||||||
version = inspec.os[:release].to_f
|
version = os[:release].to_f
|
||||||
if version < 15.04
|
if version < 15.04
|
||||||
Upstart.new(inspec, service_ctl)
|
Upstart.new(inspec, service_ctl)
|
||||||
else
|
else
|
||||||
Systemd.new(inspec, service_ctl)
|
Systemd.new(inspec, service_ctl)
|
||||||
end
|
end
|
||||||
elsif %w{debian}.include?(family)
|
elsif %w{debian}.include?(platform)
|
||||||
version = inspec.os[:release].to_i
|
version = os[:release].to_i
|
||||||
if version > 7
|
if version > 7
|
||||||
Systemd.new(inspec, service_ctl)
|
Systemd.new(inspec, service_ctl)
|
||||||
else
|
else
|
||||||
SysV.new(inspec, service_ctl || '/usr/sbin/service')
|
SysV.new(inspec, service_ctl || '/usr/sbin/service')
|
||||||
end
|
end
|
||||||
elsif %w{redhat fedora centos}.include?(family)
|
elsif %w{redhat fedora centos}.include?(platform)
|
||||||
version = inspec.os[:release].to_i
|
version = os[:release].to_i
|
||||||
if (%w{ redhat centos }.include?(family) && version >= 7) || (family == 'fedora' && version >= 15)
|
if (%w{ redhat centos }.include?(platform) && version >= 7) || (platform == 'fedora' && version >= 15)
|
||||||
Systemd.new(inspec, service_ctl)
|
Systemd.new(inspec, service_ctl)
|
||||||
else
|
else
|
||||||
SysV.new(inspec, service_ctl || '/sbin/service')
|
SysV.new(inspec, service_ctl || '/sbin/service')
|
||||||
end
|
end
|
||||||
elsif %w{wrlinux}.include?(family)
|
elsif %w{wrlinux}.include?(platform)
|
||||||
SysV.new(inspec, service_ctl)
|
SysV.new(inspec, service_ctl)
|
||||||
elsif %w{darwin}.include?(family)
|
elsif %w{mac_os_x}.include?(platform)
|
||||||
LaunchCtl.new(inspec, service_ctl)
|
LaunchCtl.new(inspec, service_ctl)
|
||||||
elsif os.windows?
|
elsif os.windows?
|
||||||
WindowsSrv.new(inspec)
|
WindowsSrv.new(inspec)
|
||||||
elsif %w{freebsd}.include?(family)
|
elsif %w{freebsd}.include?(platform)
|
||||||
BSDInit.new(inspec, service_ctl)
|
BSDInit.new(inspec, service_ctl)
|
||||||
elsif %w{arch}.include?(family)
|
elsif %w{arch}.include?(platform)
|
||||||
Systemd.new(inspec, service_ctl)
|
Systemd.new(inspec, service_ctl)
|
||||||
elsif %w{suse opensuse}.include?(family)
|
elsif %w{suse opensuse}.include?(platform)
|
||||||
if inspec.os[:release].to_i >= 12
|
if os[:release].to_i >= 12
|
||||||
Systemd.new(inspec, service_ctl)
|
Systemd.new(inspec, service_ctl)
|
||||||
else
|
else
|
||||||
SysV.new(inspec, service_ctl || '/sbin/service')
|
SysV.new(inspec, service_ctl || '/sbin/service')
|
||||||
end
|
end
|
||||||
elsif %w{aix}.include?(family)
|
elsif %w{aix}.include?(platform)
|
||||||
SrcMstr.new(inspec)
|
SrcMstr.new(inspec)
|
||||||
elsif %w{amazon}.include?(family)
|
elsif %w{amazon}.include?(platform)
|
||||||
Upstart.new(inspec, service_ctl)
|
Upstart.new(inspec, service_ctl)
|
||||||
elsif os.solaris?
|
elsif os.solaris?
|
||||||
Svcs.new(inspec)
|
Svcs.new(inspec)
|
||||||
|
@ -359,7 +359,7 @@ module Inspec::Resources
|
||||||
enabled = !config[/^\s*start on/].nil?
|
enabled = !config[/^\s*start on/].nil?
|
||||||
|
|
||||||
# implement fallback for Ubuntu 10.04
|
# implement fallback for Ubuntu 10.04
|
||||||
if inspec.os[:family] == 'ubuntu' &&
|
if inspec.os[:name] == 'ubuntu' &&
|
||||||
inspec.os[:release].to_f >= 10.04 &&
|
inspec.os[:release].to_f >= 10.04 &&
|
||||||
inspec.os[:release].to_f < 12.04 &&
|
inspec.os[:release].to_f < 12.04 &&
|
||||||
status.exit_status == 0
|
status.exit_status == 0
|
||||||
|
|
|
@ -42,7 +42,7 @@ module Inspec::Resources
|
||||||
@cache = nil
|
@cache = nil
|
||||||
|
|
||||||
# verify that this resource is only supported on Windows
|
# verify that this resource is only supported on Windows
|
||||||
return skip_resource 'The `windows_feature` resource is not supported on your OS.' if inspec.os[:family] != 'windows'
|
return skip_resource 'The `windows_feature` resource is not supported on your OS.' if !inspec.os.windows?
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns true if the package is installed
|
# returns true if the package is installed
|
||||||
|
|
|
@ -38,25 +38,25 @@ TMP_CACHE = {}
|
||||||
class MockLoader
|
class MockLoader
|
||||||
# collects emulation operating systems
|
# collects emulation operating systems
|
||||||
OPERATING_SYSTEMS = {
|
OPERATING_SYSTEMS = {
|
||||||
arch: { family: 'arch', release: nil, arch: nil },
|
arch: { name: 'arch', family: 'arch', release: nil, arch: nil },
|
||||||
centos5: { family: 'redhat', release: '5.11', arch: 'x86_64' },
|
centos5: { name: 'centos', family: 'redhat', release: '5.11', arch: 'x86_64' },
|
||||||
centos6: { family: 'redhat', release: '6.6', arch: 'x86_64' },
|
centos6: { name: 'centos', family: 'redhat', release: '6.6', arch: 'x86_64' },
|
||||||
centos7: { family: 'redhat', release: '7.1.1503', arch: 'x86_64' },
|
centos7: { name: 'centos', family: 'redhat', release: '7.1.1503', arch: 'x86_64' },
|
||||||
debian6: { family: 'debian', release: '6', arch: 'x86_64' },
|
debian6: { name: 'debian', family: 'debian', release: '6', arch: 'x86_64' },
|
||||||
debian7: { family: 'debian', release: '7', arch: 'x86_64' },
|
debian7: { name: 'debian', family: 'debian', release: '7', arch: 'x86_64' },
|
||||||
debian8: { family: 'debian', release: '8', arch: 'x86_64' },
|
debian8: { name: 'debian', family: 'debian', release: '8', arch: 'x86_64' },
|
||||||
freebsd9: { family: 'freebsd', release: '9', arch: 'amd64' },
|
freebsd9: { name: 'freebsd', family: 'freebsd', release: '9', arch: 'amd64' },
|
||||||
freebsd10: { family: 'freebsd', release: '10', arch: 'amd64' },
|
freebsd10: { name: 'freebsd', family: 'freebsd', release: '10', arch: 'amd64' },
|
||||||
osx104: { family: 'darwin', release: '10.10.4', arch: nil, name: 'mac_os_x' },
|
osx104: { name: 'mac_os_x',family: 'darwin', release: '10.10.4', arch: nil },
|
||||||
ubuntu1204: { family: 'ubuntu', release: '12.04', arch: 'x86_64' },
|
ubuntu1204: { name: 'ubuntu', family: 'debian', release: '12.04', arch: 'x86_64' },
|
||||||
ubuntu1404: { family: 'ubuntu', release: '14.04', arch: 'x86_64' },
|
ubuntu1404: { name: 'ubuntu', family: 'debian', release: '14.04', arch: 'x86_64' },
|
||||||
ubuntu1504: { family: 'ubuntu', release: '15.04', arch: 'x86_64' },
|
ubuntu1504: { name: 'ubuntu', family: 'debian', release: '15.04', arch: 'x86_64' },
|
||||||
windows: { family: 'windows', release: '6.2.9200', arch: 'x86_64' },
|
windows: { name: 'windows', family: 'windows', release: '6.2.9200', arch: 'x86_64' },
|
||||||
wrlinux: { family: 'wrlinux', release: '7.0(3)I2(2)', arch: 'x86_64' },
|
wrlinux: { name: 'wrlinux', family: 'redhat', release: '7.0(3)I2(2)', arch: 'x86_64' },
|
||||||
solaris11: { family: "solaris", release: '11', arch: 'i386'},
|
solaris11: { name: "solaris", family: 'solaris', release: '11', arch: 'i386'},
|
||||||
solaris10: { family: "solaris", release: '10', arch: 'i386'},
|
solaris10: { name: "solaris", family: 'solaris', release: '10', arch: 'i386'},
|
||||||
hpux: {family: 'hpux', release: 'B.11.31', arch: 'ia64'},
|
hpux: { name: 'hpux', family: 'hpux', release: 'B.11.31', arch: 'ia64'},
|
||||||
undefined: { family: nil, release: nil, arch: nil },
|
undefined: { name: nil, family: nil, release: nil, arch: nil },
|
||||||
}
|
}
|
||||||
|
|
||||||
# pass the os identifier to emulate a specific operating system
|
# pass the os identifier to emulate a specific operating system
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
if os[:family] == 'ubuntu'
|
if os[:name] == 'ubuntu'
|
||||||
|
|
||||||
describe apt('ppa:nginx/stable') do
|
describe apt('ppa:nginx/stable') do
|
||||||
it { should exist }
|
it { should exist }
|
||||||
|
|
|
@ -77,7 +77,7 @@ describe Inspec::ProfileContext do
|
||||||
include DescribeOneTest
|
include DescribeOneTest
|
||||||
|
|
||||||
it 'must provide os resource' do
|
it 'must provide os resource' do
|
||||||
load('print os[:family]').must_output 'ubuntu'
|
load('print os[:family]').must_output 'debian'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'must provide file resource' do
|
it 'must provide file resource' do
|
||||||
|
@ -215,7 +215,7 @@ describe Inspec::ProfileContext do
|
||||||
describe 'adds a check via describe' do
|
describe 'adds a check via describe' do
|
||||||
let(:check) {
|
let(:check) {
|
||||||
profile.load(format(context_format,
|
profile.load(format(context_format,
|
||||||
"describe os[:family] { it { must_equal 'ubuntu' } }"
|
"describe os[:family] { it { must_equal 'debian' } }"
|
||||||
))
|
))
|
||||||
get_checks[0]
|
get_checks[0]
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ describe Inspec::ProfileContext do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'registers the check with the describe argument' do
|
it 'registers the check with the describe argument' do
|
||||||
check[1].must_equal %w{ubuntu}
|
check[1].must_equal %w{debian}
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'registers the check with the provided proc' do
|
it 'registers the check with the provided proc' do
|
||||||
|
@ -236,7 +236,7 @@ describe Inspec::ProfileContext do
|
||||||
describe 'adds a check via expect' do
|
describe 'adds a check via expect' do
|
||||||
let(:check) {
|
let(:check) {
|
||||||
profile.load(format(context_format,
|
profile.load(format(context_format,
|
||||||
"expect(os[:family]).to eq('ubuntu')"
|
"expect(os[:family]).to eq('debian')"
|
||||||
))
|
))
|
||||||
get_checks[0]
|
get_checks[0]
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ describe Inspec::ProfileContext do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'registers the check with the describe argument' do
|
it 'registers the check with the describe argument' do
|
||||||
check[1].must_equal %w{ubuntu}
|
check[1].must_equal %w{debian}
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'registers the check with the provided proc' do
|
it 'registers the check with the provided proc' do
|
||||||
|
@ -258,7 +258,7 @@ describe Inspec::ProfileContext do
|
||||||
let(:check) {
|
let(:check) {
|
||||||
profile.load(format(context_format,
|
profile.load(format(context_format,
|
||||||
"describe 'the actual test' do
|
"describe 'the actual test' do
|
||||||
expect(os[:family]).to eq('ubuntu')
|
expect(os[:family]).to eq('debian')
|
||||||
end"
|
end"
|
||||||
))
|
))
|
||||||
get_checks[0]
|
get_checks[0]
|
||||||
|
|
|
@ -8,7 +8,7 @@ require 'inspec/resource'
|
||||||
describe 'Inspec::Resources::Os' do
|
describe 'Inspec::Resources::Os' do
|
||||||
it 'verify os parsing on CentOS' do
|
it 'verify os parsing on CentOS' do
|
||||||
resource = MockLoader.new(:centos7).load_resource('os')
|
resource = MockLoader.new(:centos7).load_resource('os')
|
||||||
_(resource.name).must_equal nil
|
_(resource.name).must_equal 'centos'
|
||||||
_(resource.family).must_equal 'redhat'
|
_(resource.family).must_equal 'redhat'
|
||||||
_(resource.release).must_equal '7.1.1503'
|
_(resource.release).must_equal '7.1.1503'
|
||||||
_(resource.arch).must_equal 'x86_64'
|
_(resource.arch).must_equal 'x86_64'
|
||||||
|
@ -16,7 +16,7 @@ describe 'Inspec::Resources::Os' do
|
||||||
|
|
||||||
it 'read env variable on Windows' do
|
it 'read env variable on Windows' do
|
||||||
resource = MockLoader.new(:windows).load_resource('os')
|
resource = MockLoader.new(:windows).load_resource('os')
|
||||||
_(resource.name).must_equal nil
|
_(resource.name).must_equal 'windows'
|
||||||
_(resource.family).must_equal 'windows'
|
_(resource.family).must_equal 'windows'
|
||||||
_(resource.release).must_equal '6.2.9200'
|
_(resource.release).must_equal '6.2.9200'
|
||||||
_(resource.arch).must_equal 'x86_64'
|
_(resource.arch).must_equal 'x86_64'
|
||||||
|
@ -24,7 +24,7 @@ describe 'Inspec::Resources::Os' do
|
||||||
|
|
||||||
it 'verify os parsing on Debian' do
|
it 'verify os parsing on Debian' do
|
||||||
resource = MockLoader.new(:debian8).load_resource('os')
|
resource = MockLoader.new(:debian8).load_resource('os')
|
||||||
_(resource.name).must_equal nil
|
_(resource.name).must_equal 'debian'
|
||||||
_(resource.family).must_equal 'debian'
|
_(resource.family).must_equal 'debian'
|
||||||
_(resource.release).must_equal '8'
|
_(resource.release).must_equal '8'
|
||||||
_(resource.arch).must_equal 'x86_64'
|
_(resource.arch).must_equal 'x86_64'
|
||||||
|
@ -32,8 +32,8 @@ describe 'Inspec::Resources::Os' do
|
||||||
|
|
||||||
it 'verify os parsing on Ubuntu' do
|
it 'verify os parsing on Ubuntu' do
|
||||||
resource = MockLoader.new(:ubuntu1504).load_resource('os')
|
resource = MockLoader.new(:ubuntu1504).load_resource('os')
|
||||||
_(resource.name).must_equal nil
|
_(resource.name).must_equal 'ubuntu'
|
||||||
_(resource.family).must_equal 'ubuntu'
|
_(resource.family).must_equal 'debian'
|
||||||
_(resource.release).must_equal '15.04'
|
_(resource.release).must_equal '15.04'
|
||||||
_(resource.arch).must_equal 'x86_64'
|
_(resource.arch).must_equal 'x86_64'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue