Skip to content

Commit

Permalink
only require ntlm if ntlm auth was requested.
Browse files Browse the repository at this point in the history
  • Loading branch information
coldnebo committed Jul 27, 2017
1 parent 2c0a725 commit 03da901
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/httpi/adapter/net_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/httpi/adapter/net_http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 03da901

Please sign in to comment.