serverspec 0.6.24 → 0.6.25

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ module Serverspec
3
3
  module Type
4
4
  types = %w(
5
5
  base yumrepo service package port file cron command linux_kernel_parameter iptables host
6
- routing_table default_gateway selinux user group zfs ipnat ipfilter kernel_module interface
6
+ routing_table default_gateway selinux user group zfs ipnat ipfilter kernel_module interface php_config
7
7
  )
8
8
 
9
9
  types.each {|type| require "serverspec/type/#{type}" }
@@ -0,0 +1,12 @@
1
+ module Serverspec
2
+ module Type
3
+ class PhpConfig < Base
4
+ def value
5
+ ret = backend.run_command("php -r 'echo get_cfg_var( \"#{@name}\" );'")
6
+ val = ret[:stdout]
7
+ val = val.to_i if val.match(/^\d+$/)
8
+ val
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.6.24"
2
+ VERSION = "0.6.25"
3
3
  end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Darwin
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,10 +2,91 @@ require 'spec_helper'
2
2
 
3
3
  include Serverspec::Helper::Darwin
4
4
 
5
- describe 'Serverspec service matchers of Darwin family' do
6
- it_behaves_like 'support service running matcher', 'sshd'
7
- it_behaves_like 'support service running under supervisor matcher', 'sshd'
8
- it_behaves_like 'support service running under unimplemented matcher', 'sshd'
9
- it_behaves_like 'support service monitored by monit matcher', 'unicorn'
10
- it_behaves_like 'support service monitored by unimplemented matcher', 'unicorn'
5
+ #describe service('sshd') do
6
+ # it { should be_enabled }
7
+ #end
8
+
9
+ #describe service('invalid-service') do
10
+ # it { should_not be_enabled }
11
+ #end
12
+
13
+ #describe service('sshd') do
14
+ # it { should be_enabled.with_level(3) }
15
+ #end
16
+
17
+ #describe service('invalid-service') do
18
+ # it { should_not be_enabled.with_level(3) }
19
+ #end
20
+
21
+ describe service('sshd') do
22
+ it { should be_running }
23
+ its(:command) { should eq "service sshd status" }
24
+ end
25
+
26
+ describe service('invalid-daemon') do
27
+ it { should_not be_running }
28
+ end
29
+
30
+ describe service('sshd') do
31
+ let(:stdout) { "sshd is stopped\r\n" }
32
+ it { should be_running }
33
+ end
34
+
35
+ describe service('sshd') do
36
+ let(:stdout) { "sshd RUNNING\r\n" }
37
+ it { should be_running.under('supervisor') }
38
+ end
39
+
40
+ describe service('sshd') do
41
+ let(:stdout) { "sshd STOPPED\r\n" }
42
+ it { should_not be_running.under('supervisor') }
43
+ end
44
+
45
+ describe service('invalid-daemon') do
46
+ it { should_not be_running.under('supervisor') }
47
+ end
48
+
49
+ describe service('sshd') do
50
+ let(:stdout) { "sshd running\r\n" }
51
+ it { should be_running.under('upstart') }
52
+ end
53
+
54
+ describe service('sshd') do
55
+ let(:stdout) { "sshd waiting\r\n" }
56
+ it { should_not be_running.under('upstart') }
57
+ end
58
+
59
+ describe service('invalid-daemon') do
60
+ it { should_not be_running.under('upstart') }
61
+ end
62
+
63
+ describe service('sshd') do
64
+ it {
65
+ expect {
66
+ should be_running.under('not implemented')
67
+ }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/)
68
+ }
69
+ end
70
+
71
+ describe service('sshd') do
72
+ let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" }
73
+ it { should be_monitored_by('monit') }
74
+ its(:command) { should eq "monit status" }
75
+ end
76
+
77
+ describe service('sshd') do
78
+ let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" }
79
+ it { should_not be_monitored_by('monit') }
80
+ end
81
+
82
+ describe service('invalid-daemon') do
83
+ it { should_not be_monitored_by('monit') }
84
+ end
85
+
86
+ describe service('sshd') do
87
+ it {
88
+ expect {
89
+ should be_monitored_by('not implemented')
90
+ }.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/)
91
+ }
11
92
  end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Debian
