serverspec 0.6.21 → 0.6.22

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.
Files changed (37) hide show
  1. data/Rakefile +1 -1
  2. data/lib/serverspec.rb +2 -0
  3. data/lib/serverspec/backend/exec.rb +2 -0
  4. data/lib/serverspec/commands/base.rb +5 -0
  5. data/lib/serverspec/commands/smartos.rb +8 -0
  6. data/lib/serverspec/commands/solaris.rb +7 -2
  7. data/lib/serverspec/commands/solaris11.rb +7 -0
  8. data/lib/serverspec/helper.rb +1 -0
  9. data/lib/serverspec/helper/solaris11.rb +9 -0
  10. data/lib/serverspec/matchers.rb +3 -0
  11. data/lib/serverspec/matchers/be_listening.rb +9 -0
  12. data/lib/serverspec/type/port.rb +11 -2
  13. data/lib/serverspec/version.rb +1 -1
  14. data/spec/darwin/port_spec.rb +18 -0
  15. data/spec/debian/port_spec.rb +18 -0
  16. data/spec/gentoo/port_spec.rb +18 -0
  17. data/spec/redhat/port_spec.rb +18 -0
  18. data/spec/solaris/commands_spec.rb +17 -2
  19. data/spec/solaris/port_spec.rb +18 -0
  20. data/spec/solaris10/commands_spec.rb +2 -2
  21. data/spec/solaris11/command_spec.rb +48 -0
  22. data/spec/solaris11/commands_spec.rb +82 -0
  23. data/spec/solaris11/cron_spec.rb +21 -0
  24. data/spec/solaris11/default_gateway_spec.rb +16 -0
  25. data/spec/solaris11/file_spec.rb +381 -0
  26. data/spec/solaris11/group_spec.rb +8 -0
  27. data/spec/solaris11/host_spec.rb +58 -0
  28. data/spec/solaris11/ipfilter_spec.rb +7 -0
  29. data/spec/solaris11/ipnat_spec.rb +7 -0
  30. data/spec/solaris11/package_spec.rb +76 -0
  31. data/spec/solaris11/port_spec.rb +12 -0
  32. data/spec/solaris11/routing_table_spec.rb +120 -0
  33. data/spec/solaris11/service_spec.rb +13 -0
  34. data/spec/solaris11/svcprop_spec.rb +8 -0
  35. data/spec/solaris11/user_spec.rb +12 -0
  36. data/spec/solaris11/zfs_spec.rb +9 -0
  37. metadata +37 -2
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Solaris11
4
+
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 -l root | 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') }
21
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Solaris11
4
+
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' }
16
+ end
@@ -0,0 +1,381 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Solaris11
4
+
5
+ describe file('/etc/ssh/sshd_config') do
6
+ it { should be_file }
7
+ its(:command) { should eq "test -f /etc/ssh/sshd_config" }
8
+ end
9
+
10
+ describe file('/etc/invalid_file') do
11
+ it { should_not be_file }
12
+ end
13
+
14
+ describe file('/etc/ssh') do
15
+ it { should be_directory }
16
+ its(:command) { should eq "test -d /etc/ssh" }
17
+ end
18
+
19
+ describe file('/etc/invalid_directory') do
20
+ it { should_not be_directory }
21
+ end
22
+
23
+ describe file('/var/run/unicorn.sock') do
24
+ it { should be_socket }
25
+ its(:command) { should eq "test -S /var/run/unicorn.sock" }
26
+ end
27
+
28
+ describe file('/etc/invalid_socket') do
29
+ it { should_not be_socket }
30
+ end
31
+
32
+ describe file('/etc/ssh/sshd_config') do
33
+ it { should contain 'This is the sshd server system-wide configuration file' }
34
+ its(:command) { should eq "grep -q -- This\\ is\\ the\\ sshd\\ server\\ system-wide\\ configuration\\ file /etc/ssh/sshd_config" }
35
+ end
36
+
37
+ describe file('/etc/ssh/sshd_config') do
38
+ it { should_not contain 'This is invalid text!!' }
39
+ end
40
+
41
+ describe file('Gemfile') do
42
+ it { should contain('rspec').from(/^group :test do/).to(/^end/) }
43
+ its(:command) { should eq "sed -n /\\^group\\ :test\\ do/,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin" }
44
+ end
45
+
46
+ describe file('/etc/ssh/sshd_config') do
47
+ it { should_not contain('This is invalid text!!').from(/^group :test do/).to(/^end/) }
48
+ end
49
+
50
+ describe file('Gemfile') do
51
+ it { should contain('rspec').after(/^group :test do/) }
52
+ its(:command) { should eq "sed -n /\\^group\\ :test\\ do/,\\$p Gemfile | grep -q -- rspec /dev/stdin" }
53
+ end
54
+
55
+ describe file('/etc/ssh/sshd_config') do
56
+ it { should_not contain('This is invalid text!!').after(/^group :test do/) }
57
+ end
58
+
59
+ describe file('Gemfile') do
60
+ it { should contain('rspec').before(/^end/) }
61
+ its(:command) { should eq "sed -n 1,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin" }
62
+ end
63
+
64
+ describe file('/etc/ssh/sshd_config') do
65
+ it { should_not contain('This is invalid text!!').before(/^end/) }
66
+ end
67
+
68
+ describe file('/etc/passwd') do
69
+ it { should be_mode 644 }
70
+ its(:command) { should eq "stat -c %a /etc/passwd | grep -- \\^644\\$" }
71
+ end
72
+
73
+ describe file('/etc/passwd') do
74
+ it { should_not be_mode 'invalid' }
75
+ end
76
+
77
+ describe file('/etc/passwd') do
78
+ it { should be_owned_by 'root' }
79
+ its(:command) { should eq "stat -c %U /etc/passwd | grep -- \\^root\\$" }
80
+ end
81
+
82
+ describe file('/etc/passwd') do
83
+ it { should_not be_owned_by 'invalid-owner' }
84
+ end
85
+
86
+ describe file('/etc/passwd') do
87
+ it { should be_grouped_into 'root' }
88
+ its(:command) { should eq "stat -c %G /etc/passwd | grep -- \\^root\\$" }
89
+ end
90
+
91
+ describe file('/etc/passwd') do
92
+ it { should_not be_grouped_into 'invalid-group' }
93
+ end
94
+
95
+ describe file('/etc/pam.d/system-auth') do
96
+ it { should be_linked_to '/etc/pam.d/system-auth-ac' }
97
+ its(:command) { should eq "stat -c %N /etc/pam.d/system-auth | grep -- /etc/pam.d/system-auth-ac" }
98
+ end
99
+
100
+ describe file('dummy-link') do
101
+ it { should_not be_linked_to '/invalid/target' }
102
+ end
103
+
104
+ describe file('/dev') do
105
+ let(:stdout) { "755\r\n" }
106
+ it { should be_readable }
107
+ its(:command) { should eq "stat -c %a /dev" }
108
+ end
109
+
110
+ describe file('/dev') do
111
+ let(:stdout) { "333\r\n" }
112
+ it { should_not be_readable }
113
+ end
114
+
115
+ describe file('/dev') do
116
+ let(:stdout) { "400\r\n" }
117
+ it { should be_readable.by('owner') }
118
+ end
119
+
120
+ describe file('/dev') do
121
+ let(:stdout) { "044\r\n" }
122
+ it { should_not be_readable.by('owner') }
123
+ end
124
+
125
+ describe file('/dev') do
126
+ let(:stdout) { "040\r\n" }
127
+ it { should be_readable.by('group') }
128
+ end
129
+
130
+ describe file('/dev') do
131
+ let(:stdout) { "404\r\n" }
132
+ it { should_not be_readable.by('group') }
133
+ end
134
+
135
+ describe file('/dev') do
136
+ let(:stdout) { "044\r\n" }
137
+ it { should be_readable.by('others') }
138
+ end
139
+
140
+ describe file('/dev') do
141
+ let(:stdout) { "443\r\n" }
142
+ it { should_not be_readable.by('others') }
143
+ end
144
+
145
+ describe file('/tmp') do
146
+ it { should be_readable.by_user('mail') }
147
+ its(:command) { should eq "su mail -c \"test -r /tmp\"" }
148
+ end
149
+
150
+ describe file('/tmp') do
151
+ it { should_not be_readable.by_user('invalid-user') }
152
+ end
153
+
154
+ describe file('/dev') do
155
+ let(:stdout) { "755\r\n" }
156
+ it { should be_writable }
157
+ its(:command) { should eq "stat -c %a /dev" }
158
+ end
159
+
160
+ describe file('/dev') do
161
+ let(:stdout) { "555\r\n" }
162
+ it { should_not be_writable }
163
+ end
164
+
165
+ describe file('/dev') do
166
+ let(:stdout) { "200\r\n" }
167
+ it { should be_writable.by('owner') }
168
+ end
169
+
170
+ describe file('/dev') do
171
+ let(:stdout) { "555\r\n" }
172
+ it { should_not be_writable.by('owner') }
173
+ end
174
+
175
+ describe file('/dev') do
176
+ let(:stdout) { "030\r\n" }
177
+ it { should be_writable.by('group') }
178
+ end
179
+
180
+ describe file('/dev') do
181
+ let(:stdout) { "555\r\n" }
182
+ it { should_not be_writable.by('group') }
183
+ end
184
+
185
+ describe file('/dev') do
186
+ let(:stdout) { "666\r\n" }
187
+ it { should be_writable.by('others') }
188
+ end
189
+
190
+ describe file('/dev') do
191
+ let(:stdout) { "555\r\n" }
192
+ it { should_not be_writable.by('others') }
193
+ end
194
+
195
+ describe file('/tmp') do
196
+ it { should be_writable.by_user('mail') }
197
+ its(:command) { should eq "su mail -c \"test -w /tmp\"" }
198
+ end
199
+
200
+ describe file('/tmp') do
201
+ it { should_not be_writable.by_user('invalid-user') }
202
+ end
203
+
204
+ describe file('/dev') do
205
+ let(:stdout) { "755\r\n" }
206
+ it { should be_executable }
207
+ its(:command) { should eq "stat -c %a /dev" }
208
+ end
209
+
210
+ describe file('/dev') do
211
+ let(:stdout) { "666\r\n" }
212
+ it { should_not be_executable }
213
+ end
214
+
215
+ describe file('/dev') do
216
+ let(:stdout) { "100\r\n" }
217
+ it { should be_executable.by('owner') }
218
+ end
219
+
220
+ describe file('/dev') do
221
+ let(:stdout) { "666\r\n" }
222
+ it { should_not be_executable.by('owner') }
223
+ end
224
+
225
+ describe file('/dev') do
226
+ let(:stdout) { "070\r\n" }
227
+ it { should be_executable.by('group') }
228
+ end
229
+
230
+ describe file('/dev') do
231
+ let(:stdout) { "666\r\n" }
232
+ it { should_not be_executable.by('group') }
233
+ end
234
+
235
+ describe file('/dev') do
236
+ let(:stdout) { "001\r\n" }
237
+ it { should be_executable.by('others') }
238
+ end
239
+
240
+ describe file('/dev') do
241
+ let(:stdout) { "666\r\n" }
242
+ it { should_not be_executable.by('others') }
243
+ end
244
+
245
+ describe file('/tmp') do
246
+ it { should be_executable.by_user('mail') }
247
+ its(:command) { should eq "su mail -c \"test -x /tmp\"" }
248
+ end
249
+
250
+ describe file('/tmp') do
251
+ it { should_not be_executable.by_user('invalid-user') }
252
+ end
253
+
254
+ describe file('/') do
255
+ it { should be_mounted }
256
+ its(:command) { should eq "mount | grep -w -- on\\ /" }
257
+ end
258
+
259
+ describe file('/etc/invalid-mount') do
260
+ it { should_not be_mounted }
261
+ end
262
+
263
+ describe file('/') do
264
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
265
+ it { should be_mounted.with( :type => 'ext4' ) }
266
+ end
267
+
268
+ describe file('/') do
269
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
270
+ it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) }
271
+ end
272
+
273
+ describe file('/') do
274
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
275
+ it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) }
276
+ end
277
+
278
+ describe file('/') do
279
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
280
+ it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) }
281
+ end
282
+
283
+ describe file('/') do
284
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
285
+ it { should_not be_mounted.with( :type => 'xfs' ) }
286
+ end
287
+
288
+ describe file('/') do
289
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
290
+ it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) }
291
+ end
292
+
293
+ describe file('/') do
294
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
295
+ it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) }
296
+ end
297
+
298
+ describe file('/') do
299
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
300
+ it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) }
301
+ end
302
+
303
+ describe file('/') do
304
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
305
+ it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) }
306
+ end
307
+
308
+ describe file('/etc/invalid-mount') do
309
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
310
+ it { should_not be_mounted.with( :type => 'ext4' ) }
311
+ end
312
+
313
+ describe file('/') do
314
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
315
+ it do
316
+ should be_mounted.only_with(
317
+ :device => '/dev/mapper/VolGroup-lv_root',
318
+ :type => 'ext4',
319
+ :options => {
320
+ :rw => true,
321
+ :mode => 620,
322
+ }
323
+ )
324
+ end
325
+ end
326
+
327
+ describe file('/') do
328
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
329
+ it do
330
+ should_not be_mounted.only_with(
331
+ :device => '/dev/mapper/VolGroup-lv_root',
332
+ :type => 'ext4',
333
+ :options => {
334
+ :rw => true,
335
+ :mode => 620,
336
+ :bind => true,
337
+ }
338
+ )
339
+ end
340
+ end
341
+
342
+ describe file('/') do
343
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
344
+ it do
345
+ should_not be_mounted.only_with(
346
+ :device => '/dev/mapper/VolGroup-lv_root',
347
+ :type => 'ext4',
348
+ :options => {
349
+ :rw => true,
350
+ }
351
+ )
352
+ end
353
+ end
354
+
355
+ describe file('/') do
356
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
357
+ it do
358
+ should_not be_mounted.only_with(
359
+ :device => '/dev/mapper/VolGroup-lv_roooooooooot',
360
+ :type => 'ext4',
361
+ :options => {
362
+ :rw => true,
363
+ :mode => 620,
364
+ }
365
+ )
366
+ end
367
+ end
368
+
369
+ describe file('/etc/invalid-mount') do
370
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
371
+ it { should_not be_mounted.only_with( :type => 'ext4' ) }
372
+ end
373
+
374
+ describe file('/etc/services') do
375
+ it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' }
376
+ its(:command) { should eq "md5sum /etc/services | grep -iw -- ^35435ea447c19f0ea5ef971837ab9ced" }
377
+ end
378
+
379
+ describe file('invalid-file') do
380
+ it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' }
381
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Solaris11
4
+
5
+ describe 'Serverspec user matchers of Solaris11 family' do
6
+ it_behaves_like 'support group exist matcher', 'root'
7
+ it_behaves_like 'support group have_gid matcher', 'root', 0
8
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Solaris11
4
+
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 5" }
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 1" }
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 -w 1 127.0.0.1 22" }
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 -w 1 127.0.0.1 53" }
54
+ end
55
+
56
+ describe host('invalid-host') do
57
+ it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) }
58
+ end