Skip to content

Commit fa1dac8

Browse files
author
Michael Chmielewski
committed
Added serverspec tests to validate formula. CentOS 7 and Debian 8 are still not functioning.
1 parent 0475a79 commit fa1dac8

File tree

6 files changed

+71
-18
lines changed

6 files changed

+71
-18
lines changed

.kitchen.yml

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,25 @@ provisioner:
88
is_file_root: true
99
# Use this section (and comment out the `threatstack.sls` definition in the `pillars` section)
1010
# to grab pillar data from the `pillar.example` file
11-
pillars_from_files:
12-
threatstack.sls: pillar.example
11+
# pillars_from_files:
12+
# threatstack.sls: pillar.example
1313
pillars:
1414
top.sls:
1515
base:
1616
'*':
1717
- threatstack
1818
# Use this section (and comment out the `pillars_from_files` section)
1919
# to grab pillar data from environment variables
20-
# threatstack.sls:
21-
# deploy_key: <%= ENV['TS_DEPLOY_KEY'] != nil ? ENV['TS_DEPLOY_KEY'] : 'ts_deploy_key' %>
22-
# ts_agent_version: <%= ENV['TS_PACKAGE_VERSION'] %>
23-
# <% if ENV['TS_CONFIG_ARGS'] %>
24-
# ts_agent_config_args: <%= ENV['TS_CONFIG_ARGS'] %>
25-
# <% end %>
26-
# ts_agent_version: <%= ENV['TS_PACKAGE_VERSION'] %>
27-
# ts_configure_agent: <%= ENV['TS_CONFIGURE_AGENT'] %>
28-
# ts_agent_latest: <%= ENV['TS_AGENT_LATEST'] %>
29-
# <% if ENV['TS_SETUP_ARGS'] %>
30-
# ts_agent_extra_args: <%= ENV['TS_SETUP_ARGS'] %>
31-
# <% end %>
20+
threatstack.sls:
21+
deploy_key: <%= ENV['TS_DEPLOY_KEY'] != nil ? ENV['TS_DEPLOY_KEY'] : 'ts_deploy_key' %>
22+
ts_agent_version: <%= ENV['TS_PACKAGE_VERSION'] %>
23+
ts_configure_agent: <%= ENV['TS_CONFIGURE_AGENT'] %>
24+
<% if ENV['TS_SETUP_ARGS'] %>
25+
ts_agent_extra_args: <%= ENV['TS_SETUP_ARGS'] %>
26+
<% end %>
27+
<% if ENV['TS_CONFIG_ARGS'] %>
28+
ts_agent_config_args: <%= ENV['TS_CONFIG_ARGS'] %>
29+
<% end %>
3230
state_top:
3331
base:
3432
'*':
@@ -45,6 +43,8 @@ platforms:
4543
volume:
4644
- /sys/fs/cgroup:/sys/fs/cgroup
4745
provision_command:
46+
- yum install -y ruby24
47+
- alternatives --set ruby /usr/bin/ruby2.4
4848
- yum install -y audit initscripts
4949
- sed -i 's/local_events = yes/local_events = no/g' /etc/audit/auditd.conf
5050
- chkconfig auditd on
@@ -58,6 +58,10 @@ platforms:
5858
volume:
5959
- /sys/fs/cgroup:/sys/fs/cgroup
6060
provision_command:
61+
- amazon-linux-extras install ruby2.6
62+
- yum install -y ruby-devel gcc make
63+
- gem install io-console --install-dir=/tmp/verifier/gems
64+
- chown -R kitchen:kitchen /tmp/verifier
6165
- yum install -y audit initscripts
6266
- sed -i 's/local_events = yes/local_events = no/g' /etc/audit/auditd.conf
6367
- systemctl enable auditd.service
@@ -72,9 +76,20 @@ platforms:
7276
volume:
7377
- /sys/fs/cgroup:/sys/fs/cgroup
7478
provision_command:
79+
- yum install -y ruby ruby-devel git
80+
- yum install -y centos-release-scl-rh
81+
- yum install -y rh-ruby24
82+
# - source /opt/rh/rh-ruby24/enable
83+
- |
84+
printf "\n\
85+
\n\
86+
source /opt/rh/rh-ruby24/enable \n\
87+
export X_SCLS=\"`scl enable rh-ruby24 'echo $X_SCLS'`\"\n"\
88+
>> /etc/bashrc
7589
- yum install -y audit initscripts
7690
- sed -i 's/local_events = yes/local_events = no/g' /etc/audit/auditd.conf
7791
- systemctl enable auditd.service
92+
- scl enable rh-ruby24 bash
7893
- name: centos-8
7994
image: centos:8
8095
driver_config:
@@ -166,7 +181,11 @@ platforms:
166181
provision_command:
167182
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
168183
- systemctl enable ssh.service
169-
# - name: amazonlinux-2
170184

171185
suites:
172186
- name: default
187+
- name: custom
188+
provisioner:
189+
pillars:
190+
threatstack.sls:
191+
ts_agent_config_args: "--set log.maxSize 22"

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ group :development, :unit_tests do
44
gem 'rake', :require => false
55
end
66
group :system_tests do
7-
gem 'serverspec', :require => false
7+
gem 'busser-serverspec', :require => false
8+
gem 'serverspec', :require => false
89
gem 'test-kitchen', :require => false
910
gem 'kitchen-salt', :require => false
1011
gem 'kitchen-docker', :require => false

pillar.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
deploy_key: "xxxx-xxxx-your-secret-key-xxxx"
2-
ts_configure_agent: True
32
ts_agent_version: 2.3.0*
4-
ts_agent_config_args: '--set log.level info'
3+
ts_configure_agent: True
54
ts_agent_extra_args: ''
5+
ts_agent_config_args: ''

test/integration/.DS_Store

6 KB
Binary file not shown.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'serverspec'
2+
3+
set :backend, :exec
4+
5+
describe package('threatstack-agent') do
6+
it { should be_installed }
7+
end
8+
9+
describe service('threatstack') do
10+
it { should be_running }
11+
it { should be_enabled }
12+
end
13+
14+
describe command('tsagent config --list') do
15+
its(:stdout) { should match /log.maxSize=22/ } # rubocop: disable Lint/AmbiguousRegexpLiteral
16+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'serverspec'
2+
3+
set :backend, :exec
4+
5+
describe package('threatstack-agent') do
6+
it { should be_installed }
7+
end
8+
9+
describe service('threatstack') do
10+
it { should be_running }
11+
it { should be_enabled }
12+
end
13+
14+
describe command('tsagent status') do
15+
# Sometimes due to other services, like auditd, the install would be successful, but then this service would get killed
16+
its(:stdout) { should match /UP Threat Stack Audit Collection/ } # rubocop: disable Lint/AmbiguousRegexpLiteral
17+
end

0 commit comments

Comments
 (0)