From fa721bea4fe479273306c93b70eca10fa661fc4e Mon Sep 17 00:00:00 2001 From: Aria Li Date: Mon, 1 Jul 2024 12:23:48 -0700 Subject: [PATCH] (PUP-12047) Add test to ensure MD5 checksum is skipped for FIPS This commit adds a test to http_metadata_spec.rb that checks that the MD5 checksum type is skipped in the collect method on FIPS enabled platforms. --- spec/unit/file_serving/http_metadata_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/unit/file_serving/http_metadata_spec.rb b/spec/unit/file_serving/http_metadata_spec.rb index 521abef34b0..78a525db1fa 100644 --- a/spec/unit/file_serving/http_metadata_spec.rb +++ b/spec/unit/file_serving/http_metadata_spec.rb @@ -29,6 +29,14 @@ expect( metadata.mode ).to be_nil end + it "skips md5 checksum type in collect on FIPS enabled platforms" do + allow(Puppet::Util::Platform).to receive(:fips_enabled?).and_return(true) + http_response['X-Checksum-Md5'] = 'c58989e9740a748de4f5054286faf99b' + metadata = described_class.new(http_response) + metadata.collect + expect( metadata.checksum_type ).to eq :mtime + end + context "with no Last-Modified or Content-MD5 header from the server" do it "should use :mtime as the checksum type, based on current time" do # Stringifying Time.now does some rounding; do so here so we don't end up with a time