serverspec 1.4.2 → 1.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d724a709a1a634aba2973ce6382809eb74164456
4
- data.tar.gz: 9ee68261df8a027c7967531889d355d184b15917
3
+ metadata.gz: 2485850c66b67c0974175f1ddcfa7ed640a3cfd9
4
+ data.tar.gz: 574e7de2afd5ee8da989672fb16e8395be9ed98d
5
5
  SHA512:
6
- metadata.gz: 7f5124741074c03f7ec15ae2df01a6fe9f93fa755778cae4812261c8f7508d5f7426199684fdb46c3045a840a2d2fc38e521ed54717778755b7dda689224cb8a
7
- data.tar.gz: 147ff0c0746c0ae0cb8fe8ebe0930b0e1d1c6af060e9349e8de4ee9508518397c07c060b0eb62b244eb20c08827273d8682f5c96ac860134cf2d568e3dbec7c7
6
+ metadata.gz: 84f3caa4e2e4854d7dc641350c68148e68f3ef4c4fae831bf89d1e3eca3e8255dae866a3b14769f7e1888e721f59a45609444905ec38422ce5d453f09ed8d795
7
+ data.tar.gz: 35e9a8aa6c47a99cc712dc6727da8aff0db7fa245be235006a9ea23f1cef6304cb8e95bc8bdc045cae5680c8fb8cc99936da4a881b558b23e40ef31ca9a5eb92
data/README.md CHANGED
@@ -132,6 +132,7 @@ You can select from:
132
132
 
133
133
  * SpecInfra::Helper::RedHat
134
134
  * SpecInfra::Helper::Debian
135
+ * SpecInfra::Helper::Fedora
135
136
  * SpecInfra::Helper::Gentoo
136
137
  * SpecInfra::Helper::Solaris
137
138
  * SpecInfra::Helper::Darwin
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require "octorelease"
5
5
  task :spec => 'spec:all'
6
6
 
7
7
  namespace :spec do
8
- oses = %w( darwin debian gentoo plamo redhat aix solaris solaris10 solaris11 smartos windows freebsd freebsd10 arch)
8
+ oses = %w( darwin debian gentoo plamo redhat redhat7 aix solaris solaris10 solaris11 smartos windows freebsd freebsd10 arch fedora)
9
9
  backends = %w( exec ssh cmd winrm powershell )
10
10
 
11
11
  task :all => [ oses.map {|os| "spec:#{os}" }, backends, :helper, :unit ].flatten
@@ -6,11 +6,13 @@ module Serverspec
6
6
  'Arch',
7
7
  'Darwin',
8
8
  'Debian',
9
+ 'Fedora',
9
10
  'FreeBSD',
10
11
  'FreeBSD10',
11
12
  'Gentoo',
12
13
  'Plamo',
13
14
  'RedHat',
15
+ 'RedHat7',
14
16
  'SmartOS',
15
17
  'Solaris',
16
18
  'Solaris10',
@@ -14,11 +14,11 @@ module Serverspec
14
14
  end
15
15
 
16
16
  if @backend_type == 'Ssh'
17
- print "Vagrant instance y/n: "
17
+ print 'Vagrant instance y/n: '
18
18
  @vagrant = $stdin.gets.chomp
19
19
  if @vagrant =~ (/(true|t|yes|y|1)$/i)
20
20
  @vagrant = true
21
- print "Auto-configure Vagrant from Vagrantfile? y/n: "
21
+ print 'Auto-configure Vagrant from Vagrantfile? y/n: '
22
22
  auto_config = $stdin.gets.chomp
23
23
  if auto_config =~ (/(true|t|yes|y|1)$/i)
24
24
  auto_vagrant_configuration
@@ -35,7 +35,7 @@ module Serverspec
35
35
  @hostname = 'localhost'
36
36
  end
37
37
 
38
- [ 'spec', "spec/#{@hostname}" ].each { |dir| safe_mkdir(dir) }
38
+ ['spec', "spec/#{@hostname}"].each { |dir| safe_mkdir(dir) }
39
39
  safe_create_spec
40
40
  safe_create_spec_helper
41
41
  safe_create_rakefile
@@ -55,7 +55,7 @@ EOF
55
55
  num = $stdin.gets.to_i - 1
56
56
  puts
57
57
 
