summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJoseph Larionov <30190605+decoyjoe@users.noreply.github.com>2022-11-01 12:37:58 -0700
committerGitHub <noreply@github.com>2022-11-01 15:37:58 -0400
commitc4ce765dc71a2ad1762ce5c43f0e245a17909378 (patch)
treee4fac5f2b105844d97673e60e983c77649bfda9f /spec
parent117e74ccbd1a00b6fca7da4687a68feb995b7977 (diff)
downloadchef-c4ce765dc71a2ad1762ce5c43f0e245a17909378.tar.gz
Bugfix: checksum validation (#13210)
* Add a case-insensitive helper to determine if two checksums match * Use case-insensitive checksum match helper for checksum validation This fixes a bug where checksum validation fails because the two checksums are in different letter cases. The existing checksum validation logic was using case sensitive equality checks. Signed-off-by: Joseph Larionov <jlarionov@webmd.net>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/mixin/checksum_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/unit/mixin/checksum_spec.rb b/spec/unit/mixin/checksum_spec.rb
index e8fb1ed4dc..9c1e19769d 100644
--- a/spec/unit/mixin/checksum_spec.rb
+++ b/spec/unit/mixin/checksum_spec.rb
@@ -51,4 +51,32 @@ describe Chef::Mixin::Checksum do
end
end
+ describe "checksum_match?" do
+ context "when checksum cases match" do
+ it "returns true" do
+ expect(@checksum_user.checksum_match?("u7ghbxikk3i9blsimmy2y2ionmxx", "u7ghbxikk3i9blsimmy2y2ionmxx")).to be true
+ end
+ end
+
+ context "when one checksum is uppercase and other is lowercase" do
+ it "returns true" do
+ expect(@checksum_user.checksum_match?("U7GHBXIKK3I9BLSIMMY2Y2IONMXX", "u7ghbxikk3i9blsimmy2y2ionmxx")).to be true
+ end
+ end
+
+ context "when checksums do not match" do
+ it "returns false" do
+ expect(@checksum_user.checksum_match?("u7ghbxikk3i9blsimmy2y2ionmxx", "09ee9c8cc70501763563bcf9c218")).to be false
+ end
+ end
+
+ context "when checksum is nil" do
+ it "returns false" do
+ expect(@checksum_user.checksum_match?("u7ghbxikk3i9blsimmy2y2ionmxx", nil)).to be false
+ expect(@checksum_user.checksum_match?(nil, "09ee9c8cc70501763563bcf9c218")).to be false
+ expect(@checksum_user.checksum_match?(nil, nil)).to be false
+ end
+ end
+ end
+
end