|
1 | | -# Temporary `if` due to `opensuse-leap-15` bug re: `service` |
2 | | -if os[:name] == 'suse' |
3 | | - puts "[Skip `service`-based tests due to `opensuse-leap-15` detection bug (see https://github.com/inspec/train/issues/377)]" |
4 | | -else |
5 | | - |
6 | | - control 'OpenVPN service' do |
7 | | - impact 0.5 |
8 | | - title 'should be running and enabled' |
9 | | - |
10 | | - # single service |
11 | | - if os[:name] == 'centos' and os[:release].start_with?('6') |
12 | | - describe service("openvpn") do |
13 | | - it { should be_enabled } |
14 | | - it { should be_running } |
15 | | - end |
| 1 | +control 'OpenVPN service' do |
| 2 | + impact 0.5 |
| 3 | + title 'should be running and enabled' |
| 4 | + |
| 5 | + # single service |
| 6 | + if os[:name] == 'centos' and os[:release].start_with?('6') |
| 7 | + describe service("openvpn") do |
| 8 | + it { should be_enabled } |
| 9 | + it { should be_running } |
| 10 | + end |
16 | 11 |
|
17 | | - # multiple services |
18 | | - else |
19 | | - %w(server client).each do |role| |
| 12 | + # multiple services |
| 13 | + else |
| 14 | + %w(server client).each do |role| |
20 | 15 |
|
21 | | - prefix = case os[:name] |
22 | | - when 'fedora' then "openvpn-#{role}" |
23 | | - else 'openvpn' |
24 | | - end |
| 16 | + prefix = case os[:name] |
| 17 | + when 'fedora' then "openvpn-#{role}" |
| 18 | + else 'openvpn' |
| 19 | + end |
25 | 20 |
|
26 | | - describe service("#{prefix}@my#{role}1.service") do |
27 | | - it { should be_enabled } |
28 | | - it { should be_running } |
29 | | - end |
| 21 | + describe service("#{prefix}@my#{role}1.service") do |
| 22 | + it { should be_enabled } |
| 23 | + it { should be_running } |
30 | 24 | end |
31 | 25 | end |
| 26 | + end |
32 | 27 |
|
33 | | - %w(server client).each do |role| |
34 | | - logfile = "/var/log/openvpn/my#{role}1.log" |
| 28 | + %w(server client).each do |role| |
| 29 | + logfile = "/var/log/openvpn/my#{role}1.log" |
35 | 30 |
|
36 | | - describe command("sh -c 'for i in $(seq 1 60); do if grep \"Initialization Sequence Completed\" #{logfile}; then exit 0; fi; echo -n '.'; sleep 1; done; cat #{logfile}; exit 1'") do |
37 | | - its('exit_status') { should be 0 } |
38 | | - its('stdout') { should include "Initialization Sequence Completed" } |
39 | | - end |
| 31 | + describe command("sh -c 'for i in $(seq 1 60); do if grep \"Initialization Sequence Completed\" #{logfile}; then exit 0; fi; echo -n '.'; sleep 1; done; cat #{logfile}; exit 1'") do |
| 32 | + its('exit_status') { should be 0 } |
| 33 | + its('stdout') { should include "Initialization Sequence Completed" } |
40 | 34 | end |
41 | 35 | end |
42 | | - |
43 | 36 | end |
0 commit comments