serverspec 0.11.3 → 0.11.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d315fb2da1b76be74f7b32560873a49931af7052
4
- data.tar.gz: 56a28ae00fef7fd520b063ded1b0bc0ea62dc19b
3
+ metadata.gz: 8dce4e86b84179092d0bf63b787374d0cc38b7e6
4
+ data.tar.gz: ed43fa1414a39edca1459b5adb94b05d3583d891
5
5
  SHA512:
6
- metadata.gz: 29528238581e4e70a33a2abcaa0859c000d8682ae4fcd3508ec381058dc582affe5a098c94d1074ac2103c39f89c5679ae9e4990d229c5c044951b0075b14325
7
- data.tar.gz: 22b95a93671e7dc17085943c800cf0a6a5da03f748e5d79dcc05928894b900ff9b797fe113801e63bc77cebaf88090afc87f2dd758c5eb1dbab3dbfee3afe82d
6
+ metadata.gz: 0bc46ed517a84561dc1b0254dafd59157501d92e43627b1127c0acaf37e5039bd33fbf8938e7ad2b531ea73f9ba02574d2871f3c16b68eee76c7c854f2e09ceb
7
+ data.tar.gz: a39d75293aaa0f171dc526da9200651d7b8f58a08882523abf8e182ca5ba0749e9cc8537df63b2323d6ff6fcf02f4b28cce7ab04408ec02a31a04c675cc2e062
data/WINDOWS_SUPPORT.md CHANGED
@@ -94,4 +94,5 @@ end
94
94
  ###Notes:
95
95
  * Not all the matchers you are used to in Linux-like OS are supported in Windows, some because of differences between the operating systems (e.g. users and permissions model), some because they haven't been yet implemented.
96
96
  * All commands in the windows backend are run via powershell, so the output in case of stderr is a pretty ugly xml-like thing. Still it should contain some information to help troubleshooting.
97
- * The *command* type is executed again through powershell, so bear that in mind if you mean to run old CMD windows batch or programs. (i.e run the command using the **Invoke-Expression** Cmdlet, or the **&** Call Operator)
97
+ * The *command* type is executed again through powershell, so bear that in mind if you mean to run old CMD windows batch or programs. (i.e run the command using the **Invoke-Expression** Cmdlet, or the **&** Call Operator)
98
+ * You may have to change Exectution Policy on the machine at both, machine and user level in order for tests to run: Get-ExecutionPolicy -list|%{set-executionpolicy bypass -scope $_.scope}
@@ -2,6 +2,77 @@ module Serverspec
2
2
  module Commands
3
3
  class Solaris10 < Solaris
4
4
  # Please implement Solaris 10 specific commands
