1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00

Added a digest_auth class method to HTTParty to provide the same default_option functionality as basic_auth

This commit is contained in:
Brian Artiaco 2010-02-09 18:50:53 -08:00 committed by Sandro Turriate
parent fd19af35ac
commit 14fce706a6
2 changed files with 18 additions and 0 deletions

View file

@ -74,6 +74,17 @@ module HTTParty
default_options[:basic_auth] = {:username => u, :password => p} default_options[:basic_auth] = {:username => u, :password => p}
end end
# Allows setting digest authentication username and password.
#
# class Foo
# include HTTParty
# digest_auth 'username', 'password'
# end
def digest_auth(u, p)
default_options[:digest_auth] = {:username => u, :password => p}
end
# Allows setting default parameters to be appended to each request. # Allows setting default parameters to be appended to each request.
# Great for api keys and such. # Great for api keys and such.
# #

View file

@ -222,6 +222,13 @@ describe HTTParty do
end end
end end
describe "digest http authentication" do
it "should work" do
@klass.digest_auth 'foobar', 'secret'
@klass.default_options[:digest_auth].should == {:username => 'foobar', :password => 'secret'}
end
end
describe "parser" do describe "parser" do
let(:parser) do let(:parser) do
Proc.new{ |data, format| CustomParser.parse(data) } Proc.new{ |data, format| CustomParser.parse(data) }