Browse Source

added tests for address family mismatches (give an ipv4 address with -6, etc)

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac221b@2468 e5f2f494-b856-4b98-b285-d166d9295462
JINMEI Tatuya 15 years ago
parent
commit
76f4788d5c
2 changed files with 14 additions and 4 deletions
  1. 6 4
      src/bin/auth/asio_link.cc
  2. 8 0
      src/bin/auth/tests/asio_link_unittest.cc

+ 6 - 4
src/bin/auth/asio_link.cc

@@ -524,13 +524,15 @@ IOServiceImpl::IOServiceImpl(AuthSrv* auth_server, const char* const address,
         }
 
         if (addr.is_v6() && !use_ipv6) {
-            isc_throw(FatalError,
-                      "[b10-auth] Error: -4 conflicts with " << addr);
+            isc_throw(IOError,
+                      "IPv6 address is specified while IPv6 is disabled: "
+                      << addr);
         }
 
         if (addr.is_v4() && !use_ipv4) {
-            isc_throw(FatalError,
-                      "[b10-auth] Error: -6 conflicts with " << addr);
+            isc_throw(IOError,
+                      "IPv4 address is specified while IPv4 is disabled: "
+                      << addr);
         }
 
         if (addr.is_v4()) {

+ 8 - 0
src/bin/auth/tests/asio_link_unittest.cc

@@ -105,6 +105,14 @@ TEST(IOServiceTest, badAddress) {
                  IOError);
 }
 
+TEST(IOServiceTest, addressFamilyMismatch) {
+    IOService(NULL, "192.0.2.1", *TEST_PORT, false, true);
+    EXPECT_THROW(IOService(NULL, "192.0.2.1", *TEST_PORT, false, true),
+                 IOError);
+    EXPECT_THROW(IOService(NULL, "2001:db8::1", *TEST_PORT, true, false),
+                 IOError);
+}
+
 struct addrinfo*
 resolveAddress(const int family, const int sock_type, const int protocol) {
     const char* const addr = (family == AF_INET6) ?