From f33cf9b527cb0c0665b0f84133b3b0b57760dc7a Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Fri, 17 Oct 2014 06:40:26 +0000 Subject: [PATCH] Added changes to remove check for local domain for winrm-s use --- lib/chef/knife/winrm.rb | 5 ++--- spec/unit/knife/winrm_spec.rb | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/chef/knife/winrm.rb b/lib/chef/knife/winrm.rb index 4921c185..94b7abae 100644 --- a/lib/chef/knife/winrm.rb +++ b/lib/chef/knife/winrm.rb @@ -142,8 +142,7 @@ def session_from_list(list) session_opts[:operation_timeout] = 1800 # 30 min OperationTimeout for long bootstraps fix for KNIFE_WINDOWS-8 ## If you have a \\ in your name you need to use NTLM domain authentication - username_components = session_opts[:user].split("\\") - username_contains_domain = username_components.length.eql?(2) + username_contains_domain = session_opts[:user].split("\\").length.eql?(2) if username_contains_domain # We cannot use basic_auth for domain authentication @@ -158,7 +157,7 @@ def session_from_list(list) else session_opts[:transport] = (Chef::Config[:knife][:winrm_transport] || config[:winrm_transport]).to_sym - if Chef::Platform.windows? && session_opts[:transport] == :plaintext && username_contains_domain && username_components[0] != "." + if Chef::Platform.windows? && session_opts[:transport] == :plaintext && username_contains_domain ui.warn("Switching to Negotiate authentication, Basic does not support Domain Authentication") # windows - force only encrypted communication require 'winrm-s' diff --git a/spec/unit/knife/winrm_spec.rb b/spec/unit/knife/winrm_spec.rb index 74313488..c4e1c4fa 100644 --- a/spec/unit/knife/winrm_spec.rb +++ b/spec/unit/knife/winrm_spec.rb @@ -199,7 +199,7 @@ it "should skip winrm monkey patched for windows" do @winrm.config[:winrm_user] = ".\\testuser" allow(Chef::Platform).to receive(:windows?).and_return(true) - expect(@winrm).to_not receive(:require).with('winrm-s') + expect(@winrm).to receive(:require).with('winrm-s') exit_code = @winrm.run end