serverspec 0.6.20 → 0.6.21

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.
@@ -2,40 +2,380 @@ require 'spec_helper'
2
2
 
3
3
  include Serverspec::Helper::Solaris
4
4
 
5
- describe 'Serverspec file matchers of Solaris family' do
6
- it_behaves_like 'support file be_file matcher', '/etc/ssh/sshd_config'
7
- it_behaves_like 'support file be_directory matcher', '/etc/ssh'
8
- it_behaves_like 'support file be_socket matcher', '/var/run/unicorn.sock'
9
- it_behaves_like 'support file contain matcher', '/etc/ssh/sshd_config', 'This is the sshd server system-wide configuration file'
10
- it_behaves_like 'support file contain from to matcher', 'Gemfile', 'rspec', /^group :test do/, /^end/
11
- it_behaves_like 'support file contain after matcher', 'Gemfile', 'rspec', /^group :test do/
12
- it_behaves_like 'support file contain before matcher', 'Gemfile', 'rspec', /^end/
13
- it_behaves_like 'support file be_mode matcher', '/etc/passwd', 644
14
- it_behaves_like 'support file be_owned_by matcher', '/etc/passwd', 'root'
15
- it_behaves_like 'support file be_grouped_into matcher', '/etc/passwd', 'root'
16
- it_behaves_like 'support file be_linked_to matcher', '/etc/pam.d/system-auth', '/etc/pam.d/system-auth-ac'
17
-
18
- it_behaves_like 'support file be_readable matcher', '/dev'
19
- it_behaves_like 'support file be_readable by owner matcher', '/dev'
20
- it_behaves_like 'support file be_readable by group matcher', '/dev'
21
- it_behaves_like 'support file be_readable by others matcher', '/dev'
22
- it_behaves_like 'support file be_readable by specific user matcher', '/tmp', 'mail'
23
-
24
- it_behaves_like 'support file be_writable matcher', '/dev'
25
- it_behaves_like 'support file be_writable by owner matcher', '/dev'
26
- it_behaves_like 'support file be_writable by group matcher', '/dev'
27
- it_behaves_like 'support file be_writable by others matcher', '/dev'
28
- it_behaves_like 'support file be_writable by specific user matcher', '/tmp', 'mail'
29
-
30
- it_behaves_like 'support file be_executable matcher', '/dev'
31
- it_behaves_like 'support file be_executable by owner matcher', '/dev'
32
- it_behaves_like 'support file be_executable by group matcher', '/dev'
33
- it_behaves_like 'support file be_executable by others matcher', '/dev'
34
- it_behaves_like 'support file be_executable by specific user matcher', '/tmp', 'mail'
35
-
36
- it_behaves_like 'support file be_mounted matcher', '/'
37
- it_behaves_like 'support file be_mounted with matcher', '/'
38
- it_behaves_like 'support file be_mounted only with matcher', '/'
39
-
40
- it_behaves_like 'support file match_md5checksum matcher', '/etc/services', '35435ea447c19f0ea5ef971837ab9ced'
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' }
41
381
  end
@@ -3,37 +3,19 @@ require 'spec_helper'
3
3
  include Serverspec::Helper::Solaris10
4
4
 
5
5
  describe 'Serverspec commands of Solaris family' do
6
- it_behaves_like 'support command check_file', '/etc/passwd'
7
- it_behaves_like 'support command check_directory', '/var/log'
8
- it_behaves_like 'support command check_socket', '/var/run/unicorn.sock'
9
-
10
- it_behaves_like 'support command check_mounted', '/'
11
-
12
6
  it_behaves_like 'support command check_user', 'root'
13
7
  it_behaves_like 'support command check_user', 'wheel'
14
8
 
15
- it_behaves_like 'support command check_file_md5checksum', '/etc/passewd', '96c8c50f81a29965f7af6de371ab4250'
16
-
17
9
  it_behaves_like 'support command check_running_under_supervisor', 'httpd'
18
10
  it_behaves_like 'support command check_monitored_by_monit', 'unicorn'
19
11
  it_behaves_like 'support command check_process', 'httpd'
20
12
 
21
- it_behaves_like 'support command check_file_contain', '/etc/passwd', 'root'
22
-
23
- it_behaves_like 'support command check_mode', '/etc/sudoers', 440
24
- it_behaves_like 'support command check_owner', '/etc/sudoers', 'root'
25
- it_behaves_like 'support command check_grouped', '/etc/sudoers', 'wheel'
26
-
27
- it_behaves_like 'support command check_link', '/etc/system-release', '/etc/redhat-release'
28
-
29
13
  it_behaves_like 'support command check_uid', 'root', 0
30
14
 
31
15
  it_behaves_like 'support command check_login_shell', 'root', '/bin/bash'
32
16
  it_behaves_like 'support command check_home_directory', 'root', '/root'
33
17
 
34
18
  it_behaves_like 'support command check_authorized_key'
35
-
36
- it_behaves_like 'support command get_mode'
37
19
  end
38
20
 
39
21
  describe 'check_enabled' do
