Sha256: 7fc0619a4eb0b542dd28ae24ee2e705725b91a71994211f49ee36ca37bb2cde7

Contents?: true

Size: 757 Bytes

Versions: 6

Compression:

Stored size: 757 Bytes

Contents

require File.dirname(__FILE__) + "/helper"

class BasicAuthTest < Test::Unit::TestCase
  def setup
    @agent = WWW::Mechanize.new
  end

  def test_auth_success
    @agent.basic_auth('user', 'pass')
    page = @agent.get("http://localhost/basic_auth")
    assert_equal('You are authenticated', page.body)
  end

  def test_auth_bad_user_pass
    @agent.basic_auth('aaron', 'aaron')
    begin
      page = @agent.get("http://localhost/basic_auth")
    rescue WWW::Mechanize::ResponseCodeError => e
      assert_equal("401", e.response_code)
    end
  end

  def test_auth_failure
    begin
      page = @agent.get("http://localhost/basic_auth")
    rescue WWW::Mechanize::ResponseCodeError => e
      assert_equal("401", e.response_code)
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mechanize-0.7.4 test/tc_authenticate.rb
mechanize-0.7.0 test/tc_authenticate.rb
mechanize-0.7.1 test/tc_authenticate.rb
mechanize-0.7.2 test/tc_authenticate.rb
mechanize-0.7.3 test/tc_authenticate.rb
mechanize-0.7.5 test/tc_authenticate.rb