Skip to content

Commit

Permalink
test(default): replace Serverspec with InSpec testing
Browse files Browse the repository at this point in the history
  • Loading branch information
myii committed Jan 14, 2022
1 parent ef4d7ab commit 72115be
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 6 deletions.
33 changes: 33 additions & 0 deletions test/integration/default/controls/config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

control 'snmp.config.file' do
title 'Verify the configuration file'

# Overide by platform family
config_file, root_group =
case platform[:family]
when 'bsd'
%w[/usr/local/etc/snmp/snmpd.conf wheel]
else
%w[/etc/snmp/snmpd.conf root]
end

describe file(config_file) do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into root_group }
its('mode') { should cmp '0644' }
its('content') { should include 'syslocation Right Here' }
its('content') { should include 'syscontact System Admin' }
its('content') { should include 'dontLogTCPWrappersConnects yes' }
its('content') { should include 'view all included .1 80' }
its('content') { should include 'rocommunity public localhost' }
its('content') { should include 'rocommunity public 192.168.0.0/24' }
its('content') { should include 'rocommunity public 192.168.1.0/24' }
its('content') { should include 'rwcommunity private 192.168.1.0/24' }
its('content') { should include 'rouser myv3user auth -V all' }
its('content') do
should include 'createUser myv3user SHA myv3password AES v3privpass'
end
end
end
20 changes: 20 additions & 0 deletions test/integration/default/controls/packages.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

control 'snmp.package.install' do
title 'The required package should be installed'

# Overide by platform family
package_name =
case system.platform[:family]
when 'debian'
'snmpd'
when 'gentoo'
'net-analyzer/net-snmp'
else
'net-snmp'
end

describe package(package_name) do
it { should be_installed }
end
end
13 changes: 13 additions & 0 deletions test/integration/default/controls/services.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

control 'snmp.service.running' do
title 'The service should be installed, enabled and running'

service_name = 'snmpd'

describe service(service_name) do
it { should be_installed }
it { should be_enabled }
it { should be_running }
end
end
6 changes: 0 additions & 6 deletions test/integration/default/serverspec/snmp_spec.rb

This file was deleted.

0 comments on commit 72115be

Please sign in to comment.