Thursday, November 18, 2010

Digest Authentication

hi,

You all know about basic authentication method use in most places here I share something about digest authentication method.

Below code is for digest authentication ask using pop-up when try to enter site.

Installation:

If you already have installed ruby gem then you have to now install one more gem for
digest authentication gem.

gem install net-http-digest_auth

check http://rubygems.org/gems/net-http-digest_auth for dependency for this gem.

Example code :

require 'rubygems'
require 'uri'
require 'net/http'
require 'net/http/digest_auth'


def authentication_check

#change your site which have digest authentication, this url use just for example.
uri = URI.parse 'http://api.del.icio.us/v1/tags/get'
uri.user = 'username'
uri.password = 'password'

digest_auth = Net::HTTP::DigestAuth.new
auth = digest_auth.auth_header uri, res['www-authenticate'], 'GET'
req = Net::HTTP::Get.new uri.request_uri
req.add_field 'Authorization', auth
res = h.request req
#return res.code # for get http return code
return res.message # for http message

end


Thanks,
Priyank Shah

Tuesday, November 9, 2010

Firewatir Jssh error : Unable to connect to machine : 127.0.0.1 on port 9997

Hello,


I get following error when i work with firewatir for firefox on Centos - 64 bit ,

/usr/local/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/firefox.rb:158:in `set_defaults': Unable to connect to machine : 127.0.0.1 on port 9997. Make sure that JSSh is properly installed and Firefox is running with '-jssh' option (Watir::Exception::UnableToStartJSShException)
from /usr/local/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/firefox.rb:50:in `initialize'
from /home/test.rb:39:in `new'
from /home/test.rb:39




firewatir require Jssh extension for working, but even installing Jssh extension with firefox but I continue getting error.

I have done many googling and try to change in firefox.rb as i found some where but my problem not solved.

Not solution but i found suggestion for me and you also :

I don't know in which cases this problem occur but I found that JSSH not support with 64 bit Os. so I then try with centos - 32 bit and my error solved and firefox browser works fine.


So if any one know about how it work with 64 bit they can also post there solutions here.

Thanks,
Priyank Shah