serverspec 0.6.16 → 0.6.17
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/serverspec/backend/exec.rb +16 -0
- data/lib/serverspec/commands/base.rb +9 -1
- data/lib/serverspec/helper/configuration.rb +1 -0
- data/lib/serverspec/type/service.rb +9 -1
- data/lib/serverspec/version.rb +1 -1
- data/spec/backend/exec/configuration_spec.rb +12 -8
- data/spec/backend/ssh/configuration_spec.rb +21 -14
- data/spec/darwin/command_spec.rb +41 -6
- data/spec/darwin/commands_spec.rb +1 -8
- data/spec/darwin/cron_spec.rb +16 -3
- data/spec/darwin/default_gateway_spec.rb +11 -2
- data/spec/darwin/host_spec.rb +52 -6
- data/spec/darwin/port_spec.rb +7 -2
- data/spec/darwin/routing_table_spec.rb +115 -2
- data/spec/darwin/service_spec.rb +2 -0
- data/spec/debian/command_spec.rb +41 -6
- data/spec/debian/commands_spec.rb +5 -11
- data/spec/debian/cron_spec.rb +16 -3
- data/spec/debian/default_gateway_spec.rb +11 -2
- data/spec/debian/host_spec.rb +52 -6
- data/spec/debian/interface_spec.rb +9 -2
- data/spec/debian/iptables_spec.rb +16 -3
- data/spec/debian/linux_kernel_parameter_spec.rb +31 -4
- data/spec/debian/port_spec.rb +7 -2
- data/spec/debian/routing_table_spec.rb +115 -2
- data/spec/debian/service_spec.rb +3 -0
- data/spec/gentoo/command_spec.rb +41 -6
- data/spec/gentoo/commands_spec.rb +1 -11
- data/spec/gentoo/cron_spec.rb +16 -3
- data/spec/gentoo/default_gateway_spec.rb +11 -2
- data/spec/gentoo/host_spec.rb +52 -6
- data/spec/gentoo/interface_spec.rb +9 -2
- data/spec/gentoo/iptables_spec.rb +16 -3
- data/spec/gentoo/linux_kernel_parameter_spec.rb +31 -4
- data/spec/gentoo/port_spec.rb +7 -2
- data/spec/gentoo/routing_table_spec.rb +120 -0
- data/spec/gentoo/service_spec.rb +2 -0
- data/spec/redhat/command_spec.rb +41 -6
- data/spec/redhat/commands_spec.rb +5 -11
- data/spec/redhat/cron_spec.rb +16 -3
- data/spec/redhat/default_gateway_spec.rb +11 -2
- data/spec/redhat/host_spec.rb +52 -6
- data/spec/redhat/interface_spec.rb +9 -2
- data/spec/redhat/iptables_spec.rb +16 -3
- data/spec/redhat/linux_kernel_parameter_spec.rb +31 -4
- data/spec/redhat/port_spec.rb +7 -2
- data/spec/redhat/routing_table_spec.rb +115 -2
- data/spec/redhat/service_spec.rb +3 -0
- data/spec/smartos/commands_spec.rb +1 -30
- data/spec/solaris/command_spec.rb +41 -6
- data/spec/solaris/commands_spec.rb +1 -35
- data/spec/solaris/cron_spec.rb +16 -3
- data/spec/solaris/default_gateway_spec.rb +11 -2
- data/spec/solaris/host_spec.rb +52 -6
- data/spec/solaris/port_spec.rb +7 -2
- data/spec/solaris/routing_table_spec.rb +115 -2
- data/spec/solaris/service_spec.rb +2 -0
- data/spec/spec_helper.rb +36 -2
- data/spec/support/shared_commands_examples.rb +11 -69
- data/spec/support/shared_service_examples.rb +48 -0
- metadata +4 -20
- data/spec/support/shared_command_examples.rb +0 -77
- data/spec/support/shared_cron_examples.rb +0 -23
- data/spec/support/shared_default_gateway_examples.rb +0 -13
- data/spec/support/shared_host_examples.rb +0 -53
- data/spec/support/shared_interface_examples.rb +0 -12
- data/spec/support/shared_iptables_examples.rb +0 -23
- data/spec/support/shared_linux_kernel_parameter_examples.rb +0 -41
- data/spec/support/shared_port_examples.rb +0 -11
- data/spec/support/shared_routing_table_examples.rb +0 -118
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::Gentoo
|
4
|
+
|
5
|
+
describe routing_table do
|
6
|
+
let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
|
7
|
+
it { should have_entry( :destination => '192.168.100.0/24' ) }
|
8
|
+
its(:command) { should eq "ip route | grep -E '^192.168.100.0/24 |^default '" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe routing_table do
|
12
|
+
let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
|
13
|
+
it { should_not have_entry( :destination => '192.168.100.100/24' ) }
|
14
|
+
its(:command) { should eq "ip route | grep -E '^192.168.100.100/24 |^default '" }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe routing_table do
|
18
|
+
let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
|
19
|
+
it do
|
20
|
+
should have_entry(
|
21
|
+
:destination => '192.168.100.0/24',
|
22
|
+
:gateway => '192.168.100.1'
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
it do
|
27
|
+
should have_entry(
|
28
|
+
:destination => '192.168.100.0/24',
|
29
|
+
:gateway => '192.168.100.1',
|
30
|
+
:interface => 'eth1'
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
it do
|
35
|
+
should_not have_entry(
|
36
|
+
:gateway => '192.168.100.1',
|
37
|
+
:interface => 'eth1'
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
it do
|
42
|
+
should_not have_entry(
|
43
|
+
:destination => '192.168.100.0/32',
|
44
|
+
:gateway => '192.168.100.1',
|
45
|
+
:interface => 'eth1'
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe routing_table do
|
51
|
+
let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
|
52
|
+
it { should have_entry( :destination => '192.168.200.0/24' ) }
|
53
|
+
it { should_not have_entry( :destination => '192.168.200.200/24' ) }
|
54
|
+
|
55
|
+
it do
|
56
|
+
should have_entry(
|
57
|
+
:destination => '192.168.200.0/24',
|
58
|
+
:gateway => '192.168.200.1'
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
it do
|
63
|
+
should have_entry(
|
64
|
+
:destination => '192.168.200.0/24',
|
65
|
+
:gateway => '192.168.200.1',
|
66
|
+
:interface => 'eth0'
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
it do
|
71
|
+
should_not have_entry(
|
72
|
+
:gateway => '192.168.200.1',
|
73
|
+
:interface => 'eth0'
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
it do
|
78
|
+
should_not have_entry(
|
79
|
+
:destination => '192.168.200.0/32',
|
80
|
+
:gateway => '192.168.200.1',
|
81
|
+
:interface => 'eth0'
|
82
|
+
)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe routing_table do
|
87
|
+
let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" }
|
88
|
+
it { should have_entry( :destination => 'default' ) }
|
89
|
+
it { should_not have_entry( :destination => 'defaulth' ) }
|
90
|
+
|
91
|
+
it do
|
92
|
+
should have_entry(
|
93
|
+
:destination => 'default',
|
94
|
+
:gateway => '10.0.2.2'
|
95
|
+
)
|
96
|
+
end
|
97
|
+
|
98
|
+
it do
|
99
|
+
should have_entry(
|
100
|
+
:destination => 'default',
|
101
|
+
:gateway => '10.0.2.2',
|
102
|
+
:interface => 'eth0'
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
it do
|
107
|
+
should_not have_entry(
|
108
|
+
:gateway => '10.0.2.2',
|
109
|
+
:interface => 'eth0'
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
it do
|
114
|
+
should_not have_entry(
|
115
|
+
:destination => 'default',
|
116
|
+
:gateway => '10.0.2.1',
|
117
|
+
:interface => 'eth0'
|
118
|
+
)
|
119
|
+
end
|
120
|
+
end
|
data/spec/gentoo/service_spec.rb
CHANGED
@@ -8,4 +8,6 @@ describe 'Serverspec service matchers of Gentoo family' do
|
|
8
8
|
it_behaves_like 'support service running matcher', 'sshd'
|
9
9
|
it_behaves_like 'support service running under supervisor matcher', 'sshd'
|
10
10
|
it_behaves_like 'support service running under unimplemented matcher', 'sshd'
|
11
|
+
it_behaves_like 'support service monitored by monit matcher', 'unicorn'
|
12
|
+
it_behaves_like 'support service monitored by unimplemented matcher', 'unicorn'
|
11
13
|
end
|
data/spec/redhat/command_spec.rb
CHANGED
@@ -2,12 +2,47 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::RedHat
|
4
4
|
|
5
|
-
describe '
|
6
|
-
|
7
|
-
|
5
|
+
describe command('cat /etc/resolv.conf') do
|
6
|
+
let(:stdout) { "nameserver 127.0.0.1\r\n" }
|
7
|
+
it { should return_stdout("nameserver 127.0.0.1") }
|
8
|
+
its(:command) { should eq 'cat /etc/resolv.conf' }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'complete matching of stdout' do
|
12
|
+
context command('cat /etc/resolv.conf') do
|
13
|
+
let(:stdout) { "foocontent-should-be-includedbar\r\n" }
|
14
|
+
it { should_not return_stdout('content-should-be-included') }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'regexp matching of stdout' do
|
19
|
+
context command('cat /etc/resolv.conf') do
|
20
|
+
let(:stdout) { "nameserver 127.0.0.1\r\n" }
|
21
|
+
it { should return_stdout(/127\.0\.0\.1/) }
|
22
|
+
end
|
23
|
+
end
|
8
24
|
|
9
|
-
|
10
|
-
|
25
|
+
describe command('cat /etc/resolv.conf') do
|
26
|
+
let(:stdout) { "No such file or directory\r\n" }
|
27
|
+
it { should return_stderr("No such file or directory") }
|
28
|
+
its(:command) { should eq 'cat /etc/resolv.conf' }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'complete matching of stderr' do
|
32
|
+
context command('cat /etc/resolv.conf') do
|
33
|
+
let(:stdout) { "No such file or directory\r\n" }
|
34
|
+
it { should_not return_stdout('file') }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'regexp matching of stderr' do
|
39
|
+
context command('cat /etc/resolv.conf') do
|
40
|
+
let(:stdout) { "No such file or directory\r\n" }
|
41
|
+
it { should return_stderr(/file/) }
|
42
|
+
end
|
43
|
+
end
|
11
44
|
|
12
|
-
|
45
|
+
describe command('cat /etc/resolv.conf') do
|
46
|
+
it { should return_exit_status 0 }
|
47
|
+
its(:command) { should eq 'cat /etc/resolv.conf' }
|
13
48
|
end
|
@@ -18,18 +18,17 @@ describe 'Serverspec commands of Red Hat' do
|
|
18
18
|
|
19
19
|
it_behaves_like 'support command check_mounted', '/'
|
20
20
|
|
21
|
-
it_behaves_like 'support command check_routing_table', '192.168.100.1/24'
|
22
|
-
it_behaves_like 'support command check_reachable'
|
23
|
-
it_behaves_like 'support command check_resolvable'
|
24
|
-
|
25
21
|
it_behaves_like 'support command check_user', 'root'
|
26
22
|
it_behaves_like 'support command check_user', 'wheel'
|
27
23
|
|
28
|
-
it_behaves_like 'support command check_listening', 80
|
29
|
-
|
30
24
|
it_behaves_like 'support command check_file_md5checksum', '/etc/passewd', '96c8c50f81a29965f7af6de371ab4250'
|
31
25
|
|
32
26
|
it_behaves_like 'support command check_running_under_supervisor', 'httpd'
|
27
|
+
|
28
|
+
it_behaves_like 'support command check_running_under_upstart', 'monit'
|
29
|
+
|
30
|
+
it_behaves_like 'support command check_monitored_by_monit', 'unicorn'
|
31
|
+
|
33
32
|
it_behaves_like 'support command check_process', 'httpd'
|
34
33
|
|
35
34
|
it_behaves_like 'support command check_file_contain', '/etc/passwd', 'root'
|
@@ -39,8 +38,6 @@ describe 'Serverspec commands of Red Hat' do
|
|
39
38
|
it_behaves_like 'support command check_owner', '/etc/sudoers', 'root'
|
40
39
|
it_behaves_like 'support command check_grouped', '/etc/sudoers', 'wheel'
|
41
40
|
|
42
|
-
it_behaves_like 'support command check_cron_entry'
|
43
|
-
|
44
41
|
it_behaves_like 'support command check_link', '/etc/system-release', '/etc/redhat-release'
|
45
42
|
|
46
43
|
it_behaves_like 'support command check_belonging_group', 'root', 'wheel'
|
@@ -53,14 +50,11 @@ describe 'Serverspec commands of Red Hat' do
|
|
53
50
|
|
54
51
|
it_behaves_like 'support command check_authorized_key'
|
55
52
|
|
56
|
-
it_behaves_like 'support command check_iptables'
|
57
53
|
it_behaves_like 'support command check_selinux'
|
58
54
|
|
59
55
|
it_behaves_like 'support command get_mode'
|
60
56
|
|
61
57
|
it_behaves_like 'support command check_kernel_module_loaded', 'lp'
|
62
|
-
|
63
|
-
it_behaves_like 'support command get_interface_speed_of', 'eth0'
|
64
58
|
end
|
65
59
|
|
66
60
|
describe 'check_enabled' do
|
data/spec/redhat/cron_spec.rb
CHANGED
@@ -2,7 +2,20 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::RedHat
|
4
4
|
|
5
|
-
describe
|
6
|
-
|
7
|
-
|
5
|
+
describe cron do
|
6
|
+
it { should have_entry '* * * * * /usr/local/bin/batch.sh' }
|
7
|
+
its(:command) { should eq 'crontab -l | grep -- \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ /usr/local/bin/batch.sh' }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe cron do
|
11
|
+
it { should_not have_entry 'invalid entry' }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe cron do
|
15
|
+
it { should have_entry('* * * * * /usr/local/bin/batch.sh').with_user('root') }
|
16
|
+
its(:command) { should eq 'crontab -u root -l | grep -- \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ /usr/local/bin/batch.sh' }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe cron do
|
20
|
+
it { should_not have_entry('* * * * * /usr/local/bin/batch.sh').with_user('invalid-user') }
|
8
21
|
end
|
@@ -2,6 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::RedHat
|
4
4
|
|
5
|
-
describe
|
6
|
-
|
5
|
+
describe default_gateway do
|
6
|
+
let(:stdout) { "default via 192.168.1.1 dev eth1 \r\n" }
|
7
|
+
|
8
|
+
its(:ipaddress) { should eq '192.168.1.1' }
|
9
|
+
its(:command) { should eq "ip route | grep -E '^default |^default '" }
|
10
|
+
|
11
|
+
its(:interface) { should eq 'eth1' }
|
12
|
+
its(:command) { should eq "ip route | grep -E '^default |^default '" }
|
13
|
+
|
14
|
+
its(:ipaddress) { should_not eq '192.168.1.2' }
|
15
|
+
its(:interface) { should_not eq 'eth0' }
|
7
16
|
end
|
data/spec/redhat/host_spec.rb
CHANGED
@@ -2,11 +2,57 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::RedHat
|
4
4
|
|
5
|
-
describe
|
6
|
-
|
7
|
-
|
5
|
+
describe host('127.0.0.1') do
|
6
|
+
it { should be_resolvable }
|
7
|
+
its(:command) { should eq "getent hosts 127.0.0.1" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe host('invalid-name') do
|
11
|
+
it { should_not be_resolvable }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe host('127.0.0.1') do
|
15
|
+
it { should be_resolvable.by('hosts') }
|
16
|
+
its(:command) { should eq "grep -w -- 127.0.0.1 /etc/hosts" }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe host('invalid-name') do
|
20
|
+
it { should_not be_resolvable.by('hosts') }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe host('127.0.0.1') do
|
24
|
+
it { should be_resolvable.by('dns') }
|
25
|
+
its(:command) { should eq "nslookup -timeout=1 127.0.0.1" }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe host('invalid-name') do
|
29
|
+
it { should_not be_resolvable.by('dns') }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe host('127.0.0.1') do
|
33
|
+
it { should be_reachable }
|
34
|
+
its(:command) { should eq "ping -n 127.0.0.1 -w 5 -c 2" }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe host('invalid-host') do
|
38
|
+
it { should_not be_reachable }
|
39
|
+
end
|
40
|
+
|
41
|
+
describe host('127.0.0.1') do
|
42
|
+
it { should be_reachable.with(:proto => "icmp", :timeout=> 1) }
|
43
|
+
its(:command) { should eq "ping -n 127.0.0.1 -w 1 -c 2" }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe host('127.0.0.1') do
|
47
|
+
it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) }
|
48
|
+
its(:command) { should eq "nc -vvvvzt 127.0.0.1 22 -w 1" }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe host('127.0.0.1') do
|
52
|
+
it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) }
|
53
|
+
its(:command) { should eq "nc -vvvvzu 127.0.0.1 53 -w 1" }
|
54
|
+
end
|
8
55
|
|
9
|
-
|
10
|
-
|
11
|
-
it_behaves_like 'support host be_resolvable by matcher', 'localhost', 'dns'
|
56
|
+
describe host('invalid-host') do
|
57
|
+
it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) }
|
12
58
|
end
|
@@ -2,6 +2,13 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::RedHat
|
4
4
|
|
5
|
-
describe
|
6
|
-
|
5
|
+
describe interface('eth0') do
|
6
|
+
let(:stdout) { '1000' }
|
7
|
+
its(:speed) { should eq 1000 }
|
8
|
+
its(:command) { should eq "ethtool eth0 | grep Speed | gawk '{print gensub(/Speed: ([0-9]+)Mb\\/s/,\"\\\\1\",\"\")}'" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe interface('invalid-interface') do
|
12
|
+
let(:stdout) { '1000' }
|
13
|
+
its(:speed) { should_not eq 100 }
|
7
14
|
end
|
@@ -2,7 +2,20 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::RedHat
|
4
4
|
|
5
|
-
describe
|
6
|
-
|
7
|
-
|
5
|
+
describe iptables do
|
6
|
+
it { should have_rule '-P INPUT ACCEPT' }
|
7
|
+
its(:command) { should eq "iptables -S | grep -- -P\\ INPUT\\ ACCEPT" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe iptables do
|
11
|
+
it { should_not have_rule 'invalid-rule' }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe iptables do
|
15
|
+
it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') }
|
16
|
+
its(:command) { should eq "iptables -t mangle -S INPUT | grep -- -P\\ INPUT\\ ACCEPT" }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe iptables do
|
20
|
+
it { should_not have_rule('invalid-rule').with_table('mangle').with_chain('INPUT') }
|
8
21
|
end
|
@@ -2,8 +2,35 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::RedHat
|
4
4
|
|
5
|
-
describe '
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do
|
6
|
+
let(:stdout) { "1\n" }
|
7
|
+
its(:value) { should eq 1 }
|
8
|
+
its(:command) { should eq "/sbin/sysctl -q -n net.ipv4.tcp_syncookies" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do
|
12
|
+
let(:stdout) { "1\n" }
|
13
|
+
its(:value) { should_not eq 2 }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe linux_kernel_parameter('kernel.osrelease') do
|
17
|
+
let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" }
|
18
|
+
its(:value) { should eq "2.6.32-131.0.15.el6.x86_64" }
|
19
|
+
its(:command) { should eq "/sbin/sysctl -q -n kernel.osrelease" }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe linux_kernel_parameter('kernel.osrelease') do
|
23
|
+
let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" }
|
24
|
+
its(:value) { should_not eq "2.6.32-131.0.15.el6.i386" }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe linux_kernel_parameter('net.ipv4.tcp_wmem') do
|
28
|
+
let(:stdout) { "4096 16384 4194304\n" }
|
29
|
+
its(:value) { should match /16384/ }
|
30
|
+
its(:command) { should eq "/sbin/sysctl -q -n net.ipv4.tcp_wmem" }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe linux_kernel_parameter('net.ipv4.tcp_wmem') do
|
34
|
+
let(:stdout) { "4096 16384 4194304\n" }
|
35
|
+
its(:value) { should_not match /123456/ }
|
9
36
|
end
|
data/spec/redhat/port_spec.rb
CHANGED
@@ -2,6 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::RedHat
|
4
4
|
|
5
|
-
describe
|
6
|
-
|
5
|
+
describe port(80) do
|
6
|
+
it { should be_listening }
|
7
|
+
its(:command) { should eq 'netstat -tunl | grep -- :80\\ ' }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe port('invalid') do
|
11
|
+
it { should_not be_listening }
|
7
12
|
end
|
@@ -2,6 +2,119 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::RedHat
|
4
4
|
|
5
|
-
describe
|
6
|
-
|
5
|
+
describe routing_table do
|
6
|
+
let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
|
7
|
+
it { should have_entry( :destination => '192.168.100.0/24' ) }
|
8
|
+
its(:command) { should eq "ip route | grep -E '^192.168.100.0/24 |^default '" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe routing_table do
|
12
|
+
let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
|
13
|
+
it { should_not have_entry( :destination => '192.168.100.100/24' ) }
|
14
|
+
its(:command) { should eq "ip route | grep -E '^192.168.100.100/24 |^default '" }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe routing_table do
|
18
|
+
let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
|
19
|
+
it do
|
20
|
+
should have_entry(
|
21
|
+
:destination => '192.168.100.0/24',
|
22
|
+
:gateway => '192.168.100.1'
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
it do
|
27
|
+
should have_entry(
|
28
|
+
:destination => '192.168.100.0/24',
|
29
|
+
:gateway => '192.168.100.1',
|
30
|
+
:interface => 'eth1'
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
it do
|
35
|
+
should_not have_entry(
|
36
|
+
:gateway => '192.168.100.1',
|
37
|
+
:interface => 'eth1'
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
it do
|
42
|
+
should_not have_entry(
|
43
|
+
:destination => '192.168.100.0/32',
|
44
|
+
:gateway => '192.168.100.1',
|
45
|
+
:interface => 'eth1'
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe routing_table do
|
51
|
+
let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
|
52
|
+
it { should have_entry( :destination => '192.168.200.0/24' ) }
|
53
|
+
it { should_not have_entry( :destination => '192.168.200.200/24' ) }
|
54
|
+
|
55
|
+
it do
|
56
|
+
should have_entry(
|
57
|
+
:destination => '192.168.200.0/24',
|
58
|
+
:gateway => '192.168.200.1'
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
it do
|
63
|
+
should have_entry(
|
64
|
+
:destination => '192.168.200.0/24',
|
65
|
+
:gateway => '192.168.200.1',
|
66
|
+
:interface => 'eth0'
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
it do
|
71
|
+
should_not have_entry(
|
72
|
+
:gateway => '192.168.200.1',
|
73
|
+
:interface => 'eth0'
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
it do
|
78
|
+
should_not have_entry(
|
79
|
+
:destination => '192.168.200.0/32',
|
80
|
+
:gateway => '192.168.200.1',
|
81
|
+
:interface => 'eth0'
|
82
|
+
)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe routing_table do
|
87
|
+
let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" }
|
88
|
+
it { should have_entry( :destination => 'default' ) }
|
89
|
+
it { should_not have_entry( :destination => 'defaulth' ) }
|
90
|
+
|
91
|
+
it do
|
92
|
+
should have_entry(
|
93
|
+
:destination => 'default',
|
94
|
+
:gateway => '10.0.2.2'
|
95
|
+
)
|
96
|
+
end
|
97
|
+
|
98
|
+
it do
|
99
|
+
should have_entry(
|
100
|
+
:destination => 'default',
|
101
|
+
:gateway => '10.0.2.2',
|
102
|
+
:interface => 'eth0'
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
it do
|
107
|
+
should_not have_entry(
|
108
|
+
:gateway => '10.0.2.2',
|
109
|
+
:interface => 'eth0'
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
it do
|
114
|
+
should_not have_entry(
|
115
|
+
:destination => 'default',
|
116
|
+
:gateway => '10.0.2.1',
|
117
|
+
:interface => 'eth0'
|
118
|
+
)
|
119
|
+
end
|
7
120
|
end
|
data/spec/redhat/service_spec.rb
CHANGED
@@ -7,5 +7,8 @@ describe 'Serverspec service matchers of Red Hat family' do
|
|
7
7
|
it_behaves_like 'support service enabled with level matcher', 'sshd', 3
|
8
8
|
it_behaves_like 'support service running matcher', 'sshd'
|
9
9
|
it_behaves_like 'support service running under supervisor matcher', 'sshd'
|
10
|
+
it_behaves_like 'support service running under upstart matcher', 'monit'
|
10
11
|
it_behaves_like 'support service running under unimplemented matcher', 'sshd'
|
12
|
+
it_behaves_like 'support service monitored by monit matcher', 'unicorn'
|
13
|
+
it_behaves_like 'support service monitored by unimplemented matcher', 'unicorn'
|
11
14
|
end
|
@@ -18,15 +18,13 @@ describe 'Serverspec commands of Solaris family specified SmartOS' do
|
|
18
18
|
|
19
19
|
it_behaves_like 'support command check_mounted', '/'
|
20
20
|
|
21
|
-
it_behaves_like 'support command check_routing_table', '192.168.100.1/24'
|
22
|
-
it_behaves_like 'support command check_resolvable'
|
23
|
-
|
24
21
|
it_behaves_like 'support command check_user', 'root'
|
25
22
|
it_behaves_like 'support command check_user', 'wheel'
|
26
23
|
|
27
24
|
it_behaves_like 'support command check_file_md5checksum', '/etc/passewd', '96c8c50f81a29965f7af6de371ab4250'
|
28
25
|
|
29
26
|
it_behaves_like 'support command check_running_under_supervisor', 'httpd'
|
27
|
+
it_behaves_like 'support command check_monitored_by_monit', 'unicorn'
|
30
28
|
it_behaves_like 'support command check_process', 'httpd'
|
31
29
|
|
32
30
|
it_behaves_like 'support command check_file_contain', '/etc/passwd', 'root'
|
@@ -96,18 +94,6 @@ describe 'check_running' do
|
|
96
94
|
it { should eq "svcs -l httpd status 2> /dev/null |grep -wx '^state.*online$'" }
|
97
95
|
end
|
98
96
|
|
99
|
-
describe 'check_cron_entry' do
|
100
|
-
context 'specify root user' do
|
101
|
-
subject { commands.check_cron_entry('root', '* * * * * /usr/local/bin/batch.sh') }
|
102
|
-
it { should eq 'crontab -l root | grep -- \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ /usr/local/bin/batch.sh' }
|
103
|
-
end
|
104
|
-
|
105
|
-
context 'no specified user' do
|
106
|
-
subject { commands.check_cron_entry(nil, '* * * * * /usr/local/bin/batch.sh') }
|
107
|
-
it { should eq 'crontab -l | grep -- \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ /usr/local/bin/batch.sh' }
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
97
|
describe 'check_belonging_group' do
|
112
98
|
subject { commands.check_belonging_group('root', 'wheel') }
|
113
99
|
it { should eq "id -Gn root | grep -- wheel" }
|
@@ -176,18 +162,3 @@ describe 'check_access_by_user' do
|
|
176
162
|
it { should eq 'su dummyuser3 -c "test -x /tmp/somethingx"' }
|
177
163
|
end
|
178
164
|
end
|
179
|
-
|
180
|
-
describe 'check_reachable' do
|
181
|
-
context "connect with name from /etc/services to localhost" do
|
182
|
-
subject { commands.check_reachable('localhost', 'ssh', 'tcp', 1) }
|
183
|
-
it { should eq "nc -vvvvzt -w 1 localhost ssh" }
|
184
|
-
end
|
185
|
-
context "connect with ip and port 11111 and timeout of 5" do
|
186
|
-
subject { commands.check_reachable('127.0.0.1', '11111', 'udp', 5) }
|
187
|
-
it { should eq "nc -vvvvzu -w 5 127.0.0.1 11111" }
|
188
|
-
end
|
189
|
-
context "do a ping" do
|
190
|
-
subject { commands.check_reachable('127.0.0.1', nil, 'icmp', 1) }
|
191
|
-
it { should eq "ping -n 127.0.0.1 1" }
|
192
|
-
end
|
193
|
-
end
|