From 251937f9c341d7952abd21e866dc4122a7254360 Mon Sep 17 00:00:00 2001 From: Eric Veiras Galisson Date: Thu, 12 Jul 2018 12:09:45 +0200 Subject: [PATCH] adding Inspec tests for jobs configuration --- .../controls/{logrotate.rb => base.rb} | 0 test/integration/default/controls/jobs.rb | 53 +++++++++++++++++++ test/integration/default/inspec.yml | 4 +- 3 files changed, 55 insertions(+), 2 deletions(-) rename test/integration/default/controls/{logrotate.rb => base.rb} (100%) create mode 100644 test/integration/default/controls/jobs.rb diff --git a/test/integration/default/controls/logrotate.rb b/test/integration/default/controls/base.rb similarity index 100% rename from test/integration/default/controls/logrotate.rb rename to test/integration/default/controls/base.rb diff --git a/test/integration/default/controls/jobs.rb b/test/integration/default/controls/jobs.rb new file mode 100644 index 0000000..11d8a50 --- /dev/null +++ b/test/integration/default/controls/jobs.rb @@ -0,0 +1,53 @@ +# encoding: utf-8 + +title 'Test logrotate jobs configuration' + +describe file('/etc/logrotate.d/error') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + its('mode') { should cmp '0644' } + # FIXME + #its('content') { should include '/tmp/var/log/mysql/error' } + its('content') { should include 'weekly' } + its('content') { should include 'missingok' } + its('content') { should include 'rotate 52' } + its('content') { should include 'compress' } + its('content') { should include 'delaycompress' } + its('content') { should include 'notifempty' } + its('content') { should include 'create 640 root adm' } + its('content') { should include 'sharedscripts' } +end + +describe file('/etc/logrotate.d/mysql') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + its('mode') { should cmp '0644' } + its('content') { should include '/tmp/var/log/mysql/*.log' } + its('content') { should include 'weekly' } + its('content') { should include 'missingok' } + its('content') { should include 'rotate 52' } + its('content') { should include 'compress' } + its('content') { should include 'delaycompress' } + its('content') { should include 'notifempty' } + its('content') { should include 'create 640 root adm' } + its('content') { should include 'sharedscripts' } +end + +describe file('/etc/logrotate.d/syslog') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + its('mode') { should cmp '0644' } + its('content') { should include '/var/log/cron' } + its('content') { should include '/var/log/maillog' } + its('content') { should include '/var/log/messages' } + its('content') { should include '/var/log/secure' } + its('content') { should include '/var/log/spooler' } + its('content') { should include '/var/log/slapd.log' } + its('content') { should include 'sharedscripts' } + its('content') { should include 'postrotate' } + its('content') { should include 'sharedscripts' } +end + diff --git a/test/integration/default/inspec.yml b/test/integration/default/inspec.yml index b062685..1096184 100644 --- a/test/integration/default/inspec.yml +++ b/test/integration/default/inspec.yml @@ -1,5 +1,5 @@ -name: shorewall -title: Shorewall Profile +name: logrotate +title: Logrotate Profile maintainer: Eric Veiras Galisson copyright: Eric Veiras Galisson copyright_email: eric AT sietch-tabr DOT com