@@ -41,28 +23,6 @@ describe 'check_enabled' do
41
23
  it { should eq "svcs -l httpd 2> /dev/null | grep -wx '^enabled.*true$'" }
42
24
  end
43
25
 
44
- describe 'check_file_contain_within' do
45
- context 'contain a pattern in the file' do
46
- subject { commands.check_file_contain_within('Gemfile', 'rspec') }
47
- it { should eq "sed -n 1,\\$p Gemfile | grep -q -- rspec /dev/stdin" }
48
- end
49
-
50
- context 'contain a pattern after a line in a file' do
51
- subject { commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test do/') }
52
- it { should eq "sed -n /\\^group\\ :test\\ do/,\\$p Gemfile | grep -q -- rspec /dev/stdin" }
53
- end
54
-
55
- context 'contain a pattern before a line in a file' do
56
- subject {commands.check_file_contain_within('Gemfile', 'rspec', nil, '/^end/') }
57
- it { should eq "sed -n 1,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin" }
58
- end
59
-
60
- context 'contain a pattern from within a line and another line in a file' do
61
- subject { commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test do/', '/^end/') }
62
- it { should eq "sed -n /\\^group\\ :test\\ do/,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin" }
63
- end
64
- end
65
-
66
26
  describe 'check_running' do
67
27
  subject { commands.check_running('httpd') }
68
28
  it { should eq "svcs -l httpd status 2> /dev/null |grep -wx '^state.*online$'" }
@@ -119,20 +79,3 @@ describe 'check_svcprops' do
119
79
  }
120
80
  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\\$" }
121
81
  end
122
-
123
- describe 'check_access_by_user' do
124
- context 'read access' do
125
- subject {commands.check_access_by_user '/tmp/something', 'dummyuser1', 'r'}
126
- it { should eq 'su dummyuser1 -c "test -r /tmp/something"' }
127
- end
128
-
129
- context 'write access' do
130
- subject {commands.check_access_by_user '/tmp/somethingw', 'dummyuser2', 'w'}
131
- it { should eq 'su dummyuser2 -c "test -w /tmp/somethingw"' }
132
- end
133
-
134
- context 'execute access' do
135
- subject {commands.check_access_by_user '/tmp/somethingx', 'dummyuser3', 'x'}
136
- it { should eq 'su dummyuser3 -c "test -x /tmp/somethingx"' }
137
- end
138
- end
@@ -1,23 +1,3 @@
1
- shared_examples_for 'support command check_file' do |file|
2
- subject { commands.check_file(file) }
3
- it { should eq "test -f #{file}" }
4
- end
5
-
6
- shared_examples_for 'support command check_directory' do |dir|
7
- subject { commands.check_directory(dir) }
8
- it { should eq "test -d #{dir}" }
9
- end
10
-
11
- shared_examples_for 'support command check_socket' do |socket|
12
- subject { commands.check_socket(socket) }
13
- it { should eq "test -S #{socket}" }
14
- end
15
-
16
- shared_examples_for 'support command check_mounted' do |path|
17
- subject { commands.check_mounted('/') }
18
- it { should eq "mount | grep -w -- on\\ #{path}" }
19
- end
20
-
21
1
  shared_examples_for 'support command check_user' do |user|
22
2
  subject { commands.check_user(user) }
23
3
  it { should eq "id #{user}" }
@@ -27,12 +7,6 @@ shared_examples_for 'support command check_group' do |group|
27
7
  subject { commands.check_group(group) }
28
8
  it { should eq "getent group | grep -wq -- #{group}" }
29
9
  end
30
-
31
- shared_examples_for 'support command check_file_md5checksum' do |file, md5sum|
32
- subject { commands.check_file_md5checksum(file, md5sum) }
33
- it { should eq "md5sum #{file} | grep -iw -- ^#{md5sum}" }
34
- end
35
-
36
10
  shared_examples_for 'support command check_running_under_supervisor' do |service|
37
11
  subject { commands.check_running_under_supervisor(service) }
38
12
  it { should eq "supervisorctl status #{service}" }
@@ -54,53 +28,6 @@ shared_examples_for 'support command check_process' do |process|
54
28
  it { should eq "ps aux | grep -w -- #{process} | grep -qv grep" }
55
29
  end
56
30
 
57
- shared_examples_for 'support command check_file_contain' do |file, content|
58
- subject { commands.check_file_contain(file, content) }
59
- it { should eq "grep -q -- #{content} #{file}" }
60
- end
61
-
62
- shared_examples_for 'support command check_file_contain_within' do
63
- context 'contain a pattern in the file' do
64
- subject { commands.check_file_contain_within('Gemfile', 'rspec') }
65
- it { should eq "sed -n 1,\\$p Gemfile | grep -q -- rspec -" }
66
- end
67
-
68
- context 'contain a pattern after a line in a file' do
69
- subject { commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test do/') }
70
- it { should eq "sed -n /\\^group\\ :test\\ do/,\\$p Gemfile | grep -q -- rspec -" }
71
- end
72
-
73
- context 'contain a pattern before a line in a file' do
74
- subject {commands.check_file_contain_within('Gemfile', 'rspec', nil, '/^end/') }
75
- it { should eq "sed -n 1,/\\^end/p Gemfile | grep -q -- rspec -" }
76
- end
77
-
78
- context 'contain a pattern from within a line and another line in a file' do
79
- subject { commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test do/', '/^end/') }
80
- it { should eq "sed -n /\\^group\\ :test\\ do/,/\\^end/p Gemfile | grep -q -- rspec -" }
81
- end
82
- end
83
-
84
- shared_examples_for 'support command check_mode' do |file, mode|
85
- subject { commands.check_mode(file, mode) }
86
- it { should eq "stat -c %a #{file} | grep -- \\^#{mode}\\$" }
87
- end
88
-
89
- shared_examples_for 'support command check_owner' do |file, owner|
90
- subject { commands.check_owner(file, owner) }
91
- it { should eq "stat -c %U #{file} | grep -- \\^#{owner}\\$" }
92
- end
93
-
94
- shared_examples_for 'support command check_grouped' do |file, group|
95
- subject { commands.check_grouped(file, group) }
96
- it { should eq "stat -c %G #{file} | grep -- \\^#{group}\\$" }
97
- end
98
-
99
- shared_examples_for 'support command check_link' do |link, target|
100
- subject { commands.check_link(link, target) }
101
- it { should eq "stat -c %N #{link} | grep -- #{target}" }
102
- end
103
-
104
31
  shared_examples_for 'support command check_belonging_group' do |user, group|
105
32
  subject { commands.check_belonging_group(user, group) }
106
33
  it { should eq "id #{user} | awk '{print $3}' | grep -- #{group}" }
@@ -143,47 +70,3 @@ shared_examples_for 'support command check_authorized_key' do
143
70
  it { should eq "grep -w -- #{escaped_key} ~root/.ssh/authorized_keys" }
144
71
  end
145
72
  end
146
-
147
- shared_examples_for 'support command check_selinux' do
148
- context 'enforcing' do
149
- subject { commands.check_selinux('enforcing') }
150
- it { should eq "getenforce | grep -i -- enforcing && grep -i -- ^SELINUX=enforcing$ /etc/selinux/config" }
151
- end
152
-
153
- context 'permissive' do
154
- subject { commands.check_selinux('permissive') }
155
- it { should eq "getenforce | grep -i -- permissive && grep -i -- ^SELINUX=permissive$ /etc/selinux/config" }
156
- end
157
-
158
- context 'disabled' do
159
- subject { commands.check_selinux('disabled') }
160
- it { should eq "getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config" }
161
- end
162
- end
163
-
164
- shared_examples_for 'support command get_mode' do
165
- subject { commands.get_mode('/dev') }
166
- it { should eq 'stat -c %a /dev' }
167
- end
168
-
169
- shared_examples_for 'support command check_access_by_user' do
170
- context 'read access' do
171
- subject {commands.check_access_by_user '/tmp/something', 'dummyuser1', 'r'}
172
- it { should eq 'su -c "test -r /tmp/something" dummyuser1' }
173
- end
174
-
175
- context 'write access' do
176
- subject {commands.check_access_by_user '/tmp/somethingw', 'dummyuser2', 'w'}
177
- it { should eq 'su -c "test -w /tmp/somethingw" dummyuser2' }
178
- end
179
-
180
- context 'execute access' do
181
- subject {commands.check_access_by_user '/tmp/somethingx', 'dummyuser3', 'x'}
182
- it { should eq 'su -c "test -x /tmp/somethingx" dummyuser3' }
183
- end
184
- end
185
-
186
- shared_examples_for 'support command check_kernel_module_loaded' do |name|
187
- subject { commands.check_kernel_module_loaded(name) }
188
- it { should eq "lsmod | grep ^#{name}" }
189
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.20
4
+ version: 0.6.21
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-03 00:00:00.000000000 Z
12
+ date: 2013-07-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh
@@ -300,10 +300,7 @@ files:
300
300
  - spec/solaris10/commands_spec.rb
301
301
  - spec/spec_helper.rb
302
302
  - spec/support/shared_commands_examples.rb
303
- - spec/support/shared_file_examples.rb
304
303
  - spec/support/shared_group_examples.rb
305
- - spec/support/shared_kernel_module_examples.rb
306
- - spec/support/shared_selinux_examples.rb
307
304
  - spec/support/shared_service_examples.rb
308
305
  - spec/support/shared_user_examples.rb
309
306
  homepage: http://serverspec.org/
@@ -419,9 +416,6 @@ test_files:
419
416
  - spec/solaris10/commands_spec.rb
420
417
  - spec/spec_helper.rb
421
418
  - spec/support/shared_commands_examples.rb
422
- - spec/support/shared_file_examples.rb
423
419
  - spec/support/shared_group_examples.rb
424
- - spec/support/shared_kernel_module_examples.rb
425
- - spec/support/shared_selinux_examples.rb
426
420
  - spec/support/shared_service_examples.rb
427
421
  - spec/support/shared_user_examples.rb