Skip to content

Commit aa56c97

Browse files
committed
(MODULES-11110) Fix fingerprint comparison
Given input: current fingerprint say "a/c/d" latest fingerprint say "a/b/c/d" doing `latest.include? current` would fail. A set comparison is more accurate here.
1 parent 35940b4 commit aa56c97

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/puppet/type/java_ks.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def insync?(is)
3535
return true if is == :absent
3636
when :latest
3737
unless is == :absent
38-
return true if provider.latest.include? provider.current
38+
current = provider.current.split('/')
39+
latest = provider.latest.split('/')
40+
return true if current.to_set.subset?(latest.to_set)
3941
end
4042
end
4143
end

spec/unit/puppet/type/java_ks_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@
184184
allow(provider_var).to receive(:current).and_return('66:9B:8B:23:4C:6A:9A:08:F6:4E:B6:01:23:EA:5A')
185185
expect(described_class.new(jks).property(:ensure)).to be_insync(:present)
186186
end
187+
188+
it 'insync? should return true if subset of sha1 fingerprints match and state is :present' do
189+
jks = jks_resource.dup
190+
jks[:ensure] = :latest
191+
allow(provider_var).to receive(:latest).and_return('9B:8B:23:4C:6A:9A:08:F6:4E:B6:01:23:EA:5A:E7:8F:6A/66:9B:8B:23:4C:6A:9A:08:F6:4E:B6:01:23:EA:5A')
192+
allow(provider_var).to receive(:current).and_return('66:9B:8B:23:4C:6A:9A:08:F6:4E:B6:01:23:EA:5A')
193+
expect(described_class.new(jks).property(:ensure)).to be_insync(:present)
194+
end
187195
end
188196

189197
describe 'when file resources are in the catalog' do

0 commit comments

Comments
 (0)