serverspec 0.9.2 → 0.9.3
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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/serverspec/backend/exec.rb +2 -0
- data/lib/serverspec/commands/freebsd.rb +18 -0
- data/lib/serverspec/helper/freebsd.rb +9 -0
- data/lib/serverspec/helper.rb +1 -0
- data/lib/serverspec/version.rb +1 -1
- data/lib/serverspec.rb +2 -0
- data/spec/freebsd/command_spec.rb +48 -0
- data/spec/freebsd/cron_spec.rb +21 -0
- data/spec/freebsd/default_gateway_spec.rb +16 -0
- data/spec/freebsd/file_spec.rb +367 -0
- data/spec/freebsd/group_spec.rb +21 -0
- data/spec/freebsd/host_spec.rb +58 -0
- data/spec/freebsd/package_spec.rb +81 -0
- data/spec/freebsd/php_config_spec.rb +36 -0
- data/spec/freebsd/port_spec.rb +30 -0
- data/spec/freebsd/routing_table_spec.rb +120 -0
- data/spec/freebsd/service_spec.rb +93 -0
- data/spec/freebsd/user_spec.rb +58 -0
- metadata +27 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d7cceefe09064845e7a6da397251424940101ba
|
4
|
+
data.tar.gz: a6e7cf0a8df6575ea55afeb06d1ff3ff634e1282
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fce59959e6ff6e867ba1dc68d9ac9fed31ebc3a13fa9bdd1e7e7e2bdc35eeca3b8257af8ec26301f095fbeedad66e5cac932594788bb3d1d6bfd224ff59af31c
|
7
|
+
data.tar.gz: 3ee39b8c1308dc4f16072e976cb2dd4b8242dc62464ca205a877f24b179f18b077f9f5c2c53880672513108807d5864afc878fd39cf6480871f71ca30fc0b813
|
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'rspec/core/rake_task'
|
|
4
4
|
task :spec => 'spec:all'
|
5
5
|
|
6
6
|
namespace :spec do
|
7
|
-
oses = %w( darwin debian gentoo redhat aix solaris solaris10 solaris11 smartos windows)
|
7
|
+
oses = %w( darwin debian gentoo redhat aix solaris solaris10 solaris11 smartos windows freebsd)
|
8
8
|
|
9
9
|
task :all => [ oses.map {|os| "spec:#{os}" }, :helpers, :exec, :ssh, :cmd, :winrm, :powershell ].flatten
|
10
10
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Serverspec
|
2
|
+
module Commands
|
3
|
+
class FreeBSD < Base
|
4
|
+
def check_enabled(service, level=3)
|
5
|
+
"service -e | grep -- #{escape(service)}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def check_installed(package, version=nil)
|
9
|
+
"pkg_version -X -s #{escape(package)}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def check_listening(port)
|
13
|
+
regexp = ":#{port} "
|
14
|
+
"sockstat -46l -p #{port} | grep -- #{escape(regexp)}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/serverspec/helper.rb
CHANGED
data/lib/serverspec/version.rb
CHANGED
data/lib/serverspec.rb
CHANGED
@@ -18,6 +18,7 @@ require 'serverspec/commands/solaris11'
|
|
18
18
|
require 'serverspec/commands/smartos'
|
19
19
|
require 'serverspec/commands/darwin'
|
20
20
|
require 'serverspec/commands/windows'
|
21
|
+
require 'serverspec/commands/freebsd'
|
21
22
|
require 'serverspec/configuration'
|
22
23
|
require 'rspec/core/formatters/base_formatter'
|
23
24
|
|
@@ -43,6 +44,7 @@ RSpec.configure do |c|
|
|
43
44
|
c.include(Serverspec::Helper::SmartOS, :os => :smartos)
|
44
45
|
c.include(Serverspec::Helper::Darwin, :os => :darwin)
|
45
46
|
c.include(Serverspec::Helper::Windows, :os => :windows)
|
47
|
+
c.include(Serverspec::Helper::FreeBSD, :os => :freebsd)
|
46
48
|
c.add_setting :os, :default => nil
|
47
49
|
c.add_setting :host, :default => nil
|
48
50
|
c.add_setting :ssh, :default => nil
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::FreeBSD
|
4
|
+
|
5
|
+
describe command('cat /etc/resolv.conf') do
|
6
|
+
let(:stdout) { "nameserver 127.0.0.1\r\n" }
|
7
|
+
it { should return_stdout("nameserver 127.0.0.1") }
|
8
|
+
its(:command) { should eq 'cat /etc/resolv.conf' }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'complete matching of stdout' do
|
12
|
+
context command('cat /etc/resolv.conf') do
|
13
|
+
let(:stdout) { "foocontent-should-be-includedbar\r\n" }
|
14
|
+
it { should_not return_stdout('content-should-be-included') }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'regexp matching of stdout' do
|
19
|
+
context command('cat /etc/resolv.conf') do
|
20
|
+
let(:stdout) { "nameserver 127.0.0.1\r\n" }
|
21
|
+
it { should return_stdout(/127\.0\.0\.1/) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe command('cat /etc/resolv.conf') do
|
26
|
+
let(:stdout) { "No such file or directory\r\n" }
|
27
|
+
it { should return_stderr("No such file or directory") }
|
28
|
+
its(:command) { should eq 'cat /etc/resolv.conf' }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'complete matching of stderr' do
|
32
|
+
context command('cat /etc/resolv.conf') do
|
33
|
+
let(:stdout) { "No such file or directory\r\n" }
|
34
|
+
it { should_not return_stdout('file') }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'regexp matching of stderr' do
|
39
|
+
context command('cat /etc/resolv.conf') do
|
40
|
+
let(:stdout) { "No such file or directory\r\n" }
|
41
|
+
it { should return_stderr(/file/) }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe command('cat /etc/resolv.conf') do
|
46
|
+
it { should return_exit_status 0 }
|
47
|
+
its(:command) { should eq 'cat /etc/resolv.conf' }
|
48
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::FreeBSD
|
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 -u root -l | 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::FreeBSD
|
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,367 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::FreeBSD
|
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 | 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 "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('/dev') do
|
151
|
+
let(:stdout) { "755\r\n" }
|
152
|
+
it { should be_writable }
|
153
|
+
its(:command) { should eq "stat -c %a /dev" }
|
154
|
+
end
|
155
|
+
|
156
|
+
describe file('/dev') do
|
157
|
+
let(:stdout) { "555\r\n" }
|
158
|
+
it { should_not be_writable }
|
159
|
+
end
|
160
|
+
|
161
|
+
describe file('/dev') do
|
162
|
+
let(:stdout) { "200\r\n" }
|
163
|
+
it { should be_writable.by('owner') }
|
164
|
+
end
|
165
|
+
|
166
|
+
describe file('/dev') do
|
167
|
+
let(:stdout) { "555\r\n" }
|
168
|
+
it { should_not be_writable.by('owner') }
|
169
|
+
end
|
170
|
+
|
171
|
+
describe file('/dev') do
|
172
|
+
let(:stdout) { "030\r\n" }
|
173
|
+
it { should be_writable.by('group') }
|
174
|
+
end
|
175
|
+
|
176
|
+
describe file('/dev') do
|
177
|
+
let(:stdout) { "555\r\n" }
|
178
|
+
it { should_not be_writable.by('group') }
|
179
|
+
end
|
180
|
+
|
181
|
+
describe file('/dev') do
|
182
|
+
let(:stdout) { "666\r\n" }
|
183
|
+
it { should be_writable.by('others') }
|
184
|
+
end
|
185
|
+
|
186
|
+
describe file('/dev') do
|
187
|
+
let(:stdout) { "555\r\n" }
|
188
|
+
it { should_not be_writable.by('others') }
|
189
|
+
end
|
190
|
+
|
191
|
+
describe file('/dev') do
|
192
|
+
let(:stdout) { "755\r\n" }
|
193
|
+
it { should be_executable }
|
194
|
+
end
|
195
|
+
|
196
|
+
describe file('/dev') do
|
197
|
+
let(:stdout) { "666\r\n" }
|
198
|
+
it { should_not be_executable }
|
199
|
+
end
|
200
|
+
|
201
|
+
describe file('/dev') do
|
202
|
+
let(:stdout) { "100\r\n" }
|
203
|
+
it { should be_executable.by('owner') }
|
204
|
+
end
|
205
|
+
|
206
|
+
describe file('/dev') do
|
207
|
+
let(:stdout) { "666\r\n" }
|
208
|
+
it { should_not be_executable.by('owner') }
|
209
|
+
end
|
210
|
+
|
211
|
+
describe file('/dev') do
|
212
|
+
let(:stdout) { "070\r\n" }
|
213
|
+
it { should be_executable.by('group') }
|
214
|
+
end
|
215
|
+
|
216
|
+
describe file('/dev') do
|
217
|
+
let(:stdout) { "666\r\n" }
|
218
|
+
it { should_not be_executable.by('group') }
|
219
|
+
end
|
220
|
+
|
221
|
+
describe file('/dev') do
|
222
|
+
let(:stdout) { "001\r\n" }
|
223
|
+
it { should be_executable.by('others') }
|
224
|
+
end
|
225
|
+
|
226
|
+
describe file('/dev') do
|
227
|
+
let(:stdout) { "666\r\n" }
|
228
|
+
it { should_not be_executable.by('others') }
|
229
|
+
end
|
230
|
+
|
231
|
+
describe file('/') do
|
232
|
+
it { should be_mounted }
|
233
|
+
its(:command) { should eq "mount | grep -w -- on\\ /" }
|
234
|
+
end
|
235
|
+
|
236
|
+
describe file('/etc/invalid-mount') do
|
237
|
+
it { should_not be_mounted }
|
238
|
+
end
|
239
|
+
|
240
|
+
describe file('/') do
|
241
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
242
|
+
it { should be_mounted.with( :type => 'ext4' ) }
|
243
|
+
end
|
244
|
+
|
245
|
+
describe file('/') do
|
246
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
247
|
+
it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) }
|
248
|
+
end
|
249
|
+
|
250
|
+
describe file('/') do
|
251
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
252
|
+
it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) }
|
253
|
+
end
|
254
|
+
|
255
|
+
describe file('/') do
|
256
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
257
|
+
it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) }
|
258
|
+
end
|
259
|
+
|
260
|
+
describe file('/') do
|
261
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
262
|
+
it { should_not be_mounted.with( :type => 'xfs' ) }
|
263
|
+
end
|
264
|
+
|
265
|
+
describe file('/') do
|
266
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
267
|
+
it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) }
|
268
|
+
end
|
269
|
+
|
270
|
+
describe file('/') do
|
271
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
272
|
+
it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) }
|
273
|
+
end
|
274
|
+
|
275
|
+
describe file('/') do
|
276
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
277
|
+
it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) }
|
278
|
+
end
|
279
|
+
|
280
|
+
describe file('/') do
|
281
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
282
|
+
it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) }
|
283
|
+
end
|
284
|
+
|
285
|
+
describe file('/etc/invalid-mount') do
|
286
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
287
|
+
it { should_not be_mounted.with( :type => 'ext4' ) }
|
288
|
+
end
|
289
|
+
|
290
|
+
describe file('/') do
|
291
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
292
|
+
it do
|
293
|
+
should be_mounted.only_with(
|
294
|
+
:device => '/dev/mapper/VolGroup-lv_root',
|
295
|
+
:type => 'ext4',
|
296
|
+
:options => {
|
297
|
+
:rw => true,
|
298
|
+
:mode => 620,
|
299
|
+
}
|
300
|
+
)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
describe file('/') do
|
305
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
306
|
+
it do
|
307
|
+
should_not be_mounted.only_with(
|
308
|
+
:device => '/dev/mapper/VolGroup-lv_root',
|
309
|
+
:type => 'ext4',
|
310
|
+
:options => {
|
311
|
+
:rw => true,
|
312
|
+
:mode => 620,
|
313
|
+
:bind => true,
|
314
|
+
}
|
315
|
+
)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
describe file('/') do
|
320
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
321
|
+
it do
|
322
|
+
should_not be_mounted.only_with(
|
323
|
+
:device => '/dev/mapper/VolGroup-lv_root',
|
324
|
+
:type => 'ext4',
|
325
|
+
:options => {
|
326
|
+
:rw => true,
|
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_roooooooooot',
|
337
|
+
:type => 'ext4',
|
338
|
+
:options => {
|
339
|
+
:rw => true,
|
340
|
+
:mode => 620,
|
341
|
+
}
|
342
|
+
)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
describe file('/etc/invalid-mount') do
|
347
|
+
let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
|
348
|
+
it { should_not be_mounted.only_with( :type => 'ext4' ) }
|
349
|
+
end
|
350
|
+
|
351
|
+
describe file('/etc/services') do
|
352
|
+
it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' }
|
353
|
+
its(:command) { should eq "md5sum /etc/services | grep -iw -- \\^35435ea447c19f0ea5ef971837ab9ced" }
|
354
|
+
end
|
355
|
+
|
356
|
+
describe file('invalid-file') do
|
357
|
+
it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' }
|
358
|
+
end
|
359
|
+
|
360
|
+
describe file('/etc/services') do
|
361
|
+
it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' }
|
362
|
+
its(:command) { should eq "sha256sum /etc/services | grep -iw -- \\^0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" }
|
363
|
+
end
|
364
|
+
|
365
|
+
describe file('invalid-file') do
|
366
|
+
it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
|
367
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::FreeBSD
|
4
|
+
|
5
|
+
describe group('root') do
|
6
|
+
it { should exist }
|
7
|
+
its(:command) { should eq "getent group | grep -wq -- 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 -w -- \\^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,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::FreeBSD
|
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 -w 5 -c 2" }
|
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 -w 1 -c 2" }
|
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 127.0.0.1 22 -w 1" }
|
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 127.0.0.1 53 -w 1" }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe host('invalid-host') do
|
57
|
+
it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) }
|
58
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::FreeBSD
|
4
|
+
|
5
|
+
describe package('httpd') do
|
6
|
+
it { should be_installed }
|
7
|
+
its(:command) { should eq "pkg_version -X -s 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.15-28.el6') }
|
16
|
+
its(:command) { should eq "pkg_version -X -s httpd"}
|
17
|
+
end
|
18
|
+
|
19
|
+
describe package('jekyll') do
|
20
|
+
it { should be_installed.by('gem') }
|
21
|
+
its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe package('invalid-gem') do
|
25
|
+
it { should_not be_installed.by('gem') }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe package('jekyll') do
|
29
|
+
it { should be_installed.by('gem').with_version('1.1.1') }
|
30
|
+
its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe package('jekyll') do
|
34
|
+
it { should_not be_installed.by('gem').with_version('invalid-version') }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe package('bower') do
|
38
|
+
it { should be_installed.by('npm') }
|
39
|
+
its(:command) { should eq "npm ls bower -g" }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe package('invalid-npm-package') do
|
43
|
+
it { should_not be_installed.by('npm') }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe package('bower') do
|
47
|
+
it { should be_installed.by('npm').with_version('0.9.2') }
|
48
|
+
its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe package('bower') do
|
52
|
+
it { should_not be_installed.by('npm').with_version('invalid-version') }
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
describe package('mongo') do
|
57
|
+
it { should be_installed.by('pecl') }
|
58
|
+
its(:command) { should eq "pecl list | grep -w -- \\^mongo" }
|
59
|
+
end
|
60
|
+
|
61
|
+
describe package('invalid-pecl') do
|
62
|
+
it { should_not be_installed.by('pecl') }
|
63
|
+
end
|
64
|
+
|
65
|
+
describe package('mongo') do
|
66
|
+
it { should be_installed.by('pecl').with_version('1.4.1') }
|
67
|
+
its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" }
|
68
|
+
end
|
69
|
+
|
70
|
+
describe package('mongo') do
|
71
|
+
it { should_not be_installed.by('pecl').with_version('invalid-version') }
|
72
|
+
end
|
73
|
+
|
74
|
+
describe package('supervisor') do
|
75
|
+
it { should be_installed.by('pip').with_version('3.0') }
|
76
|
+
its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" }
|
77
|
+
end
|
78
|
+
|
79
|
+
describe package('invalid-pip') do
|
80
|
+
it { should_not be_installed.by('pip').with_version('invalid-version') }
|
81
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::FreeBSD
|
4
|
+
|
5
|
+
describe php_config('default_mimetype') do
|
6
|
+
let(:stdout) { 'text/html' }
|
7
|
+
its(:value) { should eq 'text/html' }
|
8
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe php_config('default_mimetype') do
|
12
|
+
let(:stdout) { 'text/html' }
|
13
|
+
its(:value) { should_not eq 'text/plain' }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe php_config('session.cache_expire') do
|
17
|
+
let(:stdout) { '180' }
|
18
|
+
its(:value) { should eq 180 }
|
19
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe php_config('session.cache_expire') do
|
23
|
+
let(:stdout) { '180' }
|
24
|
+
its(:value) { should_not eq 360 }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe php_config('mbstring.http_output_conv_mimetypes') do
|
28
|
+
let(:stdout) { 'application' }
|
29
|
+
its(:value) { should match /application/ }
|
30
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe php_config('mbstring.http_output_conv_mimetypes') do
|
34
|
+
let(:stdout) { 'application' }
|
35
|
+
its(:value) { should_not match /html/ }
|
36
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::FreeBSD
|
4
|
+
|
5
|
+
describe port(80) do
|
6
|
+
it { should be_listening }
|
7
|
+
its(:command) { should eq 'sockstat -46l -p 80 | grep -- :80\\ ' }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe port('invalid') do
|
11
|
+
it { should_not be_listening }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe port(80) do
|
15
|
+
it { should be_listening.with("tcp") }
|
16
|
+
its(:command) { should eq 'netstat -tunl | grep -- \\^tcp\\ .\\*:80\\ ' }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe port(123) do
|
20
|
+
it { should be_listening.with("udp") }
|
21
|
+
its(:command) { should eq 'netstat -tunl | grep -- \\^udp\\ .\\*:123\\ ' }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe port(80) do
|
25
|
+
it {
|
26
|
+
expect {
|
27
|
+
should be_listening.with('not implemented')
|
28
|
+
}.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/)
|
29
|
+
}
|
30
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::FreeBSD
|
4
|
+
|
5
|
+
describe routing_table do
|
6
|
+
let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
|
7
|
+
it { should have_entry( :destination => '192.168.100.0/24' ) }
|
8
|
+
its(:command) { should eq "ip route | grep -E '^192.168.100.0/24 |^default '" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe routing_table do
|
12
|
+
let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
|
13
|
+
it { should_not have_entry( :destination => '192.168.100.100/24' ) }
|
14
|
+
its(:command) { should eq "ip route | grep -E '^192.168.100.100/24 |^default '" }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe routing_table do
|
18
|
+
let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
|
19
|
+
it do
|
20
|
+
should have_entry(
|
21
|
+
:destination => '192.168.100.0/24',
|
22
|
+
:gateway => '192.168.100.1'
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
it do
|
27
|
+
should have_entry(
|
28
|
+
:destination => '192.168.100.0/24',
|
29
|
+
:gateway => '192.168.100.1',
|
30
|
+
:interface => 'eth1'
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
it do
|
35
|
+
should_not have_entry(
|
36
|
+
:gateway => '192.168.100.1',
|
37
|
+
:interface => 'eth1'
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
it do
|
42
|
+
should_not have_entry(
|
43
|
+
:destination => '192.168.100.0/32',
|
44
|
+
:gateway => '192.168.100.1',
|
45
|
+
:interface => 'eth1'
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe routing_table do
|
51
|
+
let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
|
52
|
+
it { should have_entry( :destination => '192.168.200.0/24' ) }
|
53
|
+
it { should_not have_entry( :destination => '192.168.200.200/24' ) }
|
54
|
+
|
55
|
+
it do
|
56
|
+
should have_entry(
|
57
|
+
:destination => '192.168.200.0/24',
|
58
|
+
:gateway => '192.168.200.1'
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
it do
|
63
|
+
should have_entry(
|
64
|
+
:destination => '192.168.200.0/24',
|
65
|
+
:gateway => '192.168.200.1',
|
66
|
+
:interface => 'eth0'
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
it do
|
71
|
+
should_not have_entry(
|
72
|
+
:gateway => '192.168.200.1',
|
73
|
+
:interface => 'eth0'
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
it do
|
78
|
+
should_not have_entry(
|
79
|
+
:destination => '192.168.200.0/32',
|
80
|
+
:gateway => '192.168.200.1',
|
81
|
+
:interface => 'eth0'
|
82
|
+
)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe routing_table do
|
87
|
+
let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" }
|
88
|
+
it { should have_entry( :destination => 'default' ) }
|
89
|
+
it { should_not have_entry( :destination => 'defaulth' ) }
|
90
|
+
|
91
|
+
it do
|
92
|
+
should have_entry(
|
93
|
+
:destination => 'default',
|
94
|
+
:gateway => '10.0.2.2'
|
95
|
+
)
|
96
|
+
end
|
97
|
+
|
98
|
+
it do
|
99
|
+
should have_entry(
|
100
|
+
:destination => 'default',
|
101
|
+
:gateway => '10.0.2.2',
|
102
|
+
:interface => 'eth0'
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
it do
|
107
|
+
should_not have_entry(
|
108
|
+
:gateway => '10.0.2.2',
|
109
|
+
:interface => 'eth0'
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
it do
|
114
|
+
should_not have_entry(
|
115
|
+
:destination => 'default',
|
116
|
+
:gateway => '10.0.2.1',
|
117
|
+
:interface => 'eth0'
|
118
|
+
)
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::FreeBSD
|
4
|
+
|
5
|
+
describe service('sshd') do
|
6
|
+
it { should be_enabled }
|
7
|
+
its(:command) { should eq "service -e | grep -- sshd" }
|
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(4) }
|
16
|
+
its(:command) { should eq "service -e | grep -- sshd" }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe service('invalid-service') do
|
20
|
+
it { should_not be_enabled.with_level(4) }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe service('sshd') do
|
24
|
+
it { should be_running }
|
25
|
+
its(:command) { should eq "service sshd status" }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe service('invalid-daemon') do
|
29
|
+
it { should_not be_running }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe service('sshd') do
|
33
|
+
let(:stdout) { "sshd is stopped\r\n" }
|
34
|
+
it { should be_running }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe service('sshd') do
|
38
|
+
it { should be_running.under('supervisor') }
|
39
|
+
its(:command) { should eq "supervisorctl status sshd | grep RUNNING" }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe service('invalid-daemon') do
|
43
|
+
it { should_not be_running.under('supervisor') }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe service('sshd') do
|
47
|
+
it { should be_running.under('upstart') }
|
48
|
+
its(:command) { should eq "initctl status sshd | grep running" }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe service('invalid-daemon') do
|
52
|
+
it { should_not be_running.under('upstart') }
|
53
|
+
end
|
54
|
+
|
55
|
+
describe service('sshd') do
|
56
|
+
it {
|
57
|
+
expect {
|
58
|
+
should be_running.under('not implemented')
|
59
|
+
}.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/)
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
describe service('sshd') do
|
64
|
+
let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" }
|
65
|
+
it { should be_monitored_by('monit') }
|
66
|
+
its(:command) { should eq "monit status" }
|
67
|
+
end
|
68
|
+
|
69
|
+
describe service('sshd') do
|
70
|
+
let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" }
|
71
|
+
it { should_not be_monitored_by('monit') }
|
72
|
+
end
|
73
|
+
|
74
|
+
describe service('invalid-daemon') do
|
75
|
+
it { should_not be_monitored_by('monit') }
|
76
|
+
end
|
77
|
+
|
78
|
+
describe service('unicorn') do
|
79
|
+
it { should be_monitored_by('god') }
|
80
|
+
its(:command) { should eq "god status unicorn" }
|
81
|
+
end
|
82
|
+
|
83
|
+
describe service('invalid-daemon') do
|
84
|
+
it { should_not be_monitored_by('god') }
|
85
|
+
end
|
86
|
+
|
87
|
+
describe service('sshd') do
|
88
|
+
it {
|
89
|
+
expect {
|
90
|
+
should be_monitored_by('not implemented')
|
91
|
+
}.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/)
|
92
|
+
}
|
93
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::FreeBSD
|
4
|
+
|
5
|
+
|
6
|
+
describe user('root') do
|
7
|
+
it { should exist }
|
8
|
+
its(:command) { should eq "id root" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe user('invalid-user') do
|
12
|
+
it { should_not exist }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe user('root') do
|
16
|
+
it { should belong_to_group 'root' }
|
17
|
+
its(:command) { should eq "id root | awk '{print $3}' | grep -- root" }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe user('root') do
|
21
|
+
it { should_not belong_to_group 'invalid-group' }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe user('root') do
|
25
|
+
it { should have_uid 0 }
|
26
|
+
its(:command) { should eq "id root | grep -- \\^uid\\=0\\(" }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe user('root') do
|
30
|
+
it { should_not have_uid 'invalid-uid' }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe user('root') do
|
34
|
+
it { should have_login_shell '/bin/bash' }
|
35
|
+
its(:command) { should eq "getent passwd root | cut -f 7 -d ':' | grep -w -- /bin/bash" }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe user('root') do
|
39
|
+
it { should_not have_login_shell 'invalid-login-shell' }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe user('root') do
|
43
|
+
it { should have_home_directory '/root' }
|
44
|
+
its(:command) { should eq "getent passwd root | cut -f 6 -d ':' | grep -w -- /root" }
|
45
|
+
end
|
46
|
+
|
47
|
+
describe user('root') do
|
48
|
+
it { should_not have_home_directory 'invalid-home-directory' }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe user('root') do
|
52
|
+
it { should have_authorized_key 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local' }
|
53
|
+
its(:command) { should eq "grep -w -- ssh-rsa\\ ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH ~root/.ssh/authorized_keys" }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe user('root') do
|
57
|
+
it { should_not have_authorized_key 'invalid-key' }
|
58
|
+
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.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- lib/serverspec/commands/base.rb
|
148
148
|
- lib/serverspec/commands/darwin.rb
|
149
149
|
- lib/serverspec/commands/debian.rb
|
150
|
+
- lib/serverspec/commands/freebsd.rb
|
150
151
|
- lib/serverspec/commands/gentoo.rb
|
151
152
|
- lib/serverspec/commands/linux.rb
|
152
153
|
- lib/serverspec/commands/redhat.rb
|
@@ -166,6 +167,7 @@ files:
|
|
166
167
|
- lib/serverspec/helper/debian.rb
|
167
168
|
- lib/serverspec/helper/detect_os.rb
|
168
169
|
- lib/serverspec/helper/exec.rb
|
170
|
+
- lib/serverspec/helper/freebsd.rb
|
169
171
|
- lib/serverspec/helper/gentoo.rb
|
170
172
|
- lib/serverspec/helper/puppet.rb
|
171
173
|
- lib/serverspec/helper/redhat.rb
|
@@ -284,6 +286,18 @@ files:
|
|
284
286
|
- spec/debian/service_spec.rb
|
285
287
|
- spec/debian/user_spec.rb
|
286
288
|
- spec/debian/zfs_spec.rb
|
289
|
+
- spec/freebsd/command_spec.rb
|
290
|
+
- spec/freebsd/cron_spec.rb
|
291
|
+
- spec/freebsd/default_gateway_spec.rb
|
292
|
+
- spec/freebsd/file_spec.rb
|
293
|
+
- spec/freebsd/group_spec.rb
|
294
|
+
- spec/freebsd/host_spec.rb
|
295
|
+
- spec/freebsd/package_spec.rb
|
296
|
+
- spec/freebsd/php_config_spec.rb
|
297
|
+
- spec/freebsd/port_spec.rb
|
298
|
+
- spec/freebsd/routing_table_spec.rb
|
299
|
+
- spec/freebsd/service_spec.rb
|
300
|
+
- spec/freebsd/user_spec.rb
|
287
301
|
- spec/gentoo/command_spec.rb
|
288
302
|
- spec/gentoo/cron_spec.rb
|
289
303
|
- spec/gentoo/default_gateway_spec.rb
|
@@ -454,6 +468,18 @@ test_files:
|
|
454
468
|
- spec/debian/service_spec.rb
|
455
469
|
- spec/debian/user_spec.rb
|
456
470
|
- spec/debian/zfs_spec.rb
|
471
|
+
- spec/freebsd/command_spec.rb
|
472
|
+
- spec/freebsd/cron_spec.rb
|
473
|
+
- spec/freebsd/default_gateway_spec.rb
|
474
|
+
- spec/freebsd/file_spec.rb
|
475
|
+
- spec/freebsd/group_spec.rb
|
476
|
+
- spec/freebsd/host_spec.rb
|
477
|
+
- spec/freebsd/package_spec.rb
|
478
|
+
- spec/freebsd/php_config_spec.rb
|
479
|
+
- spec/freebsd/port_spec.rb
|
480
|
+
- spec/freebsd/routing_table_spec.rb
|
481
|
+
- spec/freebsd/service_spec.rb
|
482
|
+
- spec/freebsd/user_spec.rb
|
457
483
|
- spec/gentoo/command_spec.rb
|
458
484
|
- spec/gentoo/cron_spec.rb
|
459
485
|
- spec/gentoo/default_gateway_spec.rb
|