Sha256: d300b2f51c3b8b0ddb69d63fc959e98de37980a7ac422d0d7eebad3cef5a707d

Contents?: true

Size: 1023 Bytes

Versions: 6

Compression:

Stored size: 1023 Bytes

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_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_ntlm
    challenge = @AC.new 'Negotiate, NTLM'

    assert_nil challenge.realm_name
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mechanize-2.7.4 test/test_mechanize_http_auth_challenge.rb
mechanize-2.7.3 test/test_mechanize_http_auth_challenge.rb
mechanize-2.7.2 test/test_mechanize_http_auth_challenge.rb
mechanize-2.7.1 test/test_mechanize_http_auth_challenge.rb
mechanize-2.7.0 test/test_mechanize_http_auth_challenge.rb
mechanize-2.6.0 test/test_mechanize_http_auth_challenge.rb