|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
| 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 | + |
3 | 12 | describe command('/usr/local/bin/vault -version') do |
4 | 13 | its(:exit_status) { should eq 0 } |
5 | 14 | its(:stderr) { should be_empty } |
6 | 15 | # https://rubular.com/r/vVeCVuHAmtTYt3 |
7 | 16 | its(:stdout) { should match(/^Vault v[0-9.]+ \('[0-9a-f]+'\)/) } |
8 | 17 | end |
9 | 18 |
|
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 |
15 | 32 | end |
16 | 33 |
|
17 | 34 | describe user('vault') do |
18 | 35 | it { should exist } |
19 | 36 | its('group') { should eq 'vault' } |
20 | 37 | end |
21 | 38 |
|
22 | | -describe file('/etc/vault/conf.d/config.json') do |
| 39 | +describe file(config_json) do |
23 | 40 | it { should be_a_file } |
24 | 41 | its('owner') { should eq 'root' } |
25 | 42 | its('group') { should eq 'vault' } |
|
35 | 52 | describe file('/etc/init/vault.conf') do |
36 | 53 | it { should be_a_file } |
37 | 54 | end |
| 55 | + |
| 56 | + describe file('/usr/local/etc/rc.d/vault') do |
| 57 | + it { should be_a_file } |
| 58 | + end |
38 | 59 | end |
39 | 60 |
|
40 | 61 | describe service('vault') do |
|
44 | 65 | end |
45 | 66 |
|
46 | 67 | describe.one do |
47 | | - describe command('journalctl -u vault') do |
| 68 | + describe command(service_cmd) do |
48 | 69 | its(:exit_status) { should eq 0 } |
49 | 70 | 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+/) } |
51 | 72 | end |
52 | 73 |
|
53 | 74 | describe file('/var/log/vault.log') do |
|
70 | 91 | its('sealed') { should eq true } |
71 | 92 | end |
72 | 93 |
|
73 | | -describe file('/etc/vault/localhost.pem') do |
| 94 | +describe file("#{path_to_etc_vault}/localhost.pem") do |
74 | 95 | it { should be_a_file } |
75 | 96 | end |
76 | 97 |
|
77 | | -describe file('/etc/vault/localhost-nopass.key') do |
| 98 | +describe file("#{path_to_etc_vault}/localhost-nopass.key") do |
78 | 99 | it { should be_a_file } |
79 | 100 | end |
0 commit comments