serverspec 0.10.7 → 0.10.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05c1dc06b5b4833b7e537d596b488b3bb07aba0e
4
- data.tar.gz: c8fa93b1eab1507daa911da2a1e1b55c20dcac9c
3
+ metadata.gz: ee22569ea7858b5dc4817a5a94c5e078cd23b978
4
+ data.tar.gz: 901515d1acf81c1fa811e25fd7ba021b85e810d5
5
5
  SHA512:
6
- metadata.gz: eeab306443ccc7261c6dacf25553d98481fed15453e650c55f79c574223485a02dab66ac73751b8ca7468275defb4fbf5de8d66dbc763b941023c26f4a00c5e4
7
- data.tar.gz: 7c53f323cfcee38681c359ce7bdbef51b0e85089cec4dda10537a11aebf1af200ec93f1ca8a88a4d26e7a1084f5533b8483f57d44eba993737ccadf66ee2ba60
6
+ metadata.gz: 38b35ba251f384147a3dc0a98e658ed4cd56c72087be4796e3ab2fb310e90cadc179a4cd0506023393dd435684444406e39fee6f636a896557829dd2f9677ef1
7
+ data.tar.gz: c98ab2cecdb1c54fca0c3971bfddb164a5d38280fac9c0eccfbf05258e8168d172c9c36f23b5e15704ebf384b02024baf4109ededdeec10d608b20cd635cf740
@@ -288,6 +288,10 @@ module Serverspec
288
288
  target = "[[:space:]]#{target}"
289
289
  "getent aliases #{escape(recipient)} | grep -- #{escape(target)}$"
290
290
  end
291
+
292
+ def get_file_content(file)
293
+ "cat #{file}"
294
+ end
291
295
  end
292
296
  end
293
297
  end
@@ -1,6 +1,8 @@
1
1
  module Serverspec
2
2
  module Type
3
3
  class File < Base
4
+ attr_accessor :content
5
+
4
6
  def file?
5
7
  backend.check_file(@name)
6
8
  end
@@ -73,6 +75,12 @@ module Serverspec
73
75
  backend.check_file_sha256checksum(@name, sha256sum)
74
76
  end
75
77
 
78
+ def content
79
+ if @content.nil?
80
+ @content = backend.run_command(commands.get_file_content(@name))[:stdout]
81
+ end
82
+ @content
83
+ end
76
84
  end
77
85
  end
78
86
  end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.10.7"
2
+ VERSION = "0.10.8"
3
3
  end
@@ -386,3 +386,21 @@ end
386
386
  describe file('invalid-file') do
387
387
  it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
388
388
  end
389
+
390
+ describe file('/etc/passwd') do
391
+ let(:stdout) {<<EOF
392
+ root:x:0:0:root:/root:/bin/bash
393
+ bin:x:1:1:bin:/bin:/sbin/nologin
394
+ daemon:x:2:2:daemon:/sbin:/sbin/nologin
395
+ sync:x:5:0:sync:/sbin:/bin/sync
396
+ shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
397
+ halt:x:7:0:halt:/sbin:/sbin/halt
398
+ mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
399
+ operator:x:11:0:operator:/root:/sbin/nologin
400
+ nobody:x:99:99:Nobody:/:/sbin/nologin
401
+ dbus:x:81:81:System message bus:/:/sbin/nologin
402
+ EOF
403
+ }
404
+
405
+ its(:content) { should match /root:x:0:0/ }
406
+ end
@@ -395,3 +395,21 @@ end
395
395
  describe file('invalid-file') do
396
396
  it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
397
397
  end
398
+
399
+ describe file('/etc/passwd') do
400
+ let(:stdout) {<<EOF
401
+ root:x:0:0:root:/root:/bin/bash
402
+ bin:x:1:1:bin:/bin:/sbin/nologin
403
+ daemon:x:2:2:daemon:/sbin:/sbin/nologin
404
+ sync:x:5:0:sync:/sbin:/bin/sync
405
+ shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
406
+ halt:x:7:0:halt:/sbin:/sbin/halt
407
+ mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
408
+ operator:x:11:0:operator:/root:/sbin/nologin
409
+ nobody:x:99:99:Nobody:/:/sbin/nologin
410
+ dbus:x:81:81:System message bus:/:/sbin/nologin
411
+ EOF
412
+ }
413
+
414
+ its(:content) { should match /root:x:0:0/ }
415
+ end
@@ -395,3 +395,21 @@ end
395
395
  describe file('invalid-file') do