4
+ describe php_config('default_mimetype') do
5
+ let(:stdout) { 'text/html' }
6
+ its(:value) { should eq 'text/html' }
7
+ its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" }
8
+ end
9
+
10
+ describe php_config('default_mimetype') do
11
+ let(:stdout) { 'text/html' }
12
+ its(:value) { should_not eq 'text/plain' }
13
+ end
14
+
15
+ describe php_config('session.cache_expire') do
16
+ let(:stdout) { '180' }
17
+ its(:value) { should eq 180 }
18
+ its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" }
19
+ end
20
+
21
+ describe php_config('session.cache_expire') do
22
+ let(:stdout) { '180' }
23
+ its(:value) { should_not eq 360 }
24
+ end
25
+
26
+ describe php_config('mbstring.http_output_conv_mimetypes') do
27
+ let(:stdout) { 'application' }
28
+ its(:value) { should match /application/ }
29
+ its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" }
30
+ end
31
+
32
+ describe php_config('mbstring.http_output_conv_mimetypes') do
33
+ let(:stdout) { 'application' }
34
+ its(:value) { should_not match /html/ }
35
+ end
@@ -2,13 +2,93 @@ require 'spec_helper'
2
2
 
3
3
  include Serverspec::Helper::Debian
4
4
 
5
- describe 'Serverspec service matchers of Red Hat family' do
6
- it_behaves_like 'support service enabled matcher', 'sshd'
7
- it_behaves_like 'support service enabled with level matcher', 'sshd', 3
8
- it_behaves_like 'support service running matcher', 'sshd'
9
- it_behaves_like 'support service running under supervisor matcher', 'sshd'
10
- it_behaves_like 'support service running under upstart matcher', 'monit'
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'
5
+ describe service('sshd') do
6
+ it { should be_enabled }
7
+ its(:command) { should eq "ls /etc/rc3.d/ | grep -- sshd || grep 'start on' /etc/init/sshd.conf" }
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 "ls /etc/rc4.d/ | grep -- sshd || grep 'start on' /etc/init/sshd.conf" }
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 | grep 'running'" }
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
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Gentoo
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::Gentoo
4
4
 
5
- describe 'Serverspec service matchers of Gentoo family' do
6
- it_behaves_like 'support service enabled matcher', 'sshd'
7
- it_behaves_like 'support service enabled with level matcher', 'sshd', 3
8
- it_behaves_like 'support service running matcher', 'sshd'
9
- it_behaves_like 'support service running under supervisor matcher', 'sshd'
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'
5
+ describe service('sshd') do
6
+ it { should be_enabled }
7
+ its(:command) { should eq "rc-update show | grep -- \\^\\\\s\\*sshd\\\\s\\*\\|\\\\s\\*\\\\\\(boot\\\\\\|default\\\\\\)" }
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 "rc-update show | grep -- \\^\\\\s\\*sshd\\\\s\\*\\|\\\\s\\*\\\\\\(boot\\\\\\|default\\\\\\)" }
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 "/etc/init.d/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
+ }
13
94
  end
@@ -2,26 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  include Serverspec::Helper::RedHat
4
4
 
5
- describe 'Serverspec commands of Red Hat' do
6
- it_behaves_like 'support command check_running_under_supervisor', 'httpd'
7
-
8
- it_behaves_like 'support command check_running_under_upstart', 'monit'
9
-
10
- it_behaves_like 'support command check_monitored_by_monit', 'unicorn'
11
-
12
- it_behaves_like 'support command check_process', 'httpd'
13
- end
14
-
15
- describe 'check_enabled' do
16
- subject { commands.check_enabled('httpd') }
17
- it { should eq 'chkconfig --list httpd | grep 3:on' }
18
- end
19
-
20
- describe 'check_enabled with level 4' do
21
- subject { commands.check_enabled('httpd', 4) }
22
- it { should eq 'chkconfig --list httpd | grep 4:on' }
23
- end
24
-
25
5
  describe 'check_yumrepo' do
26
6
  subject { commands.check_yumrepo('epel') }
27
7
  it { should eq 'yum repolist all -C | grep ^epel' }
@@ -31,8 +11,3 @@ describe 'check_yumrepo_enabled' do
31
11
  subject { commands.check_yumrepo_enabled('epel') }
32
12
  it { should eq 'yum repolist all -C | grep ^epel | grep enabled' }
33
13
  end
34
-
35
- describe 'check_running' do
36
- subject { commands.check_running('httpd') }
37
- it { should eq 'service httpd status' }
38
- end