Sha256: a8db4011df2691efc78eb014ca3e7d7317033df24e5f903bda7f2840cf79e924

Contents?: true

Size: 1.35 KB

Versions: 17

Compression:

Stored size: 1.35 KB

Contents

require 'mechanize/test_case'

class TestMechanizeHttpAuthChallenge < Mechanize::TestCase

  def setup
    super

    @uri = URI 'http://example/'
    @AR = Mechanize::HTTP::AuthRealm
    @AC = Mechanize::HTTP::AuthChallenge
    @challenge = @AC.new 'Digest', { 'realm' => 'r' }, 'Digest realm=r'
  end

  def test_realm_basic
    @challenge.scheme = 'Basic'

    expected = @AR.new 'Basic', @uri, 'r'

    assert_equal expected, @challenge.realm(@uri + '/foo')
  end

  def test_realm_digest
    expected = @AR.new 'Digest', @uri, 'r'

    assert_equal expected, @challenge.realm(@uri + '/foo')
  end

  def test_realm_digest_case
    challenge = @AC.new 'Digest', { 'realm' => 'R' }, 'Digest realm=R'

    expected = @AR.new 'Digest', @uri, 'R'

    assert_equal expected, challenge.realm(@uri + '/foo')
  end

  def test_realm_unknown
    @challenge.scheme = 'Unknown'

    e = assert_raises Mechanize::Error do
      @challenge.realm(@uri + '/foo')
    end

    assert_equal 'unknown HTTP authentication scheme Unknown', e.message
  end

  def test_realm_name
    assert_equal 'r', @challenge.realm_name
  end

  def test_realm_name_case
    challenge = @AC.new 'Digest', { 'realm' => 'R' }, 'Digest realm=R'

    assert_equal 'R', challenge.realm_name
  end

  def test_realm_name_ntlm
    challenge = @AC.new 'Negotiate, NTLM'

    assert_nil challenge.realm_name
  end

end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
mechanize-2.10.0 test/test_mechanize_http_auth_challenge.rb
mechanize-2.9.2 test/test_mechanize_http_auth_challenge.rb
mechanize-2.9.1 test/test_mechanize_http_auth_challenge.rb
mechanize-2.9.0 test/test_mechanize_http_auth_challenge.rb
mechanize-2.8.5 test/test_mechanize_http_auth_challenge.rb
mechanize-2.8.4 test/test_mechanize_http_auth_challenge.rb
mechanize-2.8.3 test/test_mechanize_http_auth_challenge.rb
mechanize-2.8.2 test/test_mechanize_http_auth_challenge.rb
mechanize-2.8.1 test/test_mechanize_http_auth_challenge.rb
mechanize-2.8.0 test/test_mechanize_http_auth_challenge.rb
mechanize-2.7.7 test/test_mechanize_http_auth_challenge.rb
husc-0.2.1 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_http_auth_challenge.rb
husc-0.2.0 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_http_auth_challenge.rb
husc-0.1.1 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_http_auth_challenge.rb
husc-0.1.0 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_http_auth_challenge.rb
mechanize-2.7.6 test/test_mechanize_http_auth_challenge.rb
mechanize-2.7.5 test/test_mechanize_http_auth_challenge.rb