diff options
author | danielsdeleo <dan@opscode.com> | 2013-05-24 15:58:58 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-05-24 15:58:58 -0700 |
commit | dd134a7861e4168c553e201dab08cfcfa9b3e360 (patch) | |
tree | 593243a2ee3929b7b617af6d2834f9e81e6ee876 /spec/unit/provider/remote_file | |
parent | 18259659df47983e52fd46c9a3c1656064c1361e (diff) | |
download | chef-dd134a7861e4168c553e201dab08cfcfa9b3e360.tar.gz |
sanitize passwords in URLs when caching metadata
replace passwords with 'XXXX' when generating the file cache path to
store cache control headers for that URI.
Diffstat (limited to 'spec/unit/provider/remote_file')
-rw-r--r-- | spec/unit/provider/remote_file/cache_control_data_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/unit/provider/remote_file/cache_control_data_spec.rb b/spec/unit/provider/remote_file/cache_control_data_spec.rb index d0ac00bcbf..fa6246fd84 100644 --- a/spec/unit/provider/remote_file/cache_control_data_spec.rb +++ b/spec/unit/provider/remote_file/cache_control_data_spec.rb @@ -51,6 +51,16 @@ describe Chef::Provider::RemoteFile::CacheControlData do cache_control_data.etag.should be_nil cache_control_data.mtime.should be_nil end + + context "and the URI contains a password" do + + let(:uri) { URI.parse("http://bob:password@example.org/") } + let(:cache_path) { "remote_file/http___bob_XXXX_example_org_-f121caacb74c05a35bcefdf578ed5fc9.json" } + + it "loads the cache data from a path based on a sanitized URI" do + Chef::Provider::RemoteFile::CacheControlData.load_and_validate(uri, current_file_checksum) + end + end end describe "when loading data for a known URI" do @@ -133,6 +143,18 @@ describe Chef::Provider::RemoteFile::CacheControlData do Chef::FileCache.should_receive(:store).with(cache_path, json_data) cache_control_data.save end + + context "and the URI contains a password" do + + let(:uri) { URI.parse("http://bob:password@example.org/") } + let(:cache_path) { "remote_file/http___bob_XXXX_example_org_-f121caacb74c05a35bcefdf578ed5fc9.json" } + + it "writes the data to the cache with a sanitized path name" do + json_data = cache_control_data.json_data + Chef::FileCache.should_receive(:store).with(cache_path, json_data) + cache_control_data.save + end + end end end |