summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-10-18 16:12:58 -0700
committerTim Smith <tsmith@chef.io>2017-10-19 15:07:13 -0700
commit90e6ac9a899f6aae856b661f7c8a835aa0ba5c22 (patch)
tree3e0274d0a6650ac090e0bce6c7fc4fecbc1a8a9a
parent25dd1d9dadb68224f600aabc7d05326acfef4d27 (diff)
downloadchef-90e6ac9a899f6aae856b661f7c8a835aa0ba5c22.tar.gz
Fix remote_file with UNC paths failingnodes_not_here
Our check here to see if we're on Windows uses node data that's not available in this context. Use the same Chef::Platform.windows? check we use above. Without this you get the following error: [2017-10-02T21:40:42+00:00] DEBUG: Re-raising exception: NameError - remote_file[c:/foo/bar] (foo::default line 14) had an error: NameError: undefined local variable or method `node' for #<Chef::Provider::RemoteFile::NetworkFile:0x00000000064c0148> Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/mixin/user_context.rb2
-rw-r--r--spec/unit/mixin/user_context_spec.rb3
-rw-r--r--spec/unit/provider/remote_file/network_file_spec.rb2
3 files changed, 3 insertions, 4 deletions
diff --git a/lib/chef/mixin/user_context.rb b/lib/chef/mixin/user_context.rb
index 40a72912a3..526d6b0f3f 100644
--- a/lib/chef/mixin/user_context.rb
+++ b/lib/chef/mixin/user_context.rb
@@ -23,7 +23,7 @@ class Chef
module UserContext
def with_user_context(user, password, domain = nil, &block)
- if node["platform_family"] != "windows"
+ unless Chef::Platform.windows?
raise Exceptions::UnsupportedPlatform, "User context impersonation is supported only on the Windows platform"
end
diff --git a/spec/unit/mixin/user_context_spec.rb b/spec/unit/mixin/user_context_spec.rb
index f2119b6dbc..3dadf6a2c3 100644
--- a/spec/unit/mixin/user_context_spec.rb
+++ b/spec/unit/mixin/user_context_spec.rb
@@ -41,7 +41,6 @@ describe "a class that mixes in user_context" do
before do
allow(::Chef::Platform).to receive(:windows?).and_return(true)
allow(::Chef::Util::Windows::LogonSession).to receive(:new).and_return(logon_session)
- allow(instance_with_user_context).to receive(:node).and_return({ "platform_family" => "windows" })
end
let(:logon_session) { instance_double("::Chef::Util::Windows::LogonSession", :set_user_context => nil, :open => nil, :close => nil) }
@@ -99,7 +98,7 @@ describe "a class that mixes in user_context" do
context "when not running on Windows" do
before do
- allow(instance_with_user_context).to receive(:node).and_return({ "platform_family" => "ubuntu" })
+ allow(::Chef::Platform).to receive(:windows?).and_return(false)
end
it "raises a ::Chef::Exceptions::UnsupportedPlatform exception" do
diff --git a/spec/unit/provider/remote_file/network_file_spec.rb b/spec/unit/provider/remote_file/network_file_spec.rb
index 621d2769a4..ecb326fc64 100644
--- a/spec/unit/provider/remote_file/network_file_spec.rb
+++ b/spec/unit/provider/remote_file/network_file_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Provider::RemoteFile::NetworkFile do
let(:source_file) { double("::File", :read => nil) }
before do
- allow(fetcher).to receive(:node).and_return({ "platform_family" => "windows" })
+ allow(Chef::Platform).to receive(:windows?).and_return(true)
end
it "stages the local file to a temporary file" do