Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing Net::NTLM::EncodeUtil and using Net::NTLM insteand #103

Closed
wants to merge 2 commits into from

Conversation

tandrieu
Copy link

Net::NTLM::EncodeUtil is not defined in the httpi gem.
This commit fixes a crash when attempting to make NTLM authentication.

@coveralls
Copy link

Coverage Status

Coverage increased (+20.42%) when pulling de6a843 on tandrieu:master into 6ca1151 on savonrb:master.

@rogerleite
Copy link
Member

Hi @tandrieu! Thanks for your pull request.
To merge your PR, it would be great to simulate this crash by spec.
@tandrieu, you can write this spec?

@rubiii Do you know something about this bug?

@rogerleite
Copy link
Member

@tandrieu Travis is reporting some errors on spec. https://travis-ci.org/savonrb/httpi/jobs/13916124

 1) HTTPI::Adapter::NetHTTP http requests supports ntlm authentication
     Failure/Error: response = HTTPI.get(request, adapter)
     NoMethodError:
       undefined method `encode_utf16le' for Net::NTLM:Module
     # ./lib/httpi/adapter/net_http.rb:120:in `negotiate_ntlm_auth'
     # ./lib/httpi/adapter/net_http.rb:67:in `block in do_request'
     # ./lib/httpi/adapter/net_http.rb:66:in `do_request'
     # ./lib/httpi/adapter/net_http.rb:33:in `request'
     # ./lib/httpi.rb:140:in `request'
     # ./lib/httpi.rb:106:in `get'
     # ./spec/httpi/adapter/net_http_spec.rb:75:in `block (3 levels) in <top (required)>'

Can be some "bundler" problem?

Thanks.

@tandrieu
Copy link
Author

@rogerleite Here is the issue i got when trying to authenticate

NameError: uninitialized constant Net::NTLM::EncodeUtil
    from /Users/totibus/.rvm/gems/ruby-2.0.0-p247/gems/httpi-2.1.0/lib/httpi/adapter/net_http.rb:113:in `negotiate_ntlm_auth'
    from /Users/totibus/.rvm/gems/ruby-2.0.0-p247/gems/httpi-2.1.0/lib/httpi/adapter/net_http.rb:67:in `block in do_request'
    from /Users/totibus/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:852:in `start'
    from /Users/totibus/.rvm/gems/ruby-2.0.0-p247/gems/httpi-2.1.0/lib/httpi/adapter/net_http.rb:66:in `do_request'
    from /Users/totibus/.rvm/gems/ruby-2.0.0-p247/gems/httpi-2.1.0/lib/httpi/adapter/net_http.rb:33:in `request'
    from /Users/totibus/.rvm/gems/ruby-2.0.0-p247/gems/httpi-2.1.0/lib/httpi.rb:140:in `request'
    from /Users/totibus/.rvm/gems/ruby-2.0.0-p247/gems/httpi-2.1.0/lib/httpi.rb:106:in `get'
    from (irb):10
    from /Users/totibus/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
    from /Users/totibus/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
    from /Users/totibus/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

I'm investigating the errors.

@rogerleite
Copy link
Member

Net::NTLM::EncodUtil belongs to https://github.com/WinRb/rubyntlm rubygem. This last version seems to be a very refactored version. What version are you running?
A bundle list on your httpi folder can help. Are you on linux or mac?

Exceptions like NameError, feels like the rubyntlm isn't on your path, maybe can be something with ruby 2. In this weird case, i suggest you to test with 1.9.3 just to discard this possibility (if you can).

Good luck!

@tandrieu
Copy link
Author

 cat Gemfile.lock| grep rubyntlm
      rubyntlm (~> 0.3.2)
    rubyntlm (0.3.4)

I'm on a mac.
I'm thinking that this issue is only related to ruby 2, it seems to be fine on 1.9.3. I continue checking...

@tandrieu
Copy link
Author

bundle list
Gems included by the bundle:
  * addressable (2.3.5)
  * bundler (1.3.5)
  * cookiejar (0.3.0)
  * coveralls (0.7.0)
  * curb (0.8.5)
  * diff-lcs (1.2.5)
  * docile (1.1.0)
  * em-http-request (1.1.1)
  * em-socksify (0.3.0)
  * em-synchrony (1.0.3)
  * eventmachine (1.0.3)
  * excon (0.21.0)
  * http_parser.rb (0.6.0.beta.2)
  * httpclient (2.3.4.1)
  * httpi (2.1.0 de6a843)
  * lockfile (2.1.0)
  * metaclass (0.0.1)
  * mime-types (2.0)
  * mocha (0.14.0)
  * multi_json (1.8.2)
  * net-http-persistent (2.9)
  * puma (2.3.2)
  * rack (1.5.2)
  * rake (10.1.0)
  * rest-client (1.6.7)
  * rspec (2.14.1)
  * rspec-core (2.14.7)
  * rspec-expectations (2.14.4)
  * rspec-mocks (2.14.4)
  * rubyntlm (0.3.4)
  * simplecov (0.8.1)
  * simplecov-html (0.8.0)
  * term-ansicolor (1.2.2)
  * thor (0.18.1)
  * tins (0.13.1)

@coveralls
Copy link

Coverage Status

Coverage increased (+22.82%) when pulling 80aadfd on tandrieu:master into 6ca1151 on savonrb:master.

@tandrieu
Copy link
Author

Finaly found the solution.

There was Mechanize gem in the stack wich require ntlm-http gem.
It causes a conflict since httpi gem calls the ntlm-http methods instead of the rubyntlm methods.
After removing Mechanize and ntlm-http gem, everything is OK.

@rogerleite
Copy link
Member

This kind of errors are hard to find, great job!
Can i close this PR?

@tandrieu
Copy link
Author

Thanks ;)
Sure you can close it !

@rogerleite rogerleite closed this Nov 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants