-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(inspec): add tests for package, config & service
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
control 'ntp configuration' do | ||
title 'should match desired lines' | ||
|
||
config_file = '/etc/ntp.conf' | ||
owner, group, mode = | ||
case platform[:family] | ||
when 'suse' | ||
%w[root ntp 0640] | ||
else | ||
%w[root root 0644] | ||
end | ||
|
||
describe file(config_file) do | ||
it { should be_file } | ||
it { should be_owned_by owner } | ||
it { should be_grouped_into group } | ||
its('mode') { should cmp mode } | ||
its('content') { should include 'server 0.pool.ntp.org burst iburst' } | ||
its('content') { should include 'server 1.pool.ntp.org burst iburst' } | ||
its('content') { should include 'server 2.pool.ntp.org burst iburst' } | ||
its('content') { should include 'server 3.pool.ntp.org burst iburst' } | ||
its('content') { should include 'restrict 127.0.0.1' } | ||
its('content') { should include 'restrict ::1' } | ||
its('content') { should include 'driftfile /var/lib/ntp/ntp.drift' } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
control 'ntp package' do | ||
title 'should be installed' | ||
|
||
pkg = 'ntp' | ||
|
||
describe package(pkg) do | ||
it { should be_installed } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
service_name = | ||
case platform[:family] | ||
when 'debian' | ||
'ntp' | ||
else | ||
'ntpd' | ||
end | ||
|
||
control 'ntp service' do | ||
impact 0.5 | ||
title 'should be installed and enabled' | ||
|
||
describe service(service_name) do | ||
it { should be_installed } | ||
it { should be_enabled } | ||
it { should be_running } | ||
end | ||
end |