5
+
6
+ # reference: http://perldoc.perl.org/functions/stat.html
7
+ def check_mode(file, mode)
8
+ regexp = "^#{mode}$"
9
+ "perl -e 'printf \"%o\", (stat shift)[2]&07777' #{escape(file)} | grep -- #{escape(regexp)}"
10
+ end
11
+
12
+ # reference: http://perldoc.perl.org/functions/stat.html
13
+ # http://www.tutorialspoint.com/perl/perl_getpwuid.htm
14
+ def check_owner(file, owner)
15
+ regexp = "^#{owner}$"
16
+ "perl -e 'printf \"%s\", getpwuid((stat(\"#{escape(file)}\"))[4])' | grep -- #{escape(regexp)}"
17
+ end
18
+
19
+ def check_group(group)
20
+ "getent group | grep -w -- #{escape(group)}"
21
+ end
22
+
23
+ # reference: http://perldoc.perl.org/functions/stat.html
24
+ # http://www.tutorialspoint.com/perl/perl_getgrgid.htm
25
+ def check_grouped(file, group)
26
+ regexp = "^#{group}$"
27
+ "perl -e 'printf \"%s\", getgrgid((stat(\"#{escape(file)}\"))[5])' | grep -- #{escape(regexp)}"
28
+ end
29
+
30
+ # reference: http://www.tutorialspoint.com/perl/perl_readlink.htm
31
+ def check_link(link, target)
32
+ regexp = "^#{target}$"
33
+ "perl -e 'printf \"%s\", readlink(\"#{escape(link)}\")' | grep -- #{escape(regexp)}"
34
+ end
35
+
36
+ # reference: http://perldoc.perl.org/functions/stat.html
37
+ def get_mode(file)
38
+ "perl -e 'printf \"%o\", (stat shift)[2]&07777' #{escape(file)}"
39
+ end
40
+
41
+ def check_file_contain(file, expected_pattern)
42
+ "grep -- #{escape(expected_pattern)} #{escape(file)}"
43
+ end
44
+
45
+ def check_reachable(host, port, proto, timeout)
46
+ if port.nil?
47
+ "ping -n #{escape(host)} #{escape(timeout)}"
48
+ elsif proto == 'tcp'
49
+ "echo 'quit' | mconnect -p #{escape(port)} #{escape(host)} > /dev/null 2>&1"
50
+ else
51
+ raise NotImplementedError.new
52
+ end
53
+ end
54
+
55
+ def check_installed(package, version=nil)
56
+ cmd = "pkginfo -q #{escape(package)}"
57
+ if version
58
+ cmd = "#{cmd} | grep -- #{escape(version)}"
59
+ end
60
+ cmd
61
+ end
62
+
63
+ def check_file_md5checksum(file, expected)
64
+ "digest -a md5 -v #{escape(file)} | grep -iw -- #{escape(expected)}"
65
+ end
66
+
67
+ def check_belonging_group(user, group)
68
+ "id -ap #{escape(user)} | grep -- #{escape(group)}"
69
+ end
70
+
71
+ def check_authorized_key(user, key)
72
+ key.sub!(/\s+\S*$/, '') if key.match(/^\S+\s+\S+\s+\S*$/)
73
+ "grep -- #{escape(key)} ~#{escape(user)}/.ssh/authorized_keys"
74
+ end
75
+
5
76
  end
6
77
  end
7
78
  end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.11.3"
2
+ VERSION = "0.11.4"
3
3
  end
@@ -0,0 +1,395 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Solaris10
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 -- 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 contain /^This is the sshd server system-wide configuration file/ }
39
+ its(:command) { should eq "grep -- \\^This\\ is\\ the\\ sshd\\ server\\ system-wide\\ configuration\\ file /etc/ssh/sshd_config" }
40
+ end
41
+
42
+ describe file('/etc/ssh/sshd_config') do
43
+ it { should_not contain 'This is invalid text!!' }
44
+ end
45
+
46
+ describe file('Gemfile') do
47
+ it { should contain('rspec').from(/^group :test do/).to(/^end/) }
48
+ its(:command) { should eq "sed -n /\\^group\\ :test\\ do/,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin || sed -n /\\^group\\ :test\\ do/,/\\^end/p Gemfile | grep -qF -- rspec /dev/stdin" }
49
+ end
50
+
51
+ describe file('/etc/ssh/sshd_config') do
52
+ it { should_not contain('This is invalid text!!').from(/^group :test do/).to(/^end/) }
53
+ end
54
+
55
+ describe file('Gemfile') do
56
+ it { should contain('rspec').after(/^group :test do/) }
57
+ its(:command) { should eq "sed -n /\\^group\\ :test\\ do/,\\$p Gemfile | grep -q -- rspec /dev/stdin || sed -n /\\^group\\ :test\\ do/,\\$p Gemfile | grep -qF -- rspec /dev/stdin" }
58
+ end
59
+
60
+ describe file('/etc/ssh/sshd_config') do
61
+ it { should_not contain('This is invalid text!!').after(/^group :test do/) }
62
+ end
63
+
64
+ describe file('Gemfile') do
65
+ it { should contain('rspec').before(/^end/) }
66
+ its(:command) { should eq "sed -n 1,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin || sed -n 1,/\\^end/p Gemfile | grep -qF -- rspec /dev/stdin" }
67
+ end
68
+
69
+ describe file('/etc/ssh/sshd_config') do
70
+ it { should_not contain('This is invalid text!!').before(/^end/) }
71
+ end
72
+
73
+ describe file('/etc/passwd') do
74
+ it { should be_mode 644 }
75
+ its(:command) { should eq "perl -e 'printf \"%o\", (stat shift)[2]&07777' /etc/passwd | grep -- \\^644\\$" }
76
+ end
77
+
78
+ describe file('/etc/passwd') do
79
+ it { should_not be_mode 'invalid' }
80
+ end
81
+
82
+ describe file('/etc/passwd') do
83
+ it { should be_owned_by 'root' }
84
+ its(:command) { should eq "perl -e 'printf \"%s\", getpwuid((stat(\"/etc/passwd\"))[4])' | grep -- \\^root\\$" }
85
+ end
86
+
87
+ describe file('/etc/passwd') do
88
+ it { should_not be_owned_by 'invalid-owner' }
89
+ end
90
+
91
+ describe file('/etc/passwd') do
92
+ it { should be_grouped_into 'root' }
93
+ its(:command) { should eq "perl -e 'printf \"%s\", getgrgid((stat(\"/etc/passwd\"))[5])' | grep -- \\^root\\$" }
94
+ end
95
+
96
+ describe file('/etc/passwd') do
97
+ it { should_not be_grouped_into 'invalid-group' }
98
+ end
99
+
100
+ describe file('/etc/pam.d/system-auth') do
101
+ it { should be_linked_to '/etc/pam.d/system-auth-ac' }
102
+ its(:command) { should eq "perl -e 'printf \"%s\", readlink(\"/etc/pam.d/system-auth\")' | grep -- \\^/etc/pam.d/system-auth-ac\\$" }
103
+ end
104
+
105
+ describe file('dummy-link') do
106
+ it { should_not be_linked_to '/invalid/target' }
107
+ end
108
+
109
+ describe file('/dev') do
110
+ let(:stdout) { "755\r\n" }
111
+ it { should be_readable }
112
+ its(:command) { should eq "perl -e 'printf \"%o\", (stat shift)[2]&07777' /dev" }
113
+ end
114
+
115
+ describe file('/dev') do
116
+ let(:stdout) { "333\r\n" }
117
+ it { should_not be_readable }
118
+ end
119
+
120
+ describe file('/dev') do
121
+ let(:stdout) { "400\r\n" }
122
+ it { should be_readable.by('owner') }
123
+ end
124
+
125
+ describe file('/dev') do
126
+ let(:stdout) { "044\r\n" }
127
+ it { should_not be_readable.by('owner') }
128
+ end
129
+
130
+ describe file('/dev') do
131
+ let(:stdout) { "040\r\n" }
132
+ it { should be_readable.by('group') }
133
+ end
134
+
135
+ describe file('/dev') do
136
+ let(:stdout) { "404\r\n" }
137
+ it { should_not be_readable.by('group') }
138
+ end
139
+
140
+ describe file('/dev') do
141
+ let(:stdout) { "044\r\n" }
142
+ it { should be_readable.by('others') }
143
+ end
144
+
145
+ describe file('/dev') do
146
+ let(:stdout) { "443\r\n" }
147
+ it { should_not be_readable.by('others') }
148
+ end
149
+
150
+ describe file('/tmp') do
151
+ it { should be_readable.by_user('mail') }
152
+ its(:command) { should eq "su mail -c \"test -r /tmp\"" }
153
+ end
154
+
155
+ describe file('/tmp') do
156
+ it { should_not be_readable.by_user('invalid-user') }
157
+ end
158
+
159
+ describe file('/dev') do
160
+ let(:stdout) { "755\r\n" }
161
+ it { should be_writable }
162
+ its(:command) { should eq "perl -e 'printf \"%o\", (stat shift)[2]&07777' /dev" }
163
+ end
164
+
165
+ describe file('/dev') do
166
+ let(:stdout) { "555\r\n" }
167
+ it { should_not be_writable }
168
+ end
169
+
170
+ describe file('/dev') do
171
+ let(:stdout) { "200\r\n" }
172
+ it { should be_writable.by('owner') }
173
+ end
174
+
175
+ describe file('/dev') do
176
+ let(:stdout) { "555\r\n" }
177
+ it { should_not be_writable.by('owner') }
178
+ end
179
+
180
+ describe file('/dev') do
181
+ let(:stdout) { "030\r\n" }
182
+ it { should be_writable.by('group') }
183
+ end
184
+
185
+ describe file('/dev') do
186
+ let(:stdout) { "555\r\n" }
187
+ it { should_not be_writable.by('group') }
188
+ end
189
+
190
+ describe file('/dev') do
191
+ let(:stdout) { "666\r\n" }
192
+ it { should be_writable.by('others') }
193
+ end
194
+
195
+ describe file('/dev') do
196
+ let(:stdout) { "555\r\n" }
197
+ it { should_not be_writable.by('others') }
198
+ end
199
+
200
+ describe file('/tmp') do
201
+ it { should be_writable.by_user('mail') }
202
+ its(:command) { should eq "su mail -c \"test -w /tmp\"" }
203
+ end
204
+
205
+ describe file('/tmp') do
206
+ it { should_not be_writable.by_user('invalid-user') }
207
+ end
208
+
209
+ describe file('/dev') do
210
+ let(:stdout) { "755\r\n" }
211
+ it { should be_executable }
212
+ its(:command) { should eq "perl -e 'printf \"%o\", (stat shift)[2]&07777' /dev" }
213
+ end
214
+
215
+ describe file('/dev') do
216
+ let(:stdout) { "666\r\n" }
217
+ it { should_not be_executable }
218
+ end
219
+
220
+ describe file('/dev') do
221
+ let(:stdout) { "100\r\n" }
222
+ it { should be_executable.by('owner') }
223
+ end
224
+
225
+ describe file('/dev') do
226
+ let(:stdout) { "666\r\n" }
227
+ it { should_not be_executable.by('owner') }
228
+ end
229
+
230
+ describe file('/dev') do
231
+ let(:stdout) { "070\r\n" }
232
+ it { should be_executable.by('group') }
233
+ end
234
+
235
+ describe file('/dev') do
236
+ let(:stdout) { "666\r\n" }
237
+ it { should_not be_executable.by('group') }
238
+ end
239
+
240
+ describe file('/dev') do
241
+ let(:stdout) { "001\r\n" }
242
+ it { should be_executable.by('others') }
243
+ end
244
+
245
+ describe file('/dev') do
246
+ let(:stdout) { "666\r\n" }
247
+ it { should_not be_executable.by('others') }
248
+ end
249
+
250
+ describe file('/tmp') do
251
+ it { should be_executable.by_user('mail') }
252
+ its(:command) { should eq "su mail -c \"test -x /tmp\"" }
253
+ end
254
+
255
+ describe file('/tmp') do
256
+ it { should_not be_executable.by_user('invalid-user') }
257
+ end
258
+
259
+ describe file('/') do
260
+ it { should be_mounted }
261
+ its(:command) { should eq "mount | grep -w -- on\\ /" }
262
+ end
263
+
264
+ describe file('/etc/invalid-mount') do
265
+ it { should_not be_mounted }
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' ) }
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 => { :rw => true } ) }
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', :options => { :mode => 620 } ) }
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 be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) }
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 => 'xfs' ) }
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 => { :rw => false } ) }
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 => 'ext4', :options => { :mode => 600 } ) }
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 => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) }
306
+ end
307
+
308
+ describe file('/') 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', :device => '/dev/mapper/VolGroup-lv_r00t' ) }
311
+ end
312
+
313
+ describe file('/etc/invalid-mount') do
314
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
315
+ it { should_not be_mounted.with( :type => 'ext4' ) }
316
+ end
317
+
318
+ describe file('/') do
319
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
320
+ it do
321
+ should be_mounted.only_with(
322
+ :device => '/dev/mapper/VolGroup-lv_root',
323
+ :type => 'ext4',
324
+ :options => {
325
+ :rw => true,
326
+ :mode => 620,
327
+ }
328
+ )
329
+ end
330
+ end
331
+
332
+ describe file('/') do
333
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
334
+ it do
335
+ should_not be_mounted.only_with(
336
+ :device => '/dev/mapper/VolGroup-lv_root',
337
+ :type => 'ext4',
338
+ :options => {
339
+ :rw => true,
340
+ :mode => 620,
341
+ :bind => true,
342
+ }
343
+ )
344
+ end
345
+ end
346
+
347
+ describe file('/') do
348
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
349
+ it do
350
+ should_not be_mounted.only_with(
351
+ :device => '/dev/mapper/VolGroup-lv_root',
352
+ :type => 'ext4',
353
+ :options => {
354
+ :rw => true,
355
+ }
356
+ )
357
+ end
358
+ end
359
+
360
+ describe file('/') do
361
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
362
+ it do
363
+ should_not be_mounted.only_with(
364
+ :device => '/dev/mapper/VolGroup-lv_roooooooooot',
365
+ :type => 'ext4',
366
+ :options => {
367
+ :rw => true,
368
+ :mode => 620,
369
+ }
370
+ )
371
+ end
372
+ end
373
+
374
+ describe file('/etc/invalid-mount') do
375
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
376
+ it { should_not be_mounted.only_with( :type => 'ext4' ) }
377
+ end
378
+
379
+ describe file('/etc/services') do
380
+ it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' }
381
+ its(:command) { should eq "digest -a md5 -v /etc/services | grep -iw -- 35435ea447c19f0ea5ef971837ab9ced" }
382
+ end
383
+
384
+ describe file('invalid-file') do
385
+ it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' }
386
+ end
387
+
388
+ describe file('/etc/services') do
389
+ it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' }
390
+ its(:command) { should eq "sha256sum /etc/services | grep -iw -- \\^0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" }
391
+ end
392
+
393
+ describe file('invalid-file') do
394
+ it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
395
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Solaris10
4
+
5
+ describe group('root') do
6
+ it { should exist }
7
+ its(:command) { should eq "getent group | grep -w -- root" }
8
+ end
9
+
10
+ describe group('invalid-group') do
11
+ it { should_not exist }
12
+ end
13
+
14
+ describe group('root') do
15
+ it { should have_gid 0 }
16
+ its(:command) { should eq "getent group | grep -- \\^root: | cut -f 3 -d ':' | grep -w -- 0" }
17
+ end
18
+
19
+ describe group('root') do
20
+ it { should_not have_gid 'invalid-gid' }
21
+ end
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Solaris10
4
+
5
+ describe package('httpd') do
6
+ it { should be_installed }
7
+ its(:command) { should eq "pkginfo -q httpd" }
8
+ end
9
+
10
+ describe package('invalid-package') do
11
+ it { should_not be_installed }
12
+ end
13
+
14
+ describe package('httpd') do
15
+ it { should be_installed.with_version('2.2') }
16
+ its(:command) { should eq "pkginfo -q httpd | grep -- 2.2" }
17
+ end
18
+
19
+ describe package('httpd') do
20
+ it { should_not be_installed.with_version('invalid-version') }
21
+ end
22
+
23
+ describe package('jekyll') do
24
+ it { should be_installed.by('gem') }
25
+ its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" }
26
+ end
27
+
28
+ describe package('invalid-gem') do
29
+ it { should_not be_installed.by('gem') }
30
+ end
31
+
32
+ describe package('jekyll') do
33
+ it { should be_installed.by('gem').with_version('1.1.1') }
34
+ its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" }
35
+ end
36
+
37
+ describe package('jekyll') do
38
+ it { should_not be_installed.by('gem').with_version('invalid-version') }
39
+ end
40
+
41
+ describe package('bower') do
42
+ it { should be_installed.by('npm') }
43
+ its(:command) { should eq "npm ls bower -g" }
44
+ end
45
+
46
+ describe package('invalid-npm-package') do
47
+ it { should_not be_installed.by('npm') }
48
+ end
49
+
50
+ describe package('bower') do
51
+ it { should be_installed.by('npm').with_version('0.9.2') }
52
+ its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" }
53
+ end
54
+
55
+ describe package('bower') do
56
+ it { should_not be_installed.by('npm').with_version('invalid-version') }
57
+ end
58
+
59
+
60
+ describe package('mongo') do
61
+ it { should be_installed.by('pecl') }
62
+ its(:command) { should eq "pecl list | grep -w -- \\^mongo" }
63
+ end
64
+
65
+ describe package('invalid-pecl') do
66
+ it { should_not be_installed.by('pecl') }
67
+ end
68
+
69
+ describe package('mongo') do
70
+ it { should be_installed.by('pecl').with_version('1.4.1') }
71
+ its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" }
72
+ end
73
+
74
+ describe package('mongo') do
75
+ it { should_not be_installed.by('pecl').with_version('invalid-version') }
76
+ end
77
+
78
+ describe package('supervisor') do
79
+ it { should be_installed.by('pip').with_version('3.0') }
80
+ its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" }
81
+ end
82
+
83
+ describe package('invalid-pip') do
84
+ it { should_not be_installed.by('pip').with_version('invalid-version') }
85
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Solaris10
4
+
5
+ describe user('root') do
6
+ it { should exist }
7
+ its(:command) { should eq "id root" }
8
+ end
9
+
10
+ describe user('invalid-user') do
11
+ it { should_not exist }
12
+ end
13
+
14
+ describe user('root') do
15
+ it { should belong_to_group 'root' }
16
+ its(:command) { should eq "id -ap root | grep -- root" }
17
+ end
18
+
19
+ describe user('root') do
20
+ it { should_not belong_to_group 'invalid-group' }
21
+ end
22
+
23
+ describe user('root') do
24
+ it { should have_uid 0 }
25
+ its(:command) { should eq "id root | grep -- \\^uid\\=0\\(" }
26
+ end
27
+
28
+ describe user('root') do
29
+ it { should_not have_uid 'invalid-uid' }
30
+ end
31
+
32
+ describe user('root') do
33
+ it { should have_login_shell '/bin/bash' }
34
+ its(:command) { should eq "getent passwd root | cut -f 7 -d ':' | grep -w -- /bin/bash" }
35
+ end
36
+
37
+ describe user('root') do
38
+ it { should_not have_login_shell 'invalid-login-shell' }
39
+ end
40
+
41
+ describe user('root') do
42
+ it { should have_home_directory '/root' }
43
+ its(:command) { should eq "getent passwd root | cut -f 6 -d ':' | grep -w -- /root" }
44
+ end
45
+
46
+ describe user('root') do
47
+ it { should_not have_home_directory 'invalid-home-directory' }
48
+ end
49
+
50
+ describe user('root') do
51
+ it { should have_authorized_key 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local' }
52
+ its(:command) { should eq "grep -- ssh-rsa\\ ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH ~root/.ssh/authorized_keys" }
53
+ end
54
+
55
+ describe user('root') do
56
+ it { should_not have_authorized_key 'invalid-key' }
57
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-14 00:00:00.000000000 Z
11
+ date: 2013-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -353,8 +353,12 @@ files:
353
353
  - spec/solaris/svcprop_spec.rb
354
354
  - spec/solaris/user_spec.rb
355
355
  - spec/solaris/zfs_spec.rb
356
+ - spec/solaris10/file_spec.rb
357
+ - spec/solaris10/group_spec.rb
356
358
  - spec/solaris10/mail_alias_spec.rb
359
+ - spec/solaris10/package_spec.rb
357
360
  - spec/solaris10/php_config_spec.rb
361
+ - spec/solaris10/user_spec.rb
358
362
  - spec/solaris11/command_spec.rb
359
363
  - spec/solaris11/cron_spec.rb
360
364
  - spec/solaris11/default_gateway_spec.rb
@@ -554,8 +558,12 @@ test_files:
554
558
  - spec/solaris/svcprop_spec.rb
555
559
  - spec/solaris/user_spec.rb
556
560
  - spec/solaris/zfs_spec.rb
561
+ - spec/solaris10/file_spec.rb
562
+ - spec/solaris10/group_spec.rb
557
563
  - spec/solaris10/mail_alias_spec.rb
564
+ - spec/solaris10/package_spec.rb
558
565
  - spec/solaris10/php_config_spec.rb
566
+ - spec/solaris10/user_spec.rb
559
567
  - spec/solaris11/command_spec.rb
560
568
  - spec/solaris11/cron_spec.rb
561
569
  - spec/solaris11/default_gateway_spec.rb