58
- @os_type = [ 'UN*X', 'Windows' ][num] || 'UN*X'
58
+ @os_type = ['UN*X', 'Windows'][num] || 'UN*X'
59
59
  end
60
60
 
61
61
  def self.ask_unix_backend
@@ -71,7 +71,7 @@ EOF
71
71
  num = $stdin.gets.to_i - 1
72
72
  puts
73
73
 
74
- @backend_type = [ 'Ssh', 'Exec' ][num] || 'Exec'
74
+ @backend_type = ['Ssh', 'Exec'][num] || 'Exec'
75
75
  end
76
76
 
77
77
  def self.ask_windows_backend
@@ -87,7 +87,7 @@ EOF
87
87
  num = $stdin.gets.to_i - 1
88
88
  puts
89
89
 
90
- @backend_type = [ 'WinRM', 'Cmd' ][num] || 'Exec'
90
+ @backend_type = ['WinRM', 'Cmd'][num] || 'Exec'
91
91
  end
92
92
 
93
93
  def self.safe_create_spec
@@ -138,7 +138,6 @@ EOF
138
138
  end
139
139
 
140
140
  def self.safe_create_spec_helper
141
- requirements = []
142
141
  content = ERB.new(spec_helper_template, nil, '-').result(binding)
143
142
  if File.exists? 'spec/spec_helper.rb'
144
143
  old_content = File.read('spec/spec_helper.rb')
@@ -167,7 +166,7 @@ task :default => :spec
167
166
  if File.exists? 'Rakefile'
168
167
  old_content = File.read('Rakefile')
169
168
  if old_content != content
170
- $stderr.puts "!! Rakefile already exists and differs from template"
169
+ $stderr.puts '!! Rakefile already exists and differs from template'
171
170
  end
172
171
  else
173
172
  File.open('Rakefile', 'w') do |f|
@@ -179,7 +178,7 @@ task :default => :spec
179
178
 
180
179
  def self.find_vagrantfile
181
180
  Pathname.new(Dir.pwd).ascend do |dir|
182
- path = File.expand_path("Vagrantfile", dir)
181
+ path = File.expand_path('Vagrantfile', dir)
183
182
  return path if File.exists?(path)
184
183
  end
185
184
  nil
@@ -199,16 +198,16 @@ task :default => :spec
199
198
  @hostname = list_of_vms[0]
200
199
  else
201
200
  list_of_vms.each_with_index { |vm, index | puts "#{index}) #{vm}\n" }
202
- print "Choose a VM from the Vagrantfile: "
201
+ print 'Choose a VM from the Vagrantfile: '
203
202
  chosen_vm = $stdin.gets.chomp
204
203
  @hostname = list_of_vms[chosen_vm.to_i]
205
204
  end
206
205
  else
207
- $stderr.puts "Vagrant status error - Check your Vagrantfile or .vagrant"
206
+ $stderr.puts 'Vagrant status error - Check your Vagrantfile or .vagrant'
208
207
  exit 1
209
208
  end
210
209
  else
211
- $stderr.puts "Vagrantfile not found in directory!"
210
+ $stderr.puts 'Vagrantfile not found in directory!'
212
211
  exit 1
213
212
  end
214
213
  end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "1.4.2"
2
+ VERSION = "1.5.0"
3
3
  end
data/serverspec.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_runtime_dependency "net-ssh"
22
22
  spec.add_runtime_dependency "rspec", "~> 2.13"
23
23
  spec.add_runtime_dependency "highline"
24
- spec.add_runtime_dependency "specinfra", "~> 1.5"
24
+ spec.add_runtime_dependency "specinfra", "~> 1.10"
25
25
  spec.add_development_dependency "bundler", "~> 1.3"
26
26
  spec.add_development_dependency "rake", "~> 10.1.1"
