Class: DigestAuthServlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/mechanize/test_case/digest_auth_servlet.rb

Constant Summary collapse

@@authenticator =
WEBrick::HTTPAuth::DigestAuth.new({
  :UserDB => htpd,
  :Realm  => 'Blah',
  :Algorithm => 'MD5',
  :Logger => Logger.new(nil)
})

Instance Method Summary collapse

Instance Method Details

#do_GET(req, res) ⇒ Object Also known as: do_POST



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/mechanize/test_case/digest_auth_servlet.rb', line 19

def do_GET req, res
  def req.request_time; Time.now; end
  def req.request_uri; '/digest_auth'; end
  def req.request_method; 'GET'; end

  begin
    @@authenticator.authenticate req, res
    res.body = 'You are authenticated'
  rescue WEBrick::HTTPStatus::Unauthorized
    res.status = 401
  end
end