From 03da9016a06640c2b5016f6041e70f1822f4fb77 Mon Sep 17 00:00:00 2001 From: Larry Kyrala Date: Thu, 27 Jul 2017 16:25:15 -0400 Subject: [PATCH] only require ntlm if ntlm auth was requested. fixes savonrb/savon#819 --- lib/httpi/adapter/net_http.rb | 2 +- spec/httpi/adapter/net_http_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/httpi/adapter/net_http.rb b/lib/httpi/adapter/net_http.rb index 6390178..27e9c73 100644 --- a/lib/httpi/adapter/net_http.rb +++ b/lib/httpi/adapter/net_http.rb @@ -18,7 +18,7 @@ class NetHTTP < Base register :net_http, :deps => %w(net/https) def initialize(request) - check_net_ntlm_version! + check_net_ntlm_version! if request.auth.ntlm? @request = request @client = create_client end diff --git a/spec/httpi/adapter/net_http_spec.rb b/spec/httpi/adapter/net_http_spec.rb index 0158fef..f8776b1 100644 --- a/spec/httpi/adapter/net_http_spec.rb +++ b/spec/httpi/adapter/net_http_spec.rb @@ -132,6 +132,15 @@ to raise_error(HTTPI::NotSupportedError, /Net::NTLM is not available/) end + it 'does not require ntlm when ntlm authenication is not requested' do + HTTPI::Adapter::NetHTTP.any_instance.stubs(:check_net_ntlm_version!).raises(RuntimeError) + request = HTTPI::Request.new(@server.url) + + expect(request.auth.ntlm?).to be false + + expect { HTTPI.get(request, adapter) }.not_to raise_error + end + it "does not crash when authenticate header is missing (on second request)" do request = HTTPI::Request.new(@server.url + 'ntlm-auth') request.auth.ntlm("tester", "vReqSoafRe5O")