27
27
  spec.add_development_dependency "octokit", "~> 2.7.2"
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ include SpecInfra::Helper::Fedora
4
+
5
+ describe cgroup('group1') do
6
+ let(:stdout) { "1\r\n" }
7
+ its('cpuset.cpus') { should eq 1 }
8
+ its(:command) { should eq "cgget -n -r cpuset.cpus group1 | awk '{print $2}'" }
9
+ end
10
+
11
+ describe cgroup('group1') do
12
+ let(:stdout) { "1\r\n" }
13
+ its('cpuset.cpus') { should_not eq 0 }
14
+ end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ include SpecInfra::Helper::Fedora
4
+
5
+ =begin
6
+ describe command('cat /etc/resolv.conf') do
7
+ let(:stdout) { "nameserver 127.0.0.1\r\n" }
8
+ it { should return_stdout("nameserver 127.0.0.1") }
9
+ its(:command) { should eq 'cat /etc/resolv.conf' }
10
+ end
11
+
12
+ describe 'complete matching of stdout' do
13
+ context command('cat /etc/resolv.conf') do
14
+ let(:stdout) { "foocontent-should-be-includedbar\r\n" }
15
+ it { should_not return_stdout('content-should-be-included') }
16
+ end
17
+ end
18
+
19
+ describe 'regexp matching of stdout' do
20
+ context command('cat /etc/resolv.conf') do
21
+ let(:stdout) { "nameserver 127.0.0.1\r\n" }
22
+ it { should return_stdout(/127\.0\.0\.1/) }
23
+ end
24
+ end
25
+
26
+ describe command('cat /etc/resolv.conf') do
27
+ let(:stdout) { "No such file or directory\r\n" }
28
+ it { should return_stderr("No such file or directory") }
29
+ its(:command) { should eq 'cat /etc/resolv.conf' }
30
+ end
31
+
32
+ describe 'complete matching of stderr' do
33
+ context command('cat /etc/resolv.conf') do
34
+ let(:stdout) { "No such file or directory\r\n" }
35
+ it { should_not return_stdout('file') }
36
+ end
37
+ end
38
+
39
+ describe 'regexp matching of stderr' do
40
+ context command('cat /etc/resolv.conf') do
41
+ let(:stdout) { "No such file or directory\r\n" }
42
+ it { should return_stderr(/file/) }
43
+ end
44
+ end
45
+
46
+ describe command('cat /etc/resolv.conf') do
47
+ it { should return_exit_status 0 }
48
+ its(:command) { should eq 'cat /etc/resolv.conf' }
49
+ end
50
+ =end
51
+
52
+ describe command('ls -al /') do
53
+ let(:stdout) { <<EOF
54
+ total 88
55
+ drwxr-xr-x 23 root root 4096 Oct 10 17:19 .
56
+ drwxr-xr-x 23 root root 4096 Oct 10 17:19 ..
57
+ drwxr-xr-x 2 root root 4096 Sep 11 16:43 bin
58
+ drwxr-xr-x 3 root root 4096 Sep 23 18:14 boot
59
+ drwxr-xr-x 14 root root 4260 Oct 14 16:14 dev
60
+ drwxr-xr-x 104 root root 4096 Oct 14 17:34 etc
61
+ drwxr-xr-x 8 root root 4096 Oct 1 15:09 home
62
+ EOF
63
+ }
64
+
65
+ its(:stdout) { should match /bin/ }
66
+ its(:stdout) { should eq stdout }
67
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ include SpecInfra::Helper::Fedora
4
+
5
+ describe cron do
6
+ it { should have_entry '* * * * * /usr/local/bin/batch.sh' }
7
+ its(:command) { should eq 'crontab -l | grep -v "#" -- | 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 -v "#" | 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 SpecInfra::Helper::Fedora
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,413 @@
1
+ require 'spec_helper'
2
+
3
+ include SpecInfra::Helper::Fedora
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 "runuser -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 "runuser -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 "runuser -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 '35435ea447c19f0ea5ef971837ab9ced' }
381
+ its(:command) { should eq "md5sum /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
396
+
397
+ describe file('/etc/passwd') do
398
+ let(:stdout) {<<EOF
399
+ root:x:0:0:root:/root:/bin/bash
400
+ bin:x:1:1:bin:/bin:/sbin/nologin
401
+ daemon:x:2:2:daemon:/sbin:/sbin/nologin
402
+ sync:x:5:0:sync:/sbin:/bin/sync
403
+ shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
404
+ halt:x:7:0:halt:/sbin:/sbin/halt
405
+ mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
406
+ operator:x:11:0:operator:/root:/sbin/nologin
407
+ nobody:x:99:99:Nobody:/:/sbin/nologin
408
+ dbus:x:81:81:System message bus:/:/sbin/nologin
409
+ EOF
410
+ }
411
+
412
+ its(:content) { should match /root:x:0:0/ }
413
+ end