Merge pull request #1209 from artem-sidorenko/linuxmint

Support of Linux Mint
This commit is contained in:
Dominik Richter 2016-10-10 05:38:58 -07:00 committed by GitHub
commit 2631b3f7a9
6 changed files with 97 additions and 1 deletions

View file

@ -120,6 +120,13 @@ module Inspec::Resources
else
Systemd.new(inspec, service_ctl)
end
elsif %w{linuxmint}.include?(platform)
version = os[:release].to_f
if version < 18
Upstart.new(inspec, service_ctl)
else
Systemd.new(inspec, service_ctl)
end
elsif %w{debian}.include?(platform)
version = os[:release].to_i
if version > 7

View file

@ -49,6 +49,8 @@ class MockLoader
ubuntu1204: { name: 'ubuntu', family: 'debian', release: '12.04', arch: 'x86_64' },
ubuntu1404: { name: 'ubuntu', family: 'debian', release: '14.04', arch: 'x86_64' },
ubuntu1504: { name: 'ubuntu', family: 'debian', release: '15.04', arch: 'x86_64' },
mint17: { name: 'linuxmint', family: 'debian', release: '17.3', arch: 'x86_64' },
mint18: { name: 'linuxmint', family: 'debian', release: '18', arch: 'x86_64' },
windows: { name: 'windows', family: 'windows', release: '6.2.9200', arch: 'x86_64' },
wrlinux: { name: 'wrlinux', family: 'redhat', release: '7.0(3)I2(2)', arch: 'x86_64' },
solaris11: { name: "solaris", family: 'solaris', release: '11', arch: 'i386'},

View file

@ -25,8 +25,26 @@ describe 'Inspec::Resources::AptRepo' do
_(resource.enabled?).must_equal true
end
it 'check apt on mint' do
resource = MockLoader.new(:mint18).load_resource('apt', 'http://archive.ubuntu.com/ubuntu/')
_(resource.exists?).must_equal true
_(resource.enabled?).must_equal true
end
it 'check apt on mint with ppa' do
resource = MockLoader.new(:mint18).load_resource('apt', 'ubuntu-wine/ppa')
_(resource.exists?).must_equal true
_(resource.enabled?).must_equal true
end
it 'check apt on mint with ppa' do
resource = MockLoader.new(:mint18).load_resource('apt', 'ppa:ubuntu-wine/ppa')
_(resource.exists?).must_equal true
_(resource.enabled?).must_equal true
end
it 'check apt on debian' do
resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'http://archive.ubuntu.com/ubuntu/')
resource = MockLoader.new(:debian8).load_resource('apt', 'http://archive.ubuntu.com/ubuntu/')
_(resource.exists?).must_equal true
_(resource.enabled?).must_equal true
end

View file

@ -37,4 +37,12 @@ describe 'Inspec::Resources::Os' do
_(resource.release).must_equal '15.04'
_(resource.arch).must_equal 'x86_64'
end
it 'verify os parsing on Mint' do
resource = MockLoader.new(:mint18).load_resource('os')
_(resource.name).must_equal 'linuxmint'
_(resource.family).must_equal 'debian'
_(resource.release).must_equal '18'
_(resource.arch).must_equal 'x86_64'
end
end

View file

@ -24,6 +24,15 @@ describe 'Inspec::Resources::Package' do
_(resource.info).must_equal pkg
end
# mint
it 'verify mint package parsing' do
resource = MockLoader.new(:mint17).load_resource('package', 'curl')
pkg = { name: 'curl', installed: true, version: '7.35.0-1ubuntu2', type: 'deb' }
_(resource.installed?).must_equal true
_(resource.version).must_equal '7.35.0-1ubuntu2'
_(resource.info).must_equal pkg
end
# centos
it 'verify centos package parsing' do
resource = MockLoader.new(:centos7).load_resource('package', 'curl')

View file

@ -75,6 +75,58 @@ describe 'Inspec::Resources::Service' do
_(resource.params).must_equal params
end
# linux mint 17 with upstart
it 'verify mint package parsing' do
resource = MockLoader.new(:mint17).load_resource('service', 'ssh')
params = Hashie::Mash.new({})
_(resource.type).must_equal 'upstart'
_(resource.name).must_equal 'ssh'
_(resource.description).must_equal nil
_(resource.installed?).must_equal true
_(resource.enabled?).must_equal true
_(resource.running?).must_equal true
_(resource.params).must_equal params
end
it 'verify mint package parsing with default upstart_service' do
resource = MockLoader.new(:mint17).load_resource('upstart_service', 'ssh')
params = Hashie::Mash.new({})
_(resource.type).must_equal 'upstart'
_(resource.name).must_equal 'ssh'
_(resource.description).must_equal nil
_(resource.installed?).must_equal true
_(resource.enabled?).must_equal true
_(resource.running?).must_equal true
_(resource.params).must_equal params
_(resource.params.UnitFileState).must_equal nil
end
# mint 18 with systemd
it 'verify mint package parsing' do
resource = MockLoader.new(:mint18).load_resource('service', 'sshd')
params = Hashie::Mash.new({ 'ActiveState' => 'active', 'Description' => 'OpenSSH server daemon', 'Id' => 'sshd.service', 'LoadState' => 'loaded', 'Names' => 'sshd.service', 'SubState' => 'running', 'UnitFileState' => 'enabled' })
_(resource.type).must_equal 'systemd'
_(resource.name).must_equal 'sshd.service'
_(resource.description).must_equal 'OpenSSH server daemon'
_(resource.installed?).must_equal true
_(resource.enabled?).must_equal true
_(resource.running?).must_equal true
_(resource.params).must_equal params
_(resource.params.SubState).must_equal 'running'
end
it 'verify mint package parsing with default systemd_service' do
resource = MockLoader.new(:mint18).load_resource('systemd_service', 'sshd')
params = Hashie::Mash.new({ 'ActiveState' => 'active', 'Description' => 'OpenSSH server daemon', 'Id' => 'sshd.service', 'LoadState' => 'loaded', 'Names' => 'sshd.service', 'SubState' => 'running', 'UnitFileState' => 'enabled' })
_(resource.type).must_equal 'systemd'
_(resource.name).must_equal 'sshd.service'
_(resource.description).must_equal 'OpenSSH server daemon'
_(resource.installed?).must_equal true
_(resource.enabled?).must_equal true
_(resource.running?).must_equal true
_(resource.params).must_equal params
end
# centos 6 with sysv
it 'verify centos 6 package parsing' do
resource = MockLoader.new(:centos6).load_resource('service', 'sshd')