serverspec 0.6.24 → 0.6.25
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/serverspec/helper/type.rb +1 -1
- data/lib/serverspec/type/php_config.rb +12 -0
- data/lib/serverspec/version.rb +1 -1
- data/spec/darwin/php_config_spec.rb +36 -0
- data/spec/darwin/service_spec.rb +87 -6
- data/spec/debian/php_config_spec.rb +35 -0
- data/spec/debian/service_spec.rb +89 -9
- data/spec/gentoo/php_config_spec.rb +36 -0
- data/spec/gentoo/service_spec.rb +89 -8
- data/spec/redhat/commands_spec.rb +0 -25
- data/spec/redhat/php_config_spec.rb +36 -0
- data/spec/redhat/service_spec.rb +89 -9
- data/spec/smartos/commands_spec.rb +0 -26
- data/spec/solaris/commands_spec.rb +0 -36
- data/spec/solaris/php_config_spec.rb +36 -0
- data/spec/solaris/service_spec.rb +89 -8
- data/spec/solaris10/commands_spec.rb +0 -21
- data/spec/solaris10/php_config_spec.rb +36 -0
- data/spec/solaris11/commands_spec.rb +0 -21
- data/spec/solaris11/php_config_spec.rb +36 -0
- data/spec/solaris11/service_spec.rb +89 -8
- metadata +17 -12
- data/spec/darwin/commands_spec.rb +0 -9
- data/spec/debian/commands_spec.rb +0 -28
- data/spec/gentoo/commands_spec.rb +0 -20
- data/spec/support/shared_commands_examples.rb +0 -19
- data/spec/support/shared_service_examples.rb +0 -118
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::RedHat
|
4
|
+
|
5
|
+
describe php_config('default_mimetype') do
|
6
|
+
let(:stdout) { 'text/html' }
|
7
|
+
its(:value) { should eq 'text/html' }
|
8
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe php_config('default_mimetype') do
|
12
|
+
let(:stdout) { 'text/html' }
|
13
|
+
its(:value) { should_not eq 'text/plain' }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe php_config('session.cache_expire') do
|
17
|
+
let(:stdout) { '180' }
|
18
|
+
its(:value) { should eq 180 }
|
19
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe php_config('session.cache_expire') do
|
23
|
+
let(:stdout) { '180' }
|
24
|
+
its(:value) { should_not eq 360 }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe php_config('mbstring.http_output_conv_mimetypes') do
|
28
|
+
let(:stdout) { 'application' }
|
29
|
+
its(:value) { should match /application/ }
|
30
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe php_config('mbstring.http_output_conv_mimetypes') do
|
34
|
+
let(:stdout) { 'application' }
|
35
|
+
its(:value) { should_not match /html/ }
|
36
|
+
end
|
data/spec/redhat/service_spec.rb
CHANGED
@@ -2,13 +2,93 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::RedHat
|
4
4
|
|
5
|
-
describe
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
describe service('sshd') do
|
6
|
+
it { should be_enabled }
|
7
|
+
its(:command) { should eq "chkconfig --list sshd | grep 3:on" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe service('invalid-service') do
|
11
|
+
it { should_not be_enabled }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe service('sshd') do
|
15
|
+
it { should be_enabled.with_level(4) }
|
16
|
+
its(:command) { should eq "chkconfig --list sshd | grep 4:on" }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe service('invalid-service') do
|
20
|
+
it { should_not be_enabled.with_level(4) }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe service('sshd') do
|
24
|
+
it { should be_running }
|
25
|
+
its(:command) { should eq "service sshd status" }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe service('invalid-daemon') do
|
29
|
+
it { should_not be_running }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe service('sshd') do
|
33
|
+
let(:stdout) { "sshd is stopped\r\n" }
|
34
|
+
it { should be_running }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe service('sshd') do
|
38
|
+
let(:stdout) { "sshd RUNNING\r\n" }
|
39
|
+
it { should be_running.under('supervisor') }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe service('sshd') do
|
43
|
+
let(:stdout) { "sshd STOPPED\r\n" }
|
44
|
+
it { should_not be_running.under('supervisor') }
|
45
|
+
end
|
46
|
+
|
47
|
+
describe service('invalid-daemon') do
|
48
|
+
it { should_not be_running.under('supervisor') }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe service('sshd') do
|
52
|
+
let(:stdout) { "sshd running\r\n" }
|
53
|
+
it { should be_running.under('upstart') }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe service('sshd') do
|
57
|
+
let(:stdout) { "sshd waiting\r\n" }
|
58
|
+
it { should_not be_running.under('upstart') }
|
59
|
+
end
|
60
|
+
|
61
|
+
describe service('invalid-daemon') do
|
62
|
+
it { should_not be_running.under('upstart') }
|
63
|
+
end
|
64
|
+
|
65
|
+
describe service('sshd') do
|
66
|
+
it {
|
67
|
+
expect {
|
68
|
+
should be_running.under('not implemented')
|
69
|
+
}.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/)
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
describe service('sshd') do
|
74
|
+
let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" }
|
75
|
+
it { should be_monitored_by('monit') }
|
76
|
+
its(:command) { should eq "monit status" }
|
77
|
+
end
|
78
|
+
|
79
|
+
describe service('sshd') do
|
80
|
+
let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" }
|
81
|
+
it { should_not be_monitored_by('monit') }
|
82
|
+
end
|
83
|
+
|
84
|
+
describe service('invalid-daemon') do
|
85
|
+
it { should_not be_monitored_by('monit') }
|
86
|
+
end
|
87
|
+
|
88
|
+
describe service('sshd') do
|
89
|
+
it {
|
90
|
+
expect {
|
91
|
+
should be_monitored_by('not implemented')
|
92
|
+
}.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/)
|
93
|
+
}
|
14
94
|
end
|
@@ -2,18 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::SmartOS
|
4
4
|
|
5
|
-
describe 'Serverspec commands of Solaris family specified SmartOS' do
|
6
|
-
|
7
|
-
it_behaves_like 'support command check_running_under_supervisor', 'httpd'
|
8
|
-
it_behaves_like 'support command check_monitored_by_monit', 'unicorn'
|
9
|
-
it_behaves_like 'support command check_process', 'httpd'
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'check_enabled' do
|
13
|
-
subject { commands.check_enabled('httpd') }
|
14
|
-
it { should eq "svcs -l httpd 2> /dev/null | grep -wx '^enabled.*true$'" }
|
15
|
-
end
|
16
|
-
|
17
5
|
## SmartOS
|
18
6
|
describe 'check_installed' do
|
19
7
|
subject { commands.check_installed('httpd') }
|
@@ -25,20 +13,6 @@ describe 'check_installed' do
|
|
25
13
|
subject { commands.check_installed('httpd', '2.2') }
|
26
14
|
it { should eq '/opt/local/bin/pkgin list 2> /dev/null | grep -qw ^httpd-2.2' }
|
27
15
|
end
|
28
|
-
describe 'check_listening' do
|
29
|
-
subject { commands.check_listening(80) }
|
30
|
-
it { should eq "netstat -an 2> /dev/null | egrep 'LISTEN|Idle' | grep -- .80\\ " }
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'check_running' do
|
34
|
-
subject { commands.check_running('httpd') }
|
35
|
-
it { should eq "svcs -l httpd status 2> /dev/null |grep -wx '^state.*online$'" }
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'check_belonging_group' do
|
39
|
-
subject { commands.check_belonging_group('root', 'wheel') }
|
40
|
-
it { should eq "id -Gn root | grep -- wheel" }
|
41
|
-
end
|
42
16
|
|
43
17
|
describe 'check_zfs' do
|
44
18
|
context 'check without properties' do
|
@@ -2,42 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::Solaris
|
4
4
|
|
5
|
-
describe 'Serverspec commands of Solaris family' do
|
6
|
-
it_behaves_like 'support command check_running_under_supervisor', 'httpd'
|
7
|
-
it_behaves_like 'support command check_monitored_by_monit', 'unicorn'
|
8
|
-
it_behaves_like 'support command check_process', 'httpd'
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'check_enabled' do
|
12
|
-
subject { commands.check_enabled('httpd') }
|
13
|
-
it { should eq "svcs -l httpd 2> /dev/null | egrep '^enabled *true$'" }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'check_running' do
|
17
|
-
subject { commands.check_running('httpd') }
|
18
|
-
it { should eq "svcs -l httpd status 2> /dev/null | egrep '^state *online$'" }
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'check_listening' do
|
22
|
-
subject { commands.check_listening(80) }
|
23
|
-
it { should eq %q!netstat -an 2> /dev/null | egrep 'LISTEN|Idle' | grep -- .80\\ ! }
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'check_listening_with_tcp' do
|
27
|
-
subject { commands.check_listening_with_protocol(80, "tcp") }
|
28
|
-
it { should eq %q!netstat -an -P tcp 2> /dev/null | egrep 'LISTEN|Idle' | grep -- .\\*.80\\ ! }
|
29
|
-
end
|
30
|
-
|
31
|
-
describe 'check_listening_with_udp' do
|
32
|
-
subject { commands.check_listening_with_protocol(123, "udp") }
|
33
|
-
it { should eq %q!netstat -an -P udp 2> /dev/null | egrep 'LISTEN|Idle' | grep -- .\\*.123\\ ! }
|
34
|
-
end
|
35
|
-
|
36
|
-
describe 'check_belonging_group' do
|
37
|
-
subject { commands.check_belonging_group('root', 'wheel') }
|
38
|
-
it { should eq "id -Gn root | grep -- wheel" }
|
39
|
-
end
|
40
|
-
|
41
5
|
describe 'check_zfs' do
|
42
6
|
context 'check without properties' do
|
43
7
|
subject { commands.check_zfs('rpool') }
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::Solaris
|
4
|
+
|
5
|
+
describe php_config('default_mimetype') do
|
6
|
+
let(:stdout) { 'text/html' }
|
7
|
+
its(:value) { should eq 'text/html' }
|
8
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe php_config('default_mimetype') do
|
12
|
+
let(:stdout) { 'text/html' }
|
13
|
+
its(:value) { should_not eq 'text/plain' }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe php_config('session.cache_expire') do
|
17
|
+
let(:stdout) { '180' }
|
18
|
+
its(:value) { should eq 180 }
|
19
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe php_config('session.cache_expire') do
|
23
|
+
let(:stdout) { '180' }
|
24
|
+
its(:value) { should_not eq 360 }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe php_config('mbstring.http_output_conv_mimetypes') do
|
28
|
+
let(:stdout) { 'application' }
|
29
|
+
its(:value) { should match /application/ }
|
30
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe php_config('mbstring.http_output_conv_mimetypes') do
|
34
|
+
let(:stdout) { 'application' }
|
35
|
+
its(:value) { should_not match /html/ }
|
36
|
+
end
|
@@ -2,12 +2,93 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::Solaris
|
4
4
|
|
5
|
-
describe
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
describe service('sshd') do
|
6
|
+
it { should be_enabled }
|
7
|
+
its(:command) { should eq "svcs -l sshd 2> /dev/null | egrep '^enabled *true$'" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe service('invalid-service') do
|
11
|
+
it { should_not be_enabled }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe service('sshd') do
|
15
|
+
it { should be_enabled.with_level(4) }
|
16
|
+
its(:command) { should eq "svcs -l sshd 2> /dev/null | egrep '^enabled *true$'" }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe service('invalid-service') do
|
20
|
+
it { should_not be_enabled.with_level(4) }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe service('sshd') do
|
24
|
+
it { should be_running }
|
25
|
+
its(:command) { should eq "svcs -l sshd status 2> /dev/null | egrep '^state *online$'" }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe service('invalid-daemon') do
|
29
|
+
it { should_not be_running }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe service('sshd') do
|
33
|
+
let(:stdout) { "sshd is stopped\r\n" }
|
34
|
+
it { should be_running }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe service('sshd') do
|
38
|
+
let(:stdout) { "sshd RUNNING\r\n" }
|
39
|
+
it { should be_running.under('supervisor') }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe service('sshd') do
|
43
|
+
let(:stdout) { "sshd STOPPED\r\n" }
|
44
|
+
it { should_not be_running.under('supervisor') }
|
45
|
+
end
|
46
|
+
|
47
|
+
describe service('invalid-daemon') do
|
48
|
+
it { should_not be_running.under('supervisor') }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe service('sshd') do
|
52
|
+
let(:stdout) { "sshd running\r\n" }
|
53
|
+
it { should be_running.under('upstart') }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe service('sshd') do
|
57
|
+
let(:stdout) { "sshd waiting\r\n" }
|
58
|
+
it { should_not be_running.under('upstart') }
|
59
|
+
end
|
60
|
+
|
61
|
+
describe service('invalid-daemon') do
|
62
|
+
it { should_not be_running.under('upstart') }
|
63
|
+
end
|
64
|
+
|
65
|
+
describe service('sshd') do
|
66
|
+
it {
|
67
|
+
expect {
|
68
|
+
should be_running.under('not implemented')
|
69
|
+
}.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/)
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
describe service('sshd') do
|
74
|
+
let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" }
|
75
|
+
it { should be_monitored_by('monit') }
|
76
|
+
its(:command) { should eq "monit status" }
|
77
|
+
end
|
78
|
+
|
79
|
+
describe service('sshd') do
|
80
|
+
let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" }
|
81
|
+
it { should_not be_monitored_by('monit') }
|
82
|
+
end
|
83
|
+
|
84
|
+
describe service('invalid-daemon') do
|
85
|
+
it { should_not be_monitored_by('monit') }
|
86
|
+
end
|
87
|
+
|
88
|
+
describe service('sshd') do
|
89
|
+
it {
|
90
|
+
expect {
|
91
|
+
should be_monitored_by('not implemented')
|
92
|
+
}.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/)
|
93
|
+
}
|
13
94
|
end
|
@@ -2,27 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::Solaris10
|
4
4
|
|
5
|
-
describe 'Serverspec commands of Solaris family' do
|
6
|
-
it_behaves_like 'support command check_running_under_supervisor', 'httpd'
|
7
|
-
it_behaves_like 'support command check_monitored_by_monit', 'unicorn'
|
8
|
-
it_behaves_like 'support command check_process', 'httpd'
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'check_enabled' do
|
12
|
-
subject { commands.check_enabled('httpd') }
|
13
|
-
it { should eq "svcs -l httpd 2> /dev/null | egrep '^enabled *true$'" }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'check_running' do
|
17
|
-
subject { commands.check_running('httpd') }
|
18
|
-
it { should eq "svcs -l httpd status 2> /dev/null | egrep '^state *online$'" }
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'check_belonging_group' do
|
22
|
-
subject { commands.check_belonging_group('root', 'wheel') }
|
23
|
-
it { should eq "id -Gn root | grep -- wheel" }
|
24
|
-
end
|
25
|
-
|
26
5
|
describe 'check_zfs' do
|
27
6
|
context 'check without properties' do
|
28
7
|
subject { commands.check_zfs('rpool') }
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::Solaris10
|
4
|
+
|
5
|
+
describe php_config('default_mimetype') do
|
6
|
+
let(:stdout) { 'text/html' }
|
7
|
+
its(:value) { should eq 'text/html' }
|
8
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe php_config('default_mimetype') do
|
12
|
+
let(:stdout) { 'text/html' }
|
13
|
+
its(:value) { should_not eq 'text/plain' }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe php_config('session.cache_expire') do
|
17
|
+
let(:stdout) { '180' }
|
18
|
+
its(:value) { should eq 180 }
|
19
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe php_config('session.cache_expire') do
|
23
|
+
let(:stdout) { '180' }
|
24
|
+
its(:value) { should_not eq 360 }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe php_config('mbstring.http_output_conv_mimetypes') do
|
28
|
+
let(:stdout) { 'application' }
|
29
|
+
its(:value) { should match /application/ }
|
30
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe php_config('mbstring.http_output_conv_mimetypes') do
|
34
|
+
let(:stdout) { 'application' }
|
35
|
+
its(:value) { should_not match /html/ }
|
36
|
+
end
|
@@ -2,27 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::Solaris11
|
4
4
|
|
5
|
-
describe 'Serverspec commands of Solaris11 family' do
|
6
|
-
it_behaves_like 'support command check_running_under_supervisor', 'httpd'
|
7
|
-
it_behaves_like 'support command check_monitored_by_monit', 'unicorn'
|
8
|
-
it_behaves_like 'support command check_process', 'httpd'
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'check_enabled' do
|
12
|
-
subject { commands.check_enabled('httpd') }
|
13
|
-
it { should eq "svcs -l httpd 2> /dev/null | egrep '^enabled *true$'" }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'check_running' do
|
17
|
-
subject { commands.check_running('httpd') }
|
18
|
-
it { should eq "svcs -l httpd status 2> /dev/null | egrep '^state *online$'" }
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'check_belonging_group' do
|
22
|
-
subject { commands.check_belonging_group('root', 'wheel') }
|
23
|
-
it { should eq "id -Gn root | grep -- wheel" }
|
24
|
-
end
|
25
|
-
|
26
5
|
describe 'check_zfs' do
|
27
6
|
context 'check without properties' do
|
28
7
|
subject { commands.check_zfs('rpool') }
|