Sha256: 7b4f60f8011744ff131471979e78ff1feb04d2d142b10fb4167bdb3421802382

Contents?: true

Size: 1.29 KB

Versions: 21

Compression:

Stored size: 1.29 KB

Contents

require 'test_helper'

class ServerAdaptersPirTest < Test::Unit::TestCase

  def setup
    @definition = [:tld, ".foo", "whois.foo", {}]
    @klass  = Whois::Server::Adapters::Pir
    @server = @klass.new(*@definition)
  end

  def test_query
    response = "No match for DOMAIN.FOO."
    expected = response
    @server.expects(:ask_the_socket).with("FULL domain.foo", "whois.publicinterestregistry.net", 43).returns(response)
    assert_equal expected,
                 @server.query("domain.foo").to_s
    assert_equal [Whois::Answer::Part.new(response, "whois.publicinterestregistry.net")],
                 @server.buffer
  end

  def test_query_with_referral
    referral = File.read(File.dirname(__FILE__) + "/../../testcases/referrals/pir.org.txt")
    response = "Match for DOMAIN.FOO."
    expected = referral + "\n" + response
    @server.expects(:ask_the_socket).with("FULL domain.foo", "whois.publicinterestregistry.net", 43).returns(referral)
    @server.expects(:ask_the_socket).with("domain.foo", "whois.iana.org", 43).returns(response)
    assert_equal expected,
                 @server.query("domain.foo").to_s
    assert_equal [Whois::Answer::Part.new(referral, "whois.publicinterestregistry.net"), Whois::Answer::Part.new(response, "whois.iana.org")], 
                 @server.buffer
  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
whois-1.1.4 test/server/adapters/pir_test.rb
whois-1.1.3 test/server/adapters/pir_test.rb
whois-1.1.2 test/server/adapters/pir_test.rb
whois-1.1.1 test/server/adapters/pir_test.rb
whois-1.1.0 test/server/adapters/pir_test.rb
whois-1.0.12 test/server/adapters/pir_test.rb
whois-1.0.11 test/server/adapters/pir_test.rb
whois-1.0.10 test/server/adapters/pir_test.rb
whois-1.0.9 test/server/adapters/pir_test.rb
whois-1.0.8 test/server/adapters/pir_test.rb
whois-1.0.7 test/server/adapters/pir_test.rb
whois-1.0.6 test/server/adapters/pir_test.rb
whois-1.0.5 test/server/adapters/pir_test.rb
whois-1.0.4 test/server/adapters/pir_test.rb
whois-1.0.3 test/server/adapters/pir_test.rb
whois-1.0.2 test/server/adapters/pir_test.rb
whois-1.0.1 test/server/adapters/pir_test.rb
whois-1.0.0 test/server/adapters/pir_test.rb
whois-0.9.0 test/server/adapters/pir_test.rb
whois-0.8.1 test/server/adapters/pir_test.rb