Skip to content

Commit

Permalink
Merge pull request #123 from PChambino/ntlm
Browse files Browse the repository at this point in the history
Don't warn about missing rubyntlm gem if it is optional
  • Loading branch information
tjarratt committed Jul 9, 2014
2 parents b1cc4f1 + 451b048 commit 1d60751
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions lib/httpi/adapter/net_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
unless Net::NTLM::VERSION::STRING >= '0.3.2'
raise ArgumentError, 'Invalid version of rubyntlm. Please use v0.3.2+.'
end
rescue LoadError => e
HTTPI.logger.debug('Net::NTLM is not available. Install via gem install rubyntlm.')
rescue LoadError
end

module HTTPI
Expand Down Expand Up @@ -86,7 +85,7 @@ def setup

def negotiate_ntlm_auth(http, &requester)
unless Net.const_defined?(:NTLM)
HTTPI.logger.fatal('Cannot negotiate ntlm auth if net/ntlm is not present. Perhaps the net/ntlm gem is not installed?')
raise NotSupportedError, 'Net::NTLM is not available. Install via gem install rubyntlm.'
end

# first figure out if we should use NTLM or Negotiate
Expand Down
7 changes: 3 additions & 4 deletions spec/httpi/adapter/net_http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,14 @@
expect(response.body).to eq("ntlm-auth")
end

it 'fatal logs when net/ntlm is not available, but ntlm authentication was requested' do
it 'does not support ntlm authentication when Net::NTLM is not available' do
Net.expects(:const_defined?).with(:NTLM).returns false

request = HTTPI::Request.new(@server.url + 'ntlm-auth')
request.auth.ntlm("testing", "failures")
HTTPI.logger.expects(:fatal)

response = HTTPI.get(request, adapter)
expect(response.body).to eq("ntlm-auth")
expect { HTTPI.get(request, adapter) }.
to raise_error(HTTPI::NotSupportedError, /Net::NTLM is not available/)
end
end

Expand Down

0 comments on commit 1d60751

Please sign in to comment.