Skip to content

Commit cb29f9d

Browse files
committed
test: update all for FreeBSD
1 parent 946e2d0 commit cb29f9d

2 files changed

Lines changed: 62 additions & 19 deletions

File tree

test/integration/dev_server/controls/vault_spec.rb

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# frozen_string_literal: true
22

3+
config_json, service_cmd =
4+
case system.platform[:family]
5+
when 'bsd'
6+
['/usr/local/etc/vault/conf.d/config.json', 'service vault status']
7+
else
8+
['/etc/vault/conf.d/config.json', 'journalctl -u vault']
9+
end
10+
311
describe command('/usr/local/bin/vault -version') do
412
its(:exit_status) { should eq 0 }
513
its(:stderr) { should be_empty }
14+
# https://rubular.com/r/vVeCVuHAmtTYt3
615
its(:stdout) { should match(/^Vault v[0-9.]+ \('[0-9a-f]+'\)/) }
716
end
817

@@ -15,27 +24,40 @@
1524
describe file('/etc/init/vault.conf') do
1625
it { should be_a_file }
1726
end
27+
28+
describe file('/usr/local/etc/rc.d/vault') do
29+
it { should be_a_file }
30+
end
1831
end
1932

2033
describe service('vault') do
34+
it { should be_installed }
2135
it { should be_enabled }
2236
it { should be_running }
2337
end
2438

25-
describe file('/etc/vault/conf.d/config.json') do
39+
describe file(config_json) do
2640
it { should_not be_a_file }
2741
end
2842

29-
describe.one do
30-
describe command('journalctl -u vault') do
31-
its(:exit_status) { should eq 0 }
32-
its(:stderr) { should be_empty }
33-
its(:stdout) { should match(/WARNING! dev mode is enabled!/) }
43+
control 'vault.service' do
44+
title 'dev mode warning message should be displayed and logged'
45+
46+
only_if('Warning message is not displayed on FreeBSD') do
47+
!%w[freebsd].include?(system.platform[:name])
3448
end
3549

36-
describe file('/var/log/vault.log') do
37-
it { should be_a_file }
38-
its(:content) { should match(/WARNING! dev mode is enabled!/) }
50+
describe.one do
51+
describe command(service_cmd) do
52+
its(:exit_status) { should eq 0 }
53+
its(:stderr) { should be_empty }
54+
its(:stdout) { should match(/WARNING! dev mode is enabled!/) }
55+
end
56+
57+
describe file('/var/log/vault.log') do
58+
it { should be_a_file }
59+
its(:content) { should match(/WARNING! dev mode is enabled!/) }
60+
end
3961
end
4062
end
4163

test/integration/prod_server/controls/vault_spec.rb

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,42 @@
11
# frozen_string_literal: true
22

3+
config_json, service_cmd, path_to_etc_vault =
4+
case system.platform[:family]
5+
when 'bsd'
6+
['/usr/local/etc/vault/conf.d/config.json', 'service vault status',
7+
'/usr/local/etc/vault']
8+
else
9+
['/etc/vault/conf.d/config.json', 'journalctl -u vault', '/etc/vault']
10+
end
11+
312
describe command('/usr/local/bin/vault -version') do
413
its(:exit_status) { should eq 0 }
514
its(:stderr) { should be_empty }
615
# https://rubular.com/r/vVeCVuHAmtTYt3
716
its(:stdout) { should match(/^Vault v[0-9.]+ \('[0-9a-f]+'\)/) }
817
end
918

10-
describe command('getcap $(readlink -f /usr/local/bin/vault)') do
11-
its(:exit_status) { should eq 0 }
12-
its(:stderr) { should be_empty }
13-
# https://rubular.com/r/JApIMY1oNqGRZ8
14-
its(:stdout) { should match(%r{/vault\s?=? cap_ipc_lock[+=]ep$}) }
19+
control 'vault.package.install' do
20+
title 'Linux capabilities should be set'
21+
22+
only_if('`getcap` not available on FreeBSD') do
23+
!%w[freebsd].include?(system.platform[:name])
24+
end
25+
26+
describe command('getcap $(readlink -f /usr/local/bin/vault)') do
27+
its(:exit_status) { should eq 0 }
28+
its(:stderr) { should be_empty }
29+
# https://rubular.com/r/JApIMY1oNqGRZ8
30+
its(:stdout) { should match(%r{/vault\s?=? cap_ipc_lock[+=]ep$}) }
31+
end
1532
end
1633

1734
describe user('vault') do
1835
it { should exist }
1936
its('group') { should eq 'vault' }
2037
end
2138

22-
describe file('/etc/vault/conf.d/config.json') do
39+
describe file(config_json) do
2340
it { should be_a_file }
2441
its('owner') { should eq 'root' }
2542
its('group') { should eq 'vault' }
@@ -35,6 +52,10 @@
3552
describe file('/etc/init/vault.conf') do
3653
it { should be_a_file }
3754
end
55+
56+
describe file('/usr/local/etc/rc.d/vault') do
57+
it { should be_a_file }
58+
end
3859
end
3960

4061
describe service('vault') do
@@ -44,10 +65,10 @@
4465
end
4566

4667
describe.one do
47-
describe command('journalctl -u vault') do
68+
describe command(service_cmd) do
4869
its(:exit_status) { should eq 0 }
4970
its(:stderr) { should be_empty }
50-
its(:stdout) { should match(/Vault server started/) }
71+
its(:stdout) { should match(/Vault server started|vault is running as pid \d+/) }
5172
end
5273

5374
describe file('/var/log/vault.log') do
@@ -70,10 +91,10 @@
7091
its('sealed') { should eq true }
7192
end
7293

73-
describe file('/etc/vault/localhost.pem') do
94+
describe file("#{path_to_etc_vault}/localhost.pem") do
7495
it { should be_a_file }
7596
end
7697

77-
describe file('/etc/vault/localhost-nopass.key') do
98+
describe file("#{path_to_etc_vault}/localhost-nopass.key") do
7899
it { should be_a_file }
79100
end

0 commit comments

Comments
 (0)