396
396
  it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
397
397
  end
398
+
399
+ describe file('/etc/passwd') do
400
+ let(:stdout) {<<EOF
401
+ root:x:0:0:root:/root:/bin/bash
402
+ bin:x:1:1:bin:/bin:/sbin/nologin
403
+ daemon:x:2:2:daemon:/sbin:/sbin/nologin
404
+ sync:x:5:0:sync:/sbin:/bin/sync
405
+ shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
406
+ halt:x:7:0:halt:/sbin:/sbin/halt
407
+ mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
408
+ operator:x:11:0:operator:/root:/sbin/nologin
409
+ nobody:x:99:99:Nobody:/:/sbin/nologin
410
+ dbus:x:81:81:System message bus:/:/sbin/nologin
411
+ EOF
412
+ }
413
+
414
+ its(:content) { should match /root:x:0:0/ }
415
+ end
@@ -367,3 +367,21 @@ end
367
367
  describe file('invalid-file') do
368
368
  it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
369
369
  end
370
+
371
+ describe file('/etc/passwd') do
372
+ let(:stdout) {<<EOF
373
+ root:x:0:0:root:/root:/bin/bash
374
+ bin:x:1:1:bin:/bin:/sbin/nologin
375
+ daemon:x:2:2:daemon:/sbin:/sbin/nologin
376
+ sync:x:5:0:sync:/sbin:/bin/sync
377
+ shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
378
+ halt:x:7:0:halt:/sbin:/sbin/halt
379
+ mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
380
+ operator:x:11:0:operator:/root:/sbin/nologin
381
+ nobody:x:99:99:Nobody:/:/sbin/nologin
382
+ dbus:x:81:81:System message bus:/:/sbin/nologin
383
+ EOF
384
+ }
385
+
386
+ its(:content) { should match /root:x:0:0/ }
387
+ end
@@ -393,3 +393,21 @@ end
393
393
  describe file('invalid-file') do
394
394
  it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
395
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
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.configure do |c|
4
- c.os = 'RedHat'
4
+ c.os = 'Plamo'
5
5
  end
6
6
 
7
7
  describe cgroup('group1') do
@@ -395,3 +395,21 @@ end
395
395
  describe file('invalid-file') do
396
396
  it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
397
397
  end
398
+
399
+ describe file('/etc/passwd') do
400
+ let(:stdout) {<<EOF
401
+ root:x:0:0:root:/root:/bin/bash
402
+ bin:x:1:1:bin:/bin:/sbin/nologin
403
+ daemon:x:2:2:daemon:/sbin:/sbin/nologin
404
+ sync:x:5:0:sync:/sbin:/bin/sync
405
+ shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
406
+ halt:x:7:0:halt:/sbin:/sbin/halt
407
+ mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
408
+ operator:x:11:0:operator:/root:/sbin/nologin
409
+ nobody:x:99:99:Nobody:/:/sbin/nologin
410
+ dbus:x:81:81:System message bus:/:/sbin/nologin
411
+ EOF
412
+ }
413
+
414
+ its(:content) { should match /root:x:0:0/ }
415
+ end
@@ -395,3 +395,21 @@ end
395
395
  describe file('invalid-file') do
396
396
  it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
397
397
  end
398
+
399
+ describe file('/etc/passwd') do
400
+ let(:stdout) {<<EOF
401
+ root:x:0:0:root:/root:/bin/bash
402
+ bin:x:1:1:bin:/bin:/sbin/nologin
403
+ daemon:x:2:2:daemon:/sbin:/sbin/nologin
404
+ sync:x:5:0:sync:/sbin:/bin/sync
405
+ shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
406
+ halt:x:7:0:halt:/sbin:/sbin/halt
407
+ mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
408
+ operator:x:11:0:operator:/root:/sbin/nologin
409
+ nobody:x:99:99:Nobody:/:/sbin/nologin
410
+ dbus:x:81:81:System message bus:/:/sbin/nologin
411
+ EOF
412
+ }
413
+
414
+ its(:content) { should match /root:x:0:0/ }
415
+ end
@@ -393,3 +393,21 @@ end
393
393
  describe file('invalid-file') do
394
394
  it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
395
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
@@ -395,3 +395,21 @@ end
395
395
  describe file('invalid-file') do
396
396
  it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
397
397
  end
398
+
399
+ describe file('/etc/passwd') do
400
+ let(:stdout) {<<EOF
401
+ root:x:0:0:root:/root:/bin/bash
402
+ bin:x:1:1:bin:/bin:/sbin/nologin
403
+ daemon:x:2:2:daemon:/sbin:/sbin/nologin
404
+ sync:x:5:0:sync:/sbin:/bin/sync
405
+ shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
406
+ halt:x:7:0:halt:/sbin:/sbin/halt
407
+ mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
408
+ operator:x:11:0:operator:/root:/sbin/nologin
409
+ nobody:x:99:99:Nobody:/:/sbin/nologin
410
+ dbus:x:81:81:System message bus:/:/sbin/nologin
411
+ EOF
412
+ }
413
+
414
+ its(:content) { should match /root:x:0:0/ }
415
+ 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.10.7
4
+ version: 0.10.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
@@ -305,7 +305,6 @@ files:
305
305
  - spec/plamo/routing_table_spec.rb
306
306
  - spec/plamo/selinux_spec.rb
307
307
  - spec/plamo/service_spec.rb
308
- - spec/plamo/service_spec.rb.plamo
309
308
  - spec/plamo/user_spec.rb
310
309
  - spec/plamo/zfs_spec.rb
311
310
  - spec/redhat/cgroup_spec.rb
@@ -503,7 +502,6 @@ test_files:
503
502
  - spec/plamo/routing_table_spec.rb
504
503
  - spec/plamo/selinux_spec.rb
505
504
  - spec/plamo/service_spec.rb
506
- - spec/plamo/service_spec.rb.plamo
507
505
  - spec/plamo/user_spec.rb
508
506
  - spec/plamo/zfs_spec.rb
509
507
  - spec/redhat/cgroup_spec.rb
@@ -1,63 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.configure do |c|
4
- c.os = 'Debian'
5
- end
6
-
7
- describe service('sshd') do
8
- it { should be_enabled }
9
- its(:command) { should eq "test -x /etc/rc.d/init.d/sshd" }
10
- end
11
-
12
- describe service('invalid-service') do
13
- it { should_not be_enabled }
14
- end
15
-
16
- describe service('sshd') do
17
- it { should be_enabled.with_level(4) }
18
- its(:command) { should eq "test -x /etc/rc.d/init.d/sshd" }
19
- end
20
-
21
- describe service('invalid-service') do
22
- it { should_not be_enabled.with_level(4) }
23
- end
24
-
25
- describe service('sshd') do
26
- it {
27
- expect {
28
- should be_running.under('not implemented')
29
- }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/)
30
- }
31
- end
32
-
33
- describe service('sshd') do
34
- let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" }
35
- it { should be_monitored_by('monit') }
36
- its(:command) { should eq "monit status" }
37
- end
38
-
39
- describe service('sshd') do
40
- let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" }
41
- it { should_not be_monitored_by('monit') }
42
- end
43
-
44
- describe service('invalid-daemon') do
45
- it { should_not be_monitored_by('monit') }
46
- end
47
-
48
- describe service('unicorn') do
49
- it { should be_monitored_by('god') }
50
- its(:command) { should eq "god status unicorn" }
51
- end
52
-
53
- describe service('invalid-daemon') do
54
- it { should_not be_monitored_by('god') }
55
- end
56
-
57
- describe service('sshd') do
58
- it {
59
- expect {
60
- should be_monitored_by('not implemented')
61
- }.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/)
62
- }
63
- end