Skip to content

Commit

Permalink
Added test_plain_respects_bufsize() that tests that requested bufsize…
Browse files Browse the repository at this point in the history
… is handled correctly with send_plain_message.
  • Loading branch information
Keith Bennett committed Dec 10, 2014
1 parent d0333e0 commit 56a1fb1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
end
end

require 'minitest'
require 'minitest/autorun'
require 'dnsruby'
32 changes: 32 additions & 0 deletions test/tc_rr-opt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,38 @@

include Dnsruby
class TestRrOpt < Minitest::Test



# This test illustrates that when an OPT record specifying a maximum
# UDP size is added to a query, the server will respect that setting
# and limit the response's size to <= that maximum.
# This works only with send_plain_message, not send_message, query, etc.
def test_plain_respects_bufsize

resolver = Resolver.new('a.gtld-servers.net')

run_test = ->(bufsize) do

create_test_query = ->(bufsize) do
message = Message.new('com', Types.ANY, Classes.IN)
message.add_additional(RR::OPT.new(bufsize))
message
end

query = create_test_query.(bufsize)
response, _error = resolver.send_plain_message(query)
# puts "\nBufsize is #{bufsize}, binary message size is #{response.encode.size}"
assert_equal(true, response.header.tc)
assert(response.encode.size <= bufsize)
end

run_test.(512)
run_test.(612)
run_test.(4096)
end


def test_rropt
size=2048;
ednsflags=0x9e22;
Expand Down

0 comments on commit 56a1fb1

Please sign in to comment.