serverspec 0.2.25 → 0.2.26
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/serverspec/commands/base.rb +4 -0
- data/lib/serverspec/matchers.rb +1 -0
- data/lib/serverspec/matchers/match_md5checksum.rb +5 -0
- data/lib/serverspec/version.rb +1 -1
- data/spec/debian/commands_spec.rb +6 -0
- data/spec/debian/matchers_spec.rb +1 -0
- data/spec/gentoo/commands_spec.rb +5 -0
- data/spec/gentoo/matchers_spec.rb +1 -0
- data/spec/redhat/commands_spec.rb +5 -0
- data/spec/redhat/matchers_spec.rb +1 -0
- data/spec/solaris/commands_spec.rb +5 -0
- data/spec/solaris/matchers_spec.rb +1 -0
- data/spec/support/shared_matcher_examples.rb +12 -0
- metadata +5 -4
@@ -77,6 +77,10 @@ module Serverspec
|
|
77
77
|
"grep -q -- #{escape(expected_pattern)} #{escape(file)}"
|
78
78
|
end
|
79
79
|
|
80
|
+
def check_file_md5checksum file, expected
|
81
|
+
"md5sum #{escape(file)} | grep -iw -- ^#{escape(expected)}"
|
82
|
+
end
|
83
|
+
|
80
84
|
def check_file_contain_within file, expected_pattern, from=nil, to=nil
|
81
85
|
from ||= '1'
|
82
86
|
to ||= '$'
|
data/lib/serverspec/matchers.rb
CHANGED
data/lib/serverspec/version.rb
CHANGED
@@ -45,6 +45,12 @@ describe 'check_resolvable', :os => :debian do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
describe 'check_file_md5checksum', :os => :debian do
|
49
|
+
subject { commands.check_file_md5checksum('/etc/passwd', '96c8c50f81a29965f7af6de371ab4250') }
|
50
|
+
it { should eq "md5sum /etc/passwd | grep -iw -- ^96c8c50f81a29965f7af6de371ab4250" }
|
51
|
+
end
|
52
|
+
|
53
|
+
|
48
54
|
describe 'check_directory', :os => :debian do
|
49
55
|
subject { commands.check_directory('/var/log') }
|
50
56
|
it { should eq 'test -d /var/log' }
|
@@ -22,6 +22,7 @@ describe 'Serverspec matchers of Debian family', :os => :debian do
|
|
22
22
|
it_behaves_like 'support contain.from.to matcher', 'Gemfile', 'rspec', /^group :test do/, /^end/
|
23
23
|
it_behaves_like 'support contain.after matcher', 'Gemfile', 'rspec', /^group :test do/
|
24
24
|
it_behaves_like 'support contain.before matcher', 'Gemfile', 'rspec', /^end/
|
25
|
+
it_behaves_like 'support match_md5checksum matcher', '/etc/services', '35435ea447c19f0ea5ef971837ab9ced'
|
25
26
|
it_behaves_like 'support be_user matcher', 'root'
|
26
27
|
it_behaves_like 'support be_group matcher', 'wheel'
|
27
28
|
|
@@ -112,6 +112,11 @@ describe 'check_file_contain_within', :os => :gentoo do
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
+
describe 'check_file_md5checksum', :os => :gentoo do
|
116
|
+
subject { commands.check_file_md5checksum('/etc/passwd', '96c8c50f81a29965f7af6de371ab4250') }
|
117
|
+
it { should eq "md5sum /etc/passwd | grep -iw -- ^96c8c50f81a29965f7af6de371ab4250" }
|
118
|
+
end
|
119
|
+
|
115
120
|
describe 'check_mode', :os => :gentoo do
|
116
121
|
subject { commands.check_mode('/etc/sudoers', 440) }
|
117
122
|
it { should eq 'stat -c %a /etc/sudoers | grep -- \\^440\\$' }
|
@@ -23,6 +23,7 @@ describe 'Serverspec matchers of Gentoo family', :os => :gentoo do
|
|
23
23
|
it_behaves_like 'support contain.from.to matcher', 'Gemfile', 'rspec', /^group :test do/, /^end/
|
24
24
|
it_behaves_like 'support contain.after matcher', 'Gemfile', 'rspec', /^group :test do/
|
25
25
|
it_behaves_like 'support contain.before matcher', 'Gemfile', 'rspec', /^end/
|
26
|
+
it_behaves_like 'support match_md5checksum matcher', '/etc/services', '35435ea447c19f0ea5ef971837ab9ced'
|
26
27
|
it_behaves_like 'support be_user matcher', 'root'
|
27
28
|
it_behaves_like 'support be_group matcher', 'wheel'
|
28
29
|
|
@@ -112,6 +112,11 @@ describe 'check_file_contain_within', :os => :redhat do
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
+
describe 'check_file_md5checksum', :os => :redhat do
|
116
|
+
subject { commands.check_file_md5checksum('/etc/passwd', '96c8c50f81a29965f7af6de371ab4250') }
|
117
|
+
it { should eq "md5sum /etc/passwd | grep -iw -- ^96c8c50f81a29965f7af6de371ab4250" }
|
118
|
+
end
|
119
|
+
|
115
120
|
describe 'check_mode', :os => :redhat do
|
116
121
|
subject { commands.check_mode('/etc/sudoers', 440) }
|
117
122
|
it { should eq 'stat -c %a /etc/sudoers | grep -- \\^440\\$' }
|
@@ -24,6 +24,7 @@ describe 'Serverspec matchers of Red Hat family', :os => :redhat do
|
|
24
24
|
it_behaves_like 'support contain.from.to matcher', 'Gemfile', 'rspec', /^group :test do/, /^end/
|
25
25
|
it_behaves_like 'support contain.after matcher', 'Gemfile', 'rspec', /^group :test do/
|
26
26
|
it_behaves_like 'support contain.before matcher', 'Gemfile', 'rspec', /^end/
|
27
|
+
it_behaves_like 'support match_md5checksum matcher', '/etc/services', '35435ea447c19f0ea5ef971837ab9ced'
|
27
28
|
it_behaves_like 'support be_user matcher', 'root'
|
28
29
|
it_behaves_like 'support be_group matcher', 'wheel'
|
29
30
|
|
@@ -112,6 +112,11 @@ describe 'check_file_contain_within', :os => :solaris do
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
+
describe 'check_file_md5checksum', :os => :solaris do
|
116
|
+
subject { commands.check_file_md5checksum('/etc/passwd', '96c8c50f81a29965f7af6de371ab4250') }
|
117
|
+
it { should eq "md5sum /etc/passwd | grep -iw -- ^96c8c50f81a29965f7af6de371ab4250" }
|
118
|
+
end
|
119
|
+
|
115
120
|
describe 'check_mode', :os => :solaris do
|
116
121
|
subject { commands.check_mode('/etc/sudoers', 440) }
|
117
122
|
it { should eq 'stat -c %a /etc/sudoers | grep -- \\^440\\$' }
|
@@ -23,6 +23,7 @@ describe 'Serverspec matchers of Solaris family', :os => :solaris do
|
|
23
23
|
it_behaves_like 'support contain.from.to matcher', 'Gemfile', 'rspec', /^group :test do/, /^end/
|
24
24
|
it_behaves_like 'support contain.after matcher', 'Gemfile', 'rspec', /^group :test do/
|
25
25
|
it_behaves_like 'support contain.before matcher', 'Gemfile', 'rspec', /^end/
|
26
|
+
it_behaves_like 'support match_md5checksum matcher', '/etc/services', '35435ea447c19f0ea5ef971837ab9ced'
|
26
27
|
it_behaves_like 'support be_user matcher', 'root'
|
27
28
|
it_behaves_like 'support be_group matcher', 'root'
|
28
29
|
|
@@ -350,6 +350,18 @@ shared_examples_for 'support contain.before matcher' do |valid_file, pattern, be
|
|
350
350
|
end
|
351
351
|
end
|
352
352
|
|
353
|
+
shared_examples_for 'support match_md5checksum matcher' do |valid_file, pattern|
|
354
|
+
describe 'match_md5checksum' do
|
355
|
+
describe valid_file do
|
356
|
+
it { should match_md5checksum pattern }
|
357
|
+
end
|
358
|
+
|
359
|
+
describe '/invalid_file' do
|
360
|
+
it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' }
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
353
365
|
shared_examples_for 'support be_user matcher' do |valid_user|
|
354
366
|
describe 'be_user' do
|
355
367
|
describe valid_user do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 35
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 26
|
10
|
+
version: 0.2.26
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gosuke Miyashita
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-05-
|
18
|
+
date: 2013-05-10 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- lib/serverspec/matchers/have_svcprop.rb
|
169
169
|
- lib/serverspec/matchers/have_svcprops.rb
|
170
170
|
- lib/serverspec/matchers/have_uid.rb
|
171
|
+
- lib/serverspec/matchers/match_md5checksum.rb
|
171
172
|
- lib/serverspec/matchers/return_exit_status.rb
|
172
173
|
- lib/serverspec/matchers/return_stderr.rb
|
173
174
|
- lib/serverspec/matchers/return_stdout.rb
|