diff options
-rw-r--r-- | lib/chef/mixin/user_context.rb | 2 | ||||
-rw-r--r-- | spec/unit/mixin/user_context_spec.rb | 3 | ||||
-rw-r--r-- | spec/unit/provider/remote_file/network_file_spec.rb | 2 |
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 |