serverspec 1.7.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +25 -20
- data/lib/serverspec/helper/os.rb +1 -0
- data/lib/serverspec/type/file.rb +7 -0
- data/lib/serverspec/version.rb +1 -1
- data/serverspec.gemspec +1 -3
- data/spec/arch/package_spec.rb +5 -0
- data/spec/darwin/port_spec.rb +1 -1
- data/spec/darwin/service_spec.rb +1 -1
- data/spec/nixos/file_spec.rb +421 -0
- data/spec/nixos/package_spec.rb +109 -0
- data/spec/nixos/service_spec.rb +40 -0
- metadata +10 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f25f83fa646e00df412c0b03654a485840171fa
|
4
|
+
data.tar.gz: 79510ae949e711812b565864a6e11473a8965e6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 750b7b972dc1ea70c7ac446e5df1a3eb7f2eba280fe3fc3c766483630dcfa8c6aaed6a1dac81186e2b76b24724ac8441dab1fbeb59561bcfb90d78eb62e1f15a
|
7
|
+
data.tar.gz: 03df2d7e047da50dd7155d121c4f8c1dbc9cb2c1776421b3253c2f447d52eca6508f40ee7ece42f4c079f07ca1e5c22f342ef02f68bca5f90f9dfce31721327c
|
data/Rakefile
CHANGED
@@ -1,32 +1,37 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
|
3
|
-
require "
|
2
|
+
begin
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
require "octorelease"
|
5
|
+
rescue LoadError
|
6
|
+
end
|
4
7
|
|
5
|
-
|
8
|
+
if defined?(RSpec)
|
9
|
+
task :spec => 'spec:all'
|
6
10
|
|
7
|
-
namespace :spec do
|
8
|
-
|
9
|
-
|
11
|
+
namespace :spec do
|
12
|
+
oses = %w( darwin debian gentoo plamo redhat redhat7 aix solaris solaris10 solaris11 smartos windows freebsd freebsd10 arch fedora ubuntu nixos)
|
13
|
+
backends = %w( exec ssh cmd winrm powershell )
|
10
14
|
|
11
|
-
|
15
|
+
task :all => [ oses.map {|os| "spec:#{os}" }, backends, :helper, :unit ].flatten
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
oses.each do |os|
|
18
|
+
RSpec::Core::RakeTask.new(os.to_sym) do |t|
|
19
|
+
t.pattern = "spec/#{os}/*_spec.rb"
|
20
|
+
end
|
16
21
|
end
|
17
|
-
end
|
18
22
|
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
backends.each do |backend|
|
24
|
+
RSpec::Core::RakeTask.new(backend) do |t|
|
25
|
+
t.pattern = "spec/backend/#{backend.to_s}/*_spec.rb"
|
26
|
+
end
|
22
27
|
end
|
23
|
-
end
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
29
|
+
RSpec::Core::RakeTask.new(:helper) do |t|
|
30
|
+
t.pattern = "spec/helper/*_spec.rb"
|
31
|
+
end
|
28
32
|
|
29
|
-
|
30
|
-
|
33
|
+
RSpec::Core::RakeTask.new(:unit) do |t|
|
34
|
+
t.pattern = "spec/unit/*_spec.rb"
|
35
|
+
end
|
31
36
|
end
|
32
37
|
end
|
data/lib/serverspec/helper/os.rb
CHANGED
data/lib/serverspec/type/file.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
1
3
|
module Serverspec
|
2
4
|
module Type
|
3
5
|
class File < Base
|
@@ -93,6 +95,11 @@ module Serverspec
|
|
93
95
|
def version?(version)
|
94
96
|
backend.check_file_version(@name, version)
|
95
97
|
end
|
98
|
+
|
99
|
+
def mtime
|
100
|
+
d = backend.get_file_mtime(@name).stdout.strip
|
101
|
+
DateTime.strptime(d, '%s')
|
102
|
+
end
|
96
103
|
end
|
97
104
|
end
|
98
105
|
end
|
data/lib/serverspec/version.rb
CHANGED
data/serverspec.gemspec
CHANGED
@@ -22,9 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_runtime_dependency "rspec", "~> 2.13"
|
23
23
|
spec.add_runtime_dependency "rspec-its"
|
24
24
|
spec.add_runtime_dependency "highline"
|
25
|
-
spec.add_runtime_dependency "specinfra", "~> 1.
|
25
|
+
spec.add_runtime_dependency "specinfra", "~> 1.17"
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
27
|
spec.add_development_dependency "rake", "~> 10.1.1"
|
28
|
-
spec.add_development_dependency "octokit", "~> 2.7.2"
|
29
|
-
spec.add_development_dependency "octorelease"
|
30
28
|
end
|
data/spec/arch/package_spec.rb
CHANGED
@@ -11,6 +11,11 @@ describe package('invalid-package') do
|
|
11
11
|
it { should_not be_installed }
|
12
12
|
end
|
13
13
|
|
14
|
+
describe package('curl') do
|
15
|
+
it { should be_installed.with_version('7.37.0-1') }
|
16
|
+
its(:command) { should eq "pacman -Q | grep curl 7.37.0-1" }
|
17
|
+
end
|
18
|
+
|
14
19
|
package('invalid-package') do
|
15
20
|
it { should_not be_installed.by('pacman') }
|
16
21
|
end
|
data/spec/darwin/port_spec.rb
CHANGED
data/spec/darwin/service_spec.rb
CHANGED
@@ -20,7 +20,7 @@ include SpecInfra::Helper::Darwin
|
|
20
20
|
|
21
21
|
describe service('sshd') do
|
22
22
|
it { should be_running }
|
23
|
-
its(:command) { should eq "
|
23
|
+
its(:command) { should eq "launchctl list | grep sshd | grep -E '^[0-9]+'" }
|
24
24
|
end
|
25
25
|
|
26
26
|
describe service('invalid-daemon') do
|
@@ -0,0 +1,421 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::NixOS
|
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 || grep -qF -- 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 -q -- \\^This\\ is\\ the\\ sshd\\ server\\ system-wide\\ configuration\\ file /etc/ssh/sshd_config || grep -qF -- \\^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 - || sed -n /\\^group\\ :test\\ do/,/\\^end/p Gemfile | grep -qF -- rspec -" }
|
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 - || sed -n /\\^group\\ :test\\ do/,\\$p Gemfile | grep -qF -- rspec -" }
|
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 - || sed -n 1,/\\^end/p Gemfile | grep -qF -- rspec -" }
|
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 "stat -c %a /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 "stat -c %U /etc/passwd | 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 "stat -c %G /etc/passwd | 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 "stat -c %N /etc/pam.d/system-auth | egrep -e \"-> ./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 "stat -c %a /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 -s /bin/sh -c \"test -r /tmp\" mail" }
|
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 "stat -c %a /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 -s /bin/sh -c \"test -w /tmp\" mail" }
|
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 "stat -c %a /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 -s /bin/sh -c \"test -x /tmp\" mail" }
|
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 '9d39e51e6bd5a30168c26c57b66d2e37' }
|
381
|
+
its(:command) { should eq "md5sum /etc/services | grep -iw -- \\^9d39e51e6bd5a30168c26c57b66d2e37" }
|
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 'b4d36eb75767bebb41c5fa7a35599952e1883b3d3f6332496e1561eeb4067018' }
|
390
|
+
its(:command) { should eq "sha256sum /etc/services | grep -iw -- \\^b4d36eb75767bebb41c5fa7a35599952e1883b3d3f6332496e1561eeb4067018" }
|
391
|
+
end
|
392
|
+
|
393
|
+
describe file('invalid-file') do
|
394
|
+
it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
|
395
|
+
end
|
396
|
+
|
397
|
+
describe file('/etc/passwd') do
|
398
|
+
let(:stdout) {<<EOF
|
399
|
+
root:x:0:0:System administrator:/root:/run/current-system/sw/bin/bash
|
400
|
+
nscd:x:1:65534:Name service cache daemon user:/var/empty:/run/current-system/sw/sbin/nologin
|
401
|
+
sshd:x:2:65534:SSH privilege separation user:/var/empty:/run/current-system/sw/sbin/nologin
|
402
|
+
ntp:x:3:65534:NTP daemon user:/var/lib/ntp:/run/current-system/sw/sbin/nologin
|
403
|
+
messagebus:x:4:4:D-Bus system message bus daemon user:/var/run/dbus:/run/current-system/sw/sbin/nologin
|
404
|
+
polkituser:x:28:65534:PolKit daemon:/var/empty:/run/current-system/sw/sbin/nologin
|
405
|
+
systemd-journal-gateway:x:110:65534::/var/empty:/run/current-system/sw/sbin/nologin
|
406
|
+
nixbld1:x:30001:30000:Nix build user 1:/var/empty:/run/current-system/sw/sbin/nologin
|
407
|
+
nixbld2:x:30002:30000:Nix build user 2:/var/empty:/run/current-system/sw/sbin/nologin
|
408
|
+
nixbld3:x:30003:30000:Nix build user 3:/var/empty:/run/current-system/sw/sbin/nologin
|
409
|
+
nixbld4:x:30004:30000:Nix build user 4:/var/empty:/run/current-system/sw/sbin/nologin
|
410
|
+
nixbld5:x:30005:30000:Nix build user 5:/var/empty:/run/current-system/sw/sbin/nologin
|
411
|
+
nixbld6:x:30006:30000:Nix build user 6:/var/empty:/run/current-system/sw/sbin/nologin
|
412
|
+
nixbld7:x:30007:30000:Nix build user 7:/var/empty:/run/current-system/sw/sbin/nologin
|
413
|
+
nixbld8:x:30008:30000:Nix build user 8:/var/empty:/run/current-system/sw/sbin/nologin
|
414
|
+
nixbld9:x:30009:30000:Nix build user 9:/var/empty:/run/current-system/sw/sbin/nologin
|
415
|
+
nixbld10:x:30010:30000:Nix build user 10:/var/empty:/run/current-system/sw/sbin/nologin
|
416
|
+
nobody:x:65534:65534:Unprivileged account (don't use!):/var/empty:/run/current-system/sw/sbin/nologin
|
417
|
+
EOF
|
418
|
+
}
|
419
|
+
|
420
|
+
its(:content) { should match /root:x:0:0/ }
|
421
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::NixOS
|
4
|
+
|
5
|
+
describe package('apache-httpd') do
|
6
|
+
it { should be_installed }
|
7
|
+
its(:command) { should eq "nix-store -q --references /var/run/current-system/sw | grep apache-httpd" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe package('invalid-package') do
|
11
|
+
it { should_not be_installed }
|
12
|
+
end
|
13
|
+
|
14
|
+
package('invalid-package') do
|
15
|
+
it { should_not be_installed.by('nix') }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe package('apache-httpd') do
|
19
|
+
it { should be_installed.with_version('2.4.9') }
|
20
|
+
its(:command) { should eq "nix-store -q --references /var/run/current-system/sw | grep apache-httpd-2.4.9" }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe package('httpd') do
|
24
|
+
it { should be_installed.by('nix').with_version('2.4.9') }
|
25
|
+
its(:command) { should eq "nix-store -q --references /var/run/current-system/sw | grep httpd-2.4.9" }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe package('httpd') do
|
29
|
+
it { should_not be_installed.with_version('invalid-version') }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe package('jekyll') do
|
33
|
+
it { should be_installed.by('gem') }
|
34
|
+
its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe package('invalid-gem') do
|
38
|
+
it { should_not be_installed.by('gem') }
|
39
|
+
end
|
40
|
+
|
41
|
+
describe package('jekyll') do
|
42
|
+
it { should be_installed.by('gem').with_version('1.1.1') }
|
43
|
+
its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe package('jekyll') do
|
47
|
+
it { should_not be_installed.by('gem').with_version('invalid-version') }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe package('bower') do
|
51
|
+
it { should be_installed.by('npm') }
|
52
|
+
its(:command) { should eq "npm ls bower -g" }
|
53
|
+
end
|
54
|
+
|
55
|
+
describe package('invalid-npm-package') do
|
56
|
+
it { should_not be_installed.by('npm') }
|
57
|
+
end
|
58
|
+
|
59
|
+
describe package('bower') do
|
60
|
+
it { should be_installed.by('npm').with_version('0.9.2') }
|
61
|
+
its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" }
|
62
|
+
end
|
63
|
+
|
64
|
+
describe package('bower') do
|
65
|
+
it { should_not be_installed.by('npm').with_version('invalid-version') }
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
describe package('mongo') do
|
70
|
+
it { should be_installed.by('pecl') }
|
71
|
+
its(:command) { should eq "pecl list | grep -w -- \\^mongo" }
|
72
|
+
end
|
73
|
+
|
74
|
+
describe package('invalid-pecl') do
|
75
|
+
it { should_not be_installed.by('pecl') }
|
76
|
+
end
|
77
|
+
|
78
|
+
describe package('mongo') do
|
79
|
+
it { should be_installed.by('pecl').with_version('1.4.1') }
|
80
|
+
its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" }
|
81
|
+
end
|
82
|
+
|
83
|
+
describe package('mongo') do
|
84
|
+
it { should_not be_installed.by('pecl').with_version('invalid-version') }
|
85
|
+
end
|
86
|
+
|
87
|
+
describe package('XML_Util') do
|
88
|
+
it { should be_installed.by('pear').with_version('1.2.1') }
|
89
|
+
its(:command) { should eq "pear list | grep -w -- \\^XML_Util | grep -w -- 1.2.1" }
|
90
|
+
end
|
91
|
+
|
92
|
+
describe package('supervisor') do
|
93
|
+
it { should be_installed.by('pip').with_version('3.0') }
|
94
|
+
its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" }
|
95
|
+
end
|
96
|
+
|
97
|
+
describe package('invalid-pip') do
|
98
|
+
it { should_not be_installed.by('pip').with_version('invalid-version') }
|
99
|
+
end
|
100
|
+
|
101
|
+
describe package('App::Ack') do
|
102
|
+
it { should be_installed.by('cpan') }
|
103
|
+
its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack" }
|
104
|
+
end
|
105
|
+
|
106
|
+
describe package('App::Ack') do
|
107
|
+
it { should be_installed.by('cpan').with_version('2.04') }
|
108
|
+
its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack | grep -w -- 2.04" }
|
109
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::NixOS
|
4
|
+
|
5
|
+
describe service('sshd') do
|
6
|
+
it { should be_enabled }
|
7
|
+
its(:command) { should eq "systemctl --plain list-dependencies multi-user.target | grep 'sshd.service$'" }
|
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(3) }
|
16
|
+
its(:command) { should eq "systemctl --plain list-dependencies multi-user.target | grep 'sshd.service$'" }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe service('sshd') do
|
20
|
+
it { should be_enabled.with_level("graphical.target") }
|
21
|
+
its(:command) { should eq "systemctl --plain list-dependencies graphical.target | grep 'sshd.service$'" }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe service('invalid-service') do
|
25
|
+
it { should_not be_enabled.with_level(4) }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe service('sshd') do
|
29
|
+
it { should be_running }
|
30
|
+
its(:command) { should eq "systemctl is-active sshd.service" }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe service('invalid-daemon') do
|
34
|
+
it { should_not be_running }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe service('sshd') do
|
38
|
+
let(:stdout) { "sshd is stopped\r\n" }
|
39
|
+
it { should be_running }
|
40
|
+
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: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.17'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.17'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,34 +108,6 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 10.1.1
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: octokit
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 2.7.2
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 2.7.2
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: octorelease
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
111
|
description: RSpec tests for your servers configured by Puppet, Chef or anything else
|
140
112
|
email:
|
141
113
|
- gosukenator@gmail.com
|
@@ -336,6 +308,9 @@ files:
|
|
336
308
|
- spec/gentoo/zfs_spec.rb
|
337
309
|
- spec/helper/properties_spec.rb
|
338
310
|
- spec/helper/type_spec.rb
|
311
|
+
- spec/nixos/file_spec.rb
|
312
|
+
- spec/nixos/package_spec.rb
|
313
|
+
- spec/nixos/service_spec.rb
|
339
314
|
- spec/plamo/cgroup_spec.rb
|
340
315
|
- spec/plamo/command_spec.rb
|
341
316
|
- spec/plamo/cron_spec.rb
|
@@ -580,6 +555,9 @@ test_files:
|
|
580
555
|
- spec/gentoo/zfs_spec.rb
|
581
556
|
- spec/helper/properties_spec.rb
|
582
557
|
- spec/helper/type_spec.rb
|
558
|
+
- spec/nixos/file_spec.rb
|
559
|
+
- spec/nixos/package_spec.rb
|
560
|
+
- spec/nixos/service_spec.rb
|
583
561
|
- spec/plamo/cgroup_spec.rb
|
584
562
|
- spec/plamo/command_spec.rb
|
585
563
|
- spec/plamo/cron_spec.rb
|