Skip to content

Commit

Permalink
test(inspec): provide tests for the repo package and config
Browse files Browse the repository at this point in the history
  • Loading branch information
myii committed Nov 3, 2019
1 parent 1892879 commit 35b98d5
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/integration/default/controls/config_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

control 'epel repo configuration' do
title 'should match desired lines'

epel_version =
case platform[:name]
when 'amazon'
case platform[:release]
when '2'
'7'
when '2018.03'
'6'
end
when 'centos'
platform[:release][0]
end

describe file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-#{epel_version}") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
end
end
30 changes: 30 additions & 0 deletions test/integration/default/controls/packages_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

control 'epel package' do
title 'should be installed'

pkg = 'epel-release'
version =
case platform[:name]
when 'amazon'
case platform[:release]
when '2'
'7-12'
when '2018.03'
'6-8'
end
when 'centos'
if platform[:release].start_with?('8')
'8-7.el8'
elsif platform[:release].start_with?('7')
'7-12'
elsif platform[:release].start_with?('6')
'6-8'
end
end

describe package(pkg) do
it { should be_installed }
its('version') { should eq version }
end
end

0 comments on commit 35b98d5

Please sign in to comment.