summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/custodian/protocoltest/dns.rb1
-rwxr-xr-xt/test-dns-types61
2 files changed, 62 insertions, 0 deletions
diff --git a/lib/custodian/protocoltest/dns.rb b/lib/custodian/protocoltest/dns.rb
index 65dfa2b..eb76f77 100644
--- a/lib/custodian/protocoltest/dns.rb
+++ b/lib/custodian/protocoltest/dns.rb
@@ -60,6 +60,7 @@ module Custodian
raise ArgumentError, "Missing host to resolve" unless( @resolve_name )
raise ArgumentError, "Missing type of record to lookup" unless( @resolve_type )
raise ArgumentError, "Missing expected results" unless( @resolve_expected )
+ raise ArgumentError, "Uknown record type: #{@resolve_type}" unless( @resolve_type =~ /^(A|NS|MX|AAAA)$/ )
#
# The host to query against
diff --git a/t/test-dns-types b/t/test-dns-types
new file mode 100755
index 0000000..dba7a3c
--- /dev/null
+++ b/t/test-dns-types
@@ -0,0 +1,61 @@
+#!/usr/bin/ruby -Ilib/ -I../lib/
+
+
+require 'test/unit'
+
+require 'custodian/protocoltests'
+
+
+
+#
+# The DNS test is a complex one.
+#
+class TestDNSTypes < Test::Unit::TestCase
+
+ #
+ # Create the test suite environment: NOP.
+ #
+ def setup
+ end
+
+ #
+ # Destroy the test suite environment: NOP.
+ #
+ def teardown
+ end
+
+
+ #
+ # Test the known-record types: A, NS, MX, AAAA
+ #
+ def test_known_types
+
+ assert_nothing_raised do
+ test = Custodian::TestFactory.create( "a.ns.bytemark.co.uk must run dns for bytemark.co.uk resolving NS as 'foo'." )
+ test = Custodian::TestFactory.create( "a.ns.bytemark.co.uk must run dns for bytemark.co.uk resolving A as 'foo'." )
+ test = Custodian::TestFactory.create( "a.ns.bytemark.co.uk must run dns for bytemark.co.uk resolving MX as 'foo'." )
+ test = Custodian::TestFactory.create( "a.ns.bytemark.co.uk must run dns for bytemark.co.uk resolving AAAA as 'foo'." )
+ end
+
+ end
+
+
+
+ #
+ # Test that using random types fails.
+ #
+ def test_unknown_types
+
+ #
+ # Each of these will fail
+ #
+ %w( a ns www example fdskfjdlfsj `` ).each do |res|
+ assert_raise ArgumentError do
+ Custodian::TestFactory.create( "a.ns.bytemark.co.uk must run dns for bytemark.co.uk resolving #{res} as 'foo'." )
+ end
+ end
+ end
+
+
+end
+