mirror of
https://github.com/inspec/inspec
synced 2024-11-14 00:47:10 +00:00
84817366a1
* Add `release-2.0` target branch to AppVeyor/Travis (#2510) Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * simpleconfig: Remove deprecated config keys Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * cli (exec): Remove `--cache` command line argument Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * platform: Remove lowercase os name protection Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * matcher: Remove `contain_legacy_plus` matcher Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * matcher: Remove `contain_match` matcher Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * matcher: Remove `with_version` matcher Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * matcher: Remove `belong_to_group` matcher Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * matcher: Remove `belong_to_primary_group` matcher Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * matcher: Remove `contain` matcher Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * passwd: Remove deprecated properties This removes: - `passwd.count` - `passwd.username` - `passwd.usernames` - `passwd.uid` Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * auditd_rules: Remove in favor of `auditd` resource Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * cli: Remove `login_automate` command Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Remove `resource_skipped` message method Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
97 lines
2.8 KiB
Ruby
97 lines
2.8 KiB
Ruby
# encoding: utf-8
|
|
|
|
require 'helper'
|
|
require 'inspec/resource'
|
|
|
|
describe 'Inspec::Resources::Platform' do
|
|
let(:resource) { resource = MockLoader.new(:ubuntu1504).load_resource('platform') }
|
|
|
|
it 'verify platform parsing on Ubuntu' do
|
|
_(resource.name).must_equal 'ubuntu'
|
|
_(resource.family).must_equal 'debian'
|
|
_(resource.release).must_equal '15.04'
|
|
_(resource.arch).must_equal 'x86_64'
|
|
end
|
|
|
|
it 'verify platform hash parsing on Ubuntu' do
|
|
_(resource[:name]).must_equal 'ubuntu'
|
|
_(resource[:family]).must_equal 'debian'
|
|
_(resource[:release]).must_equal '15.04'
|
|
_(resource[:arch]).must_equal 'x86_64'
|
|
end
|
|
|
|
it 'verify platform families' do
|
|
expect = ["debian", "linux", "unix"]
|
|
_(resource.families).must_equal expect
|
|
end
|
|
|
|
it 'verify platform? responds correctly' do
|
|
_(resource.platform?('windows')).must_equal false
|
|
_(resource.platform?('unix')).must_equal true
|
|
_(resource.platform?('ubuntu')).must_equal true
|
|
_(resource.platform?('mac_os_x')).must_equal false
|
|
end
|
|
|
|
it 'verify family? responds correctly' do
|
|
_(resource.in_family?('windows')).must_equal false
|
|
_(resource.in_family?('unix')).must_equal true
|
|
_(resource.in_family?('ubuntu')).must_equal false
|
|
_(resource.in_family?('mac_os_x')).must_equal false
|
|
end
|
|
|
|
it 'verify supported? with multiple families' do
|
|
supports = [
|
|
{ os_family: 'windows' },
|
|
{ os_family: 'unix' }
|
|
]
|
|
resource.supported?(supports).must_equal true
|
|
end
|
|
|
|
it 'loads a profile which supports multiple names' do
|
|
supports = [
|
|
{ 'os-family': 'windows', 'os-name': 'windows_2000'},
|
|
{ 'os-family': 'unix', 'os-name': 'ubuntu' }
|
|
]
|
|
resource.supported?(supports).must_equal true
|
|
end
|
|
|
|
it 'reject a profile which supports multiple families' do
|
|
supports = [
|
|
{ os_family: 'windows' },
|
|
{ os_family: 'redhat' }
|
|
]
|
|
resource.supported?(supports).must_equal false
|
|
end
|
|
|
|
it 'loads a profile which supports release 15.04' do
|
|
supports = [
|
|
{ 'os-family': 'windows', 'os-name': 'windows_2000'},
|
|
{ 'os-name': 'ubuntu', 'release': '15.04'}
|
|
]
|
|
resource.supported?(supports).must_equal true
|
|
end
|
|
|
|
it 'loads a profile which supports release 15.*' do
|
|
supports = [
|
|
{ 'os-family': 'windows', 'os-name': 'windows_2000'},
|
|
{ 'os-name': 'ubuntu', 'release': '15.*'}
|
|
]
|
|
resource.supported?(supports).must_equal true
|
|
end
|
|
|
|
it 'loads a profile which supports release *.04' do
|
|
supports = [
|
|
{ 'os-family': 'windows', 'os-name': 'windows_2000'},
|
|
{ 'os-name': 'ubuntu', 'release': '*.04'}
|
|
]
|
|
resource.supported?(supports).must_equal true
|
|
end
|
|
|
|
it 'reject a profile which supports release 12.*' do
|
|
supports = [
|
|
{ 'os-family': 'windows', 'os-name': 'windows_2000'},
|
|
{ 'os-name': 'ubuntu', 'release': '12.*'}
|
|
]
|
|
resource.supported?(supports).must_equal false
|
|
end
|
|
end
|