]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2833] throw CacheConfigError for duplicate zone names.
authorJINMEI Tatuya <jinmei@isc.org>
Tue, 2 Apr 2013 03:44:33 +0000 (20:44 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Tue, 2 Apr 2013 03:45:28 +0000 (20:45 -0700)
this is not a program error, so CacheConfigError should be more appropriate.

src/lib/datasrc/cache_config.cc
src/lib/datasrc/cache_config.h
src/lib/datasrc/tests/cache_config_unittest.cc

index c2a13edb614daef5fe5db30dcff1e164d629f16c..9cfe3b1a7c3986876431b2a5ed38410f16671113 100644 (file)
@@ -101,7 +101,7 @@ CacheConfig::CacheConfig(const std::string& datasrc_type,
             const dns::Name zone_name(zones->get(i)->stringValue());
             if (!zone_config_.insert(Zones::value_type(zone_name,
                                                        "")).second) {
-                isc_throw(InvalidParameter, "Duplicate cache zone: " <<
+                isc_throw(CacheConfigError, "Duplicate cache zone: " <<
                           zone_name);
             }
         }
index 02fc2118dce2ad2b41d5a1ebe4e6c912dc35b106..eb63a03d173b6e70923ab9ae6cba12671fbb1b9b 100644 (file)
@@ -91,6 +91,8 @@ public:
     ///   - Each string value of cache-zones entries must be a valid textual
     ///     representation of a domain name.  Otherwise corresponding
     ///     exception from the dns::Name class will be thrown.
+    ///   - Names in the list must not have duplicates;
+    ///     throws CacheConfigError otherwise.
     ///
     /// For other data source types than "MasterFiles", cache can be disabled.
     /// In this case cache-zones configuration item is simply ignored, even
@@ -105,11 +107,11 @@ public:
     /// item if defined; otherwise it defaults to "local".
     ///
     /// \throw InvalidParameter Program error at the caller side rather than
-    /// in the configuration.
+    /// in the configuration (see above)
     /// \throw CacheConfigError There is a semantics error in the given
-    /// configuration.
+    /// configuration (see above)
     /// \throw data::TypeError There is a syntax error in the given
-    /// configuration.
+    /// configuration (see above)
     ///
     /// \param datasrc_type Type of data source. This must be the "type"
     /// value of the data source configuration.
index b0fe4ac8b5f2720ce06c5c2946a4f9a7a2869a0f..a9baec9f6f8b1d637c8fd66ead3eae08978c4769 100644 (file)
@@ -204,13 +204,13 @@ TEST_F(CacheConfigTest, badConstructWithMock) {
     EXPECT_THROW(CacheConfig("mock", &mock_client_, *bad_config, true),
                  isc::dns::EmptyLabel);
 
-    // duplicate zone name
+    // duplicate zone name (note that comparison is case insensitive)
     const ConstElementPtr dup_config(Element::fromJSON(
                                          "{\"cache-enable\": true,"
                                          " \"cache-zones\": "
-                                         " [\"example\", \"example\"]}"));
+                                         " [\"example\", \"EXAMPLE\"]}"));
     EXPECT_THROW(CacheConfig("mock", &mock_client_, *dup_config, true),
-                 isc::InvalidParameter);
+                 CacheConfigError);
 
     // datasrc is null
     EXPECT_THROW(CacheConfig("mock", 0, *mock_config_, true),