2015-09-20 21:55:00 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2018-01-02 19:04:13 +00:00
|
|
|
require 'resources/platform'
|
|
|
|
|
2016-03-08 18:06:55 +00:00
|
|
|
module Inspec::Resources
|
2018-01-02 19:04:13 +00:00
|
|
|
class OSResource < PlatformResource
|
2016-03-08 18:06:55 +00:00
|
|
|
name 'os'
|
2018-02-19 14:26:49 +00:00
|
|
|
supports platform: 'unix'
|
|
|
|
supports platform: 'windows'
|
2016-03-08 18:06:55 +00:00
|
|
|
desc 'Use the os InSpec audit resource to test the platform on which the system is running.'
|
|
|
|
example "
|
2016-09-21 06:03:17 +00:00
|
|
|
describe os[:family] do
|
2016-03-08 18:06:55 +00:00
|
|
|
it { should eq 'redhat' }
|
|
|
|
end
|
2016-05-30 08:32:28 +00:00
|
|
|
|
|
|
|
describe os.redhat? do
|
|
|
|
it { should eq true }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe os.linux? do
|
|
|
|
it { should eq true }
|
|
|
|
end
|
2016-03-08 18:06:55 +00:00
|
|
|
"
|
2015-09-20 21:55:00 +00:00
|
|
|
|
2016-03-08 18:06:55 +00:00
|
|
|
# reuse helper methods from backend
|
2016-08-19 22:18:53 +00:00
|
|
|
%w{aix? redhat? debian? suse? bsd? solaris? linux? unix? windows? hpux? darwin?}.each do |os_family|
|
2016-03-08 18:06:55 +00:00
|
|
|
define_method(os_family.to_sym) do
|
2018-01-02 19:04:13 +00:00
|
|
|
@platform.send(os_family)
|
2016-05-30 08:32:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-08 18:06:55 +00:00
|
|
|
def to_s
|
|
|
|
'Operating System Detection'
|
|
|
|
end
|
2015-09-20 21:55:00 +00:00
|
|
|
end
|
|
|
|
end
|