serverspec 0.2.22 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/serverspec.rb +22 -0
- data/lib/serverspec/backend/exec.rb +17 -12
- data/lib/serverspec/backend/ssh.rb +6 -1
- data/lib/serverspec/commands/base.rb +45 -37
- data/lib/serverspec/commands/debian.rb +3 -3
- data/lib/serverspec/commands/gentoo.rb +5 -4
- data/lib/serverspec/commands/linux.rb +22 -0
- data/lib/serverspec/commands/redhat.rb +3 -3
- data/lib/serverspec/commands/solaris.rb +22 -16
- data/lib/serverspec/matchers/be_reachable.rb +1 -0
- data/lib/serverspec/version.rb +1 -1
- data/spec/debian/commands_spec.rb +30 -29
- data/spec/gentoo/commands_spec.rb +30 -29
- data/spec/redhat/commands_spec.rb +29 -28
- data/spec/solaris/commands_spec.rb +30 -29
- metadata +99 -90
@@ -12,7 +12,7 @@ end
|
|
12
12
|
|
13
13
|
describe 'check_mounted', :os => :solaris do
|
14
14
|
subject { commands.check_mounted('/') }
|
15
|
-
it { should eq "mount | grep -w
|
15
|
+
it { should eq "mount | grep -w -- on\\ /" }
|
16
16
|
end
|
17
17
|
|
18
18
|
describe 'check_reachable', :os => :solaris do
|
@@ -33,7 +33,7 @@ end
|
|
33
33
|
describe 'check_resolvable', :os => :solaris do
|
34
34
|
context "resolve localhost by hosts" do
|
35
35
|
subject { commands.check_resolvable('localhost', 'hosts') }
|
36
|
-
it { should eq "grep -w localhost /etc/hosts" }
|
36
|
+
it { should eq "grep -w -- localhost /etc/hosts" }
|
37
37
|
end
|
38
38
|
context "resolve localhost by dns" do
|
39
39
|
subject { commands.check_resolvable('localhost', 'dns') }
|
@@ -57,7 +57,7 @@ end
|
|
57
57
|
|
58
58
|
describe 'check_group', :os => :solaris do
|
59
59
|
subject { commands.check_group('wheel') }
|
60
|
-
it { should eq 'getent group | grep -wq wheel' }
|
60
|
+
it { should eq 'getent group | grep -wq -- wheel' }
|
61
61
|
end
|
62
62
|
|
63
63
|
describe 'check_installed', :os => :solaris do
|
@@ -67,7 +67,7 @@ end
|
|
67
67
|
|
68
68
|
describe 'check_listening', :os => :solaris do
|
69
69
|
subject { commands.check_listening(80) }
|
70
|
-
it { should eq "netstat -an 2> /dev/null | egrep 'LISTEN|Idle' | grep
|
70
|
+
it { should eq "netstat -an 2> /dev/null | egrep 'LISTEN|Idle' | grep -- .80\\ " }
|
71
71
|
end
|
72
72
|
|
73
73
|
describe 'check_running', :os => :solaris do
|
@@ -82,105 +82,106 @@ end
|
|
82
82
|
|
83
83
|
describe 'check_process', :os => :solaris do
|
84
84
|
subject { commands.check_process('httpd') }
|
85
|
-
it { should eq 'ps aux | grep -w httpd | grep -qv grep' }
|
85
|
+
it { should eq 'ps aux | grep -w -- httpd | grep -qv grep' }
|
86
86
|
end
|
87
87
|
|
88
88
|
describe 'check_file_contain', :os => :solaris do
|
89
89
|
subject { commands.check_file_contain('/etc/passwd', 'root') }
|
90
|
-
it { should eq "grep -q
|
90
|
+
it { should eq "grep -q -- root /etc/passwd" }
|
91
91
|
end
|
92
92
|
|
93
93
|
describe 'check_file_contain_within', :os => :solaris do
|
94
94
|
context 'contain a pattern in the file' do
|
95
95
|
subject { commands.check_file_contain_within('Gemfile', 'rspec') }
|
96
|
-
it { should eq "sed -n
|
96
|
+
it { should eq "sed -n 1,\\$p Gemfile | grep -q -- rspec /dev/stdin" }
|
97
97
|
end
|
98
98
|
|
99
99
|
context 'contain a pattern after a line in a file' do
|
100
100
|
subject { commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test do/') }
|
101
|
-
it { should eq "sed -n
|
101
|
+
it { should eq "sed -n /\\^group\\ :test\\ do/,\\$p Gemfile | grep -q -- rspec /dev/stdin" }
|
102
102
|
end
|
103
103
|
|
104
104
|
context 'contain a pattern before a line in a file' do
|
105
105
|
subject {commands.check_file_contain_within('Gemfile', 'rspec', nil, '/^end/') }
|
106
|
-
it { should eq "sed -n
|
106
|
+
it { should eq "sed -n 1,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin" }
|
107
107
|
end
|
108
108
|
|
109
109
|
context 'contain a pattern from within a line and another line in a file' do
|
110
110
|
subject { commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test do/', '/^end/') }
|
111
|
-
it { should eq "sed -n
|
111
|
+
it { should eq "sed -n /\\^group\\ :test\\ do/,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin" }
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
115
|
describe 'check_mode', :os => :solaris do
|
116
116
|
subject { commands.check_mode('/etc/sudoers', 440) }
|
117
|
-
it { should eq 'stat -c %a /etc/sudoers | grep
|
117
|
+
it { should eq 'stat -c %a /etc/sudoers | grep -- \\^440\\$' }
|
118
118
|
end
|
119
119
|
|
120
120
|
describe 'check_owner', :os => :solaris do
|
121
121
|
subject { commands.check_owner('/etc/passwd', 'root') }
|
122
|
-
it { should eq 'stat -c %U /etc/passwd | grep
|
122
|
+
it { should eq 'stat -c %U /etc/passwd | grep -- \\^root\\$' }
|
123
123
|
end
|
124
124
|
|
125
125
|
describe 'check_grouped', :os => :solaris do
|
126
126
|
subject { commands.check_grouped('/etc/passwd', 'wheel') }
|
127
|
-
it { should eq 'stat -c %G /etc/passwd | grep
|
127
|
+
it { should eq 'stat -c %G /etc/passwd | grep -- \\^wheel\\$' }
|
128
128
|
end
|
129
129
|
|
130
130
|
describe 'check_cron_entry', :os => :solaris do
|
131
131
|
subject { commands.check_cron_entry('root', '* * * * * /usr/local/bin/batch.sh') }
|
132
|
-
it { should eq
|
132
|
+
it { should eq 'crontab -l root | grep -- \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ \\\\\\*\\ /usr/local/bin/batch.sh' }
|
133
133
|
end
|
134
134
|
|
135
135
|
describe 'check_link', :os => :solaris do
|
136
136
|
subject { commands.check_link('/etc/system-release', '/etc/redhat-release') }
|
137
|
-
it { should eq 'stat -c %N /etc/system-release | grep /etc/redhat-release' }
|
137
|
+
it { should eq 'stat -c %N /etc/system-release | grep -- /etc/redhat-release' }
|
138
138
|
end
|
139
139
|
|
140
140
|
describe 'check_installed_by_gem', :os => :solaris do
|
141
141
|
subject { commands.check_installed_by_gem('jekyll') }
|
142
|
-
it { should eq 'gem list --local | grep
|
142
|
+
it { should eq 'gem list --local | grep -- \\^jekyll\\ ' }
|
143
143
|
end
|
144
144
|
|
145
145
|
describe 'check_belonging_group', :os => :solaris do
|
146
146
|
subject { commands.check_belonging_group('root', 'wheel') }
|
147
|
-
it { should eq "id -Gn root | grep wheel" }
|
147
|
+
it { should eq "id -Gn root | grep -- wheel" }
|
148
148
|
end
|
149
149
|
|
150
150
|
describe 'have_gid', :os => :solaris do
|
151
151
|
subject { commands.check_gid('root', 0) }
|
152
|
-
it { should eq "getent group | grep
|
152
|
+
it { should eq "getent group | grep -- \\^root: | cut -f 3 -d ':' | grep -w -- 0" }
|
153
153
|
end
|
154
154
|
|
155
155
|
describe 'have_uid', :os => :solaris do
|
156
156
|
subject { commands.check_uid('root', 0) }
|
157
|
-
it { should eq "id root | grep
|
157
|
+
it { should eq "id root | grep -- \\^uid\\=0\\(" }
|
158
158
|
end
|
159
159
|
|
160
160
|
describe 'have_login_shell', :os => :solaris do
|
161
161
|
subject { commands.check_login_shell('root', '/bin/bash') }
|
162
|
-
it { should eq "getent passwd root | cut -f 7 -d ':' | grep -w /bin/bash" }
|
162
|
+
it { should eq "getent passwd root | cut -f 7 -d ':' | grep -w -- /bin/bash" }
|
163
163
|
end
|
164
164
|
|
165
165
|
describe 'have_home_directory', :os => :solaris do
|
166
166
|
subject { commands.check_home_directory('root', '/root') }
|
167
|
-
it { should eq "getent passwd root | cut -f 6 -d ':' | grep -w /root" }
|
167
|
+
it { should eq "getent passwd root | cut -f 6 -d ':' | grep -w -- /root" }
|
168
168
|
end
|
169
169
|
|
170
170
|
describe 'have_authorized_key', :os => :solaris do
|
171
171
|
key = "ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH"
|
172
|
+
escaped_key = key.gsub(/ /, '\ ')
|
172
173
|
|
173
174
|
context 'with commented publickey' do
|
174
175
|
commented_key = key + " foo@bar.local"
|
175
176
|
subject { commands.check_authorized_key('root', commented_key) }
|
176
177
|
describe 'when command insert publickey is removed comment' do
|
177
|
-
it { should eq "grep -w
|
178
|
+
it { should eq "grep -w -- #{escaped_key} ~root/.ssh/authorized_keys" }
|
178
179
|
end
|
179
180
|
end
|
180
181
|
|
181
182
|
context 'with uncomented publickey' do
|
182
183
|
subject { commands.check_authorized_key('root', key) }
|
183
|
-
it { should eq "grep -w
|
184
|
+
it { should eq "grep -w -- #{escaped_key} ~root/.ssh/authorized_keys" }
|
184
185
|
end
|
185
186
|
end
|
186
187
|
|
@@ -192,12 +193,12 @@ describe 'check_zfs', :os => :solaris do
|
|
192
193
|
|
193
194
|
context 'check with a property' do
|
194
195
|
subject { commands.check_zfs('rpool', { 'mountpoint' => '/rpool' }) }
|
195
|
-
it { should eq "/sbin/zfs list -H -o mountpoint rpool | grep
|
196
|
+
it { should eq "/sbin/zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" }
|
196
197
|
end
|
197
198
|
|
198
199
|
context 'check with multiple properties' do
|
199
200
|
subject { commands.check_zfs('rpool', { 'mountpoint' => '/rpool', 'compression' => 'off' }) }
|
200
|
-
it { should eq "/sbin/zfs list -H -o compression rpool | grep
|
201
|
+
it { should eq "/sbin/zfs list -H -o compression rpool | grep -- \\^off\\$ && /sbin/zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" }
|
201
202
|
end
|
202
203
|
end
|
203
204
|
|
@@ -208,17 +209,17 @@ end
|
|
208
209
|
|
209
210
|
describe 'check_ip_filter_rule', :os => :solaris do
|
210
211
|
subject { commands.check_ipfilter_rule('pass in quick on lo0 all') }
|
211
|
-
it { should eq "/sbin/ipfstat -io 2> /dev/null | grep
|
212
|
+
it { should eq "/sbin/ipfstat -io 2> /dev/null | grep -- pass\\ in\\ quick\\ on\\ lo0\\ all" }
|
212
213
|
end
|
213
214
|
|
214
215
|
describe 'check_ipnat_rule', :os => :solaris do
|
215
216
|
subject { commands.check_ipnat_rule('map net1 192.168.0.0/24 -> 0.0.0.0/32') }
|
216
|
-
it { should eq "/sbin/ipnat -l 2> /dev/null | grep
|
217
|
+
it { should eq "/sbin/ipnat -l 2> /dev/null | grep -- \\^map\\ net1\\ 192.168.0.0/24\\ -\\>\\ 0.0.0.0/32\\$" }
|
217
218
|
end
|
218
219
|
|
219
220
|
describe 'check_svcprop', :os => :solaris do
|
220
221
|
subject { commands.check_svcprop('svc:/network/http:apache22', 'httpd/enable_64bit','false') }
|
221
|
-
it { should eq "svcprop -p httpd/enable_64bit svc:/network/http:apache22 | grep
|
222
|
+
it { should eq "svcprop -p httpd/enable_64bit svc:/network/http:apache22 | grep -- \\^false\\$" }
|
222
223
|
end
|
223
224
|
|
224
225
|
describe 'check_svcprops', :os => :solaris do
|
@@ -228,6 +229,6 @@ describe 'check_svcprops', :os => :solaris do
|
|
228
229
|
'httpd/server_type' => 'worker',
|
229
230
|
})
|
230
231
|
}
|
231
|
-
it { should eq "svcprop -p httpd/enable_64bit svc:/network/http:apache22 | grep
|
232
|
+
it { should eq "svcprop -p httpd/enable_64bit svc:/network/http:apache22 | grep -- \\^false\\$ && svcprop -p httpd/server_type svc:/network/http:apache22 | grep -- \\^worker\\$" }
|
232
233
|
end
|
233
234
|
|
metadata
CHANGED
@@ -1,105 +1,104 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverspec
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 57
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 23
|
10
|
+
version: 0.2.23
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Gosuke Miyashita
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2013-05-07 00:00:00 +09:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
15
22
|
name: net-ssh
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rspec
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
33
25
|
none: false
|
34
|
-
requirements:
|
35
|
-
- -
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
38
33
|
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
39
37
|
prerelease: false
|
40
|
-
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: highline
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
49
39
|
none: false
|
50
|
-
requirements:
|
51
|
-
- -
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
54
47
|
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: highline
|
55
51
|
prerelease: false
|
56
|
-
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
53
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :runtime
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
63
64
|
name: bundler
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '1.3'
|
70
|
-
type: :development
|
71
65
|
prerelease: false
|
72
|
-
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
67
|
none: false
|
74
|
-
requirements:
|
68
|
+
requirements:
|
75
69
|
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 9
|
72
|
+
segments:
|
73
|
+
- 1
|
74
|
+
- 3
|
75
|
+
version: "1.3"
|
86
76
|
type: :development
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rake
|
87
80
|
prerelease: false
|
88
|
-
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
82
|
none: false
|
90
|
-
requirements:
|
91
|
-
- -
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
type: :development
|
91
|
+
version_requirements: *id005
|
92
|
+
description: RSpec tests for your servers provisioned by Puppet, Chef or anything else
|
93
|
+
email:
|
97
94
|
- gosukenator@gmail.com
|
98
|
-
executables:
|
95
|
+
executables:
|
99
96
|
- serverspec-init
|
100
97
|
extensions: []
|
98
|
+
|
101
99
|
extra_rdoc_files: []
|
102
|
-
|
100
|
+
|
101
|
+
files:
|
103
102
|
- .gitignore
|
104
103
|
- .travis.yml
|
105
104
|
- Gemfile
|
@@ -115,6 +114,7 @@ files:
|
|
115
114
|
- lib/serverspec/commands/base.rb
|
116
115
|
- lib/serverspec/commands/debian.rb
|
117
116
|
- lib/serverspec/commands/gentoo.rb
|
117
|
+
- lib/serverspec/commands/linux.rb
|
118
118
|
- lib/serverspec/commands/redhat.rb
|
119
119
|
- lib/serverspec/commands/solaris.rb
|
120
120
|
- lib/serverspec/filter.rb
|
@@ -183,32 +183,41 @@ files:
|
|
183
183
|
- spec/solaris/matchers_spec.rb
|
184
184
|
- spec/spec_helper.rb
|
185
185
|
- spec/support/shared_matcher_examples.rb
|
186
|
+
has_rdoc: true
|
186
187
|
homepage: http://serverspec.org/
|
187
|
-
licenses:
|
188
|
+
licenses:
|
188
189
|
- MIT
|
189
190
|
post_install_message:
|
190
191
|
rdoc_options: []
|
191
|
-
|
192
|
+
|
193
|
+
require_paths:
|
192
194
|
- lib
|
193
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
195
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
194
196
|
none: false
|
195
|
-
requirements:
|
196
|
-
- -
|
197
|
-
- !ruby/object:Gem::Version
|
198
|
-
|
199
|
-
|
197
|
+
requirements:
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
hash: 3
|
201
|
+
segments:
|
202
|
+
- 0
|
203
|
+
version: "0"
|
204
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
205
|
none: false
|
201
|
-
requirements:
|
202
|
-
- -
|
203
|
-
- !ruby/object:Gem::Version
|
204
|
-
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
hash: 3
|
210
|
+
segments:
|
211
|
+
- 0
|
212
|
+
version: "0"
|
205
213
|
requirements: []
|
214
|
+
|
206
215
|
rubyforge_project:
|
207
|
-
rubygems_version: 1.
|
216
|
+
rubygems_version: 1.3.7
|
208
217
|
signing_key:
|
209
218
|
specification_version: 3
|
210
219
|
summary: RSpec tests for your servers provisioned by Puppet, Chef or anything else
|
211
|
-
test_files:
|
220
|
+
test_files:
|
212
221
|
- spec/debian/commands_spec.rb
|
213
222
|
- spec/debian/matchers_spec.rb
|
214
223
|
- spec/gentoo/commands_spec.rb
|