Skip to content

Commit

Permalink
Merge pull request #464 from serverspec/remove-match-checksum-matcher
Browse files Browse the repository at this point in the history
Remove match_checksum matcher
  • Loading branch information
mizzy committed Aug 10, 2014
2 parents 2a7151f + 68a2f89 commit fa4f5cd
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 46 deletions.
2 changes: 0 additions & 2 deletions lib/serverspec/matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
require 'serverspec/matcher/be_readable'
require 'serverspec/matcher/be_writable'
require 'serverspec/matcher/be_executable'
require 'serverspec/matcher/match_md5checksum'
require 'serverspec/matcher/match_sha256checksum'

# port
require 'serverspec/matcher/be_listening'
Expand Down
5 changes: 0 additions & 5 deletions lib/serverspec/matcher/match_md5checksum.rb

This file was deleted.

5 changes: 0 additions & 5 deletions lib/serverspec/matcher/match_sha256checksum.rb

This file was deleted.

12 changes: 4 additions & 8 deletions lib/serverspec/type/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,12 @@ def immutable?
@runner.check_file_is_immutable(@name)
end

def match_checksum(checksum)
@runner.check_file_has_checksum(@name, checksum)
def md5sum
@runner.get_file_md5sum(@name).stdout.strip
end

def match_md5checksum(md5sum)
@runner.check_file_has_md5checksum(@name, md5sum)
end

def match_sha256checksum(sha256sum)
@runner.check_file_has_sha256checksum(@name, sha256sum)
def sha256sum
@runner.get_file_sha256sum(@name).stdout.strip
end

def content
Expand Down
10 changes: 6 additions & 4 deletions spec/type/base/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,21 @@
end

describe file('/etc/services') do
it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' }
let(:stdout) { "35435ea447c19f0ea5ef971837ab9ced\n" }
its(:md5sum) { should eq '35435ea447c19f0ea5ef971837ab9ced' }
end

describe file('invalid-file') do
it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' }
its(:md5sum) { should_not eq 'INVALIDMD5CHECKSUM' }
end

describe file('/etc/services') do
it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' }
let(:stdout) {"0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" }
its(:sha256sum) { should eq '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' }
end

describe file('invalid-file') do
it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
its(:sha256sum) { should_not eq 'INVALIDSHA256CHECKSUM' }
end

describe file('/etc/passwd') do
Expand Down
6 changes: 4 additions & 2 deletions spec/type/darwin/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
end

describe file('/etc/services') do
it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' }
let(:stdout) { "35435ea447c19f0ea5ef971837ab9ced\n" }
its(:md5sum) { should eq '35435ea447c19f0ea5ef971837ab9ced' }
end

describe file('/etc/services') do
it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' }
let(:stdout) {"0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" }
its(:sha256sum) { should eq '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' }
end

describe file('/etc/pam.d/system-auth') do
Expand Down
14 changes: 4 additions & 10 deletions spec/type/openbsd/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,11 @@
end

describe file('/etc/services') do
it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' }
end

describe file('invalid-file') do
it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' }
let(:stdout) { "35435ea447c19f0ea5ef971837ab9ced\n" }
its(:md5sum) { should eq '35435ea447c19f0ea5ef971837ab9ced' }
end

describe file('/etc/services') do
it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' }
end

describe file('invalid-file') do
it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
let(:stdout) {"0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" }
its(:sha256sum) { should eq '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' }
end
14 changes: 4 additions & 10 deletions spec/type/solaris10/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,13 @@
end

describe file('/etc/services') do
it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' }
end

describe file('invalid-file') do
it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' }
let(:stdout) { "35435ea447c19f0ea5ef971837ab9ced\n" }
its(:md5sum) { should eq '35435ea447c19f0ea5ef971837ab9ced' }
end

describe file('/etc/services') do
it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' }
end

describe file('invalid-file') do
it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
let(:stdout) {"0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" }
its(:md5sum) { should eq '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' }
end

describe file('/etc/passwd') do
Expand Down

0 comments on commit fa4f5cd

Please sign in to comment.