summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-12-11 10:41:56 +0000
committerSteve Kemp <steve@steve.org.uk>2012-12-11 10:41:56 +0000
commit95042aa9fd7387a882150af2c50a5cd2072dff93 (patch)
treecda53208b9c33e621a853e1e78822ecce4e3db8f
parent51b6f6926eaefb91b479e22c33e4579b35cfc203 (diff)
Use and require an exact match in DNS results.
-rw-r--r--lib/custodian/protocoltest/dns.rb37
1 files changed, 23 insertions, 14 deletions
diff --git a/lib/custodian/protocoltest/dns.rb b/lib/custodian/protocoltest/dns.rb
index eb76f77..7547c04 100644
--- a/lib/custodian/protocoltest/dns.rb
+++ b/lib/custodian/protocoltest/dns.rb
@@ -100,16 +100,12 @@ module Custodian
# OK we have an array of results. If every one of the expected
# results is contained in those results returned then we're good.
#
- @resolve_expected.split( /;/ ).each do |required|
- if ( ! results.include?( required ) )
- @error = "The expected result #{required} was not found in the results: #{results.join(",")}"
- return false
- end
+ expected = 0
+ if ( results != @resolve_expected )
+ @error = "The expected result '#{resolve_expected}' didn't match the returned results '#{results}'"
+ return false
end
- #
- # OK we've succeeded.
- #
true
end
@@ -130,16 +126,16 @@ module Custodian
case ltype
when /^A$/ then
- dns.getresources(name, Resolv::DNS::Resource::IN::A).map{ |r| results.push r.address.to_s() }
+ dns.getresources(name, Resolv::DNS::Resource::IN::A).map{ |r| results.push(r.address.to_s()) }
when /^AAAA$/ then
- dns.getresources(name, Resolv::DNS::Resource::IN::AAAA).map{ |r| results.push r.address.to_s() }
+ dns.getresources(name, Resolv::DNS::Resource::IN::AAAA).map{ |r| results.push( r.address.to_s()) }
when /^NS$/ then
- dns.getresources(name, Resolv::DNS::Resource::IN::NS).map{ |r| results.push Resolv.getaddresses(r.name.to_s()) }
+ dns.getresources(name, Resolv::DNS::Resource::IN::NS).map{ |r| results.push( Resolv.getaddresses(r.name.to_s())) }
when /^MX$/ then
- dns.getresources(name, Resolv::DNS::Resource::IN::MX).map{ |r| results.push Resolv.getaddresses(r.exchange.to_s()) }
+ dns.getresources(name, Resolv::DNS::Resource::IN::MX).map{ |r| results.push( Resolv.getaddresses(r.exchange.to_s())) }
else
@error = "Unknown record type to resolve: '#{ltype}'"
return nil
@@ -154,8 +150,21 @@ module Custodian
@error = "Timed-out connecting #{e}"
return nil
end
- results.flatten!
- results
+
+ #
+ # Flatten via a hash.
+ #
+ h = Hash.new()
+ results.sort.each do |key|
+ if ( key.kind_of? Array )
+ key.each do |n|
+ h[n]=1
+ end
+ else
+ h[key]=1
+ end
+ end
+ h.keys.sort!.join( "," )
end