summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/provider/remote_file/content.rb9
-rw-r--r--lib/chef/provider/remote_file/ftp.rb1
-rw-r--r--lib/chef/provider/remote_file/util.rb43
-rw-r--r--lib/chef/providers.rb1
-rw-r--r--spec/unit/provider/remote_file/content_spec.rb28
5 files changed, 2 insertions, 80 deletions
diff --git a/lib/chef/provider/remote_file/content.rb b/lib/chef/provider/remote_file/content.rb
index 586f75f5bc..d75ee735a1 100644
--- a/lib/chef/provider/remote_file/content.rb
+++ b/lib/chef/provider/remote_file/content.rb
@@ -21,15 +21,12 @@ require 'rest_client'
require 'uri'
require 'tempfile'
require 'chef/file_content_management/content_base'
-require 'chef/provider/remote_file/util'
class Chef
class Provider
class RemoteFile
class Content < Chef::FileContentManagement::ContentBase
- attr_reader :raw_file_source
-
private
def file_for_provider
@@ -39,13 +36,11 @@ class Chef
Chef::Log.debug("#{@new_resource} checksum matches target checksum (#{@new_resource.checksum}) - not updating")
else
sources = @new_resource.source
- raw_file, @raw_file_source = try_multiple_sources(sources)
+ raw_file = try_multiple_sources(sources)
end
raw_file
end
- private
-
# Given an array of source uris, iterate through them until one does not fail
def try_multiple_sources(sources)
sources = sources.dup
@@ -62,7 +57,7 @@ class Chef
raise e
end
end
- return raw_file, Chef::Provider::RemoteFile::Util.uri_for_cache(uri)
+ raw_file
end
# Given a source uri, return a Tempfile, or a File that acts like a Tempfile (close! method)
diff --git a/lib/chef/provider/remote_file/ftp.rb b/lib/chef/provider/remote_file/ftp.rb
index f772d19cc9..865667a31c 100644
--- a/lib/chef/provider/remote_file/ftp.rb
+++ b/lib/chef/provider/remote_file/ftp.rb
@@ -20,7 +20,6 @@ require 'uri'
require 'tempfile'
require 'net/ftp'
require 'chef/provider/remote_file'
-require 'chef/provider/remote_file/util'
require 'chef/provider/remote_file/result'
require 'chef/file_content_management/tempfile'
diff --git a/lib/chef/provider/remote_file/util.rb b/lib/chef/provider/remote_file/util.rb
deleted file mode 100644
index 6a6b71e8e0..0000000000
--- a/lib/chef/provider/remote_file/util.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# Author:: Jesse Campbell (<hikeit@gmail.com>)
-# Author:: Lamont Granquist (<lamont@opscode.com>)
-# Copyright:: Copyright (c) 2013 Jesse Campbell
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-class Chef
- class Provider
- class RemoteFile
- class Util
- def self.uri_for_cache(uri)
- sanitized_uri(uri).to_s
- end
-
- def self.uri_matches_string?(u1, u2)
- # we store sanitiszed uris, so have to compare sanitized uris
- return false if u1.nil? || u2.nil?
- sanitized_uri(u1).to_s == u2
- end
-
- def self.sanitized_uri(uri)
- uri_dup = uri.dup
- uri_dup.password = "********" if uri_dup.userinfo
- uri_dup
- end
- end
- end
- end
-end
-
diff --git a/lib/chef/providers.rb b/lib/chef/providers.rb
index 9ecdee322a..8fc66fc9a8 100644
--- a/lib/chef/providers.rb
+++ b/lib/chef/providers.rb
@@ -107,7 +107,6 @@ require 'chef/provider/remote_file/http'
require 'chef/provider/remote_file/local_file'
require 'chef/provider/remote_file/fetcher'
require 'chef/provider/remote_file/result'
-require 'chef/provider/remote_file/util'
require "chef/provider/lwrp_base"
require 'chef/provider/registry_key'
diff --git a/spec/unit/provider/remote_file/content_spec.rb b/spec/unit/provider/remote_file/content_spec.rb
index 0e030ab2e8..ed02fa9a32 100644
--- a/spec/unit/provider/remote_file/content_spec.rb
+++ b/spec/unit/provider/remote_file/content_spec.rb
@@ -79,9 +79,7 @@ describe Chef::Provider::RemoteFile::Content do
before do
# FIXME: test one or the other nil, test both not nil and not equal, abuse the regexp a little
@uri = mock("URI")
- @sanitized_uri = mock("URI")
URI.should_receive(:parse).with(new_resource.source[0]).and_return(@uri)
- Chef::Provider::RemoteFile::Util.should_receive(:uri_for_cache).with(@uri).and_return(@sanitized_uri)
end
describe "when the fetcher returns nil for the tempfile" do
@@ -95,11 +93,6 @@ describe Chef::Provider::RemoteFile::Content do
content.tempfile.should be_nil
end
- it "should return the raw_file_source when the accessor is called after getting the tempfile" do
- content.tempfile
- content.raw_file_source.should == @sanitized_uri
- end
-
it "should not set the etags on the new resource" do
new_resource.should_not_receive(:etag).with(@result.etag)
content.tempfile
@@ -126,11 +119,6 @@ describe Chef::Provider::RemoteFile::Content do
content.tempfile.should == tempfile
end
- it "should return the raw_file_source when the accessor is called after getting the tempfile" do
- content.tempfile
- content.raw_file_source.should == @sanitized_uri
- end
-
end
end
describe "when the checksum are both nil" do
@@ -175,7 +163,6 @@ describe Chef::Provider::RemoteFile::Content do
http_fetcher = mock("Chef::Provider::RemoteFile::HTTP")
http_fetcher.should_receive(:fetch).and_raise(Errno::ECONNREFUSED)
Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher)
- Chef::Provider::RemoteFile::Util.should_not_receive(:uri_for_cache)
end
it "should propagate the error back to the caller" do
@@ -205,19 +192,12 @@ describe Chef::Provider::RemoteFile::Content do
@result = mock("Chef::Provider::RemoteFile::Result", :raw_file => @tempfile, :etag => "etag", :mtime => mtime)
http_fetcher_works = mock("Chef::Provider::RemoteFile::HTTP", :fetch => @result)
Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri1, new_resource, current_resource).and_return(http_fetcher_works)
- @sanitized_uri = mock("URI")
- Chef::Provider::RemoteFile::Util.should_receive(:uri_for_cache).with(@uri1).and_return(@sanitized_uri)
end
it "should return a valid tempfile" do
content.tempfile.should == @tempfile
end
- it "should return the raw_file_source when the accessor is called after getting the tempfile" do
- content.tempfile
- content.raw_file_source.should == @sanitized_uri
- end
-
it "should not mutate the new_resource" do
content.tempfile
new_resource.source.length.should == 2
@@ -227,7 +207,6 @@ describe Chef::Provider::RemoteFile::Content do
describe "when both urls fail" do
before do
Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri1, new_resource, current_resource).and_return(@http_fetcher_throws_exception)
- Chef::Provider::RemoteFile::Util.should_not_receive(:uri_for_cache)
end
it "should propagate the error back to the caller" do
@@ -249,19 +228,12 @@ describe Chef::Provider::RemoteFile::Content do
@result = mock("Chef::Provider::RemoteFile::Result", :raw_file => @tempfile, :etag => "etag", :mtime => mtime)
http_fetcher_works = mock("Chef::Provider::RemoteFile::HTTP", :fetch => @result)
Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri0, new_resource, current_resource).and_return(http_fetcher_works)
- @sanitized_uri = mock("URI")
- Chef::Provider::RemoteFile::Util.should_receive(:uri_for_cache).with(@uri0).and_return(@sanitized_uri)
end
it "should return a valid tempfile" do
content.tempfile.should == @tempfile
end
- it "should return the raw_file_source when the accessor is called after getting the tempfile" do
- content.tempfile
- content.raw_file_source.should == @sanitized_uri
- end
-
it "should not mutate the new_resource" do
content.tempfile
new_resource.source.length.should == 2