BIND 10 trac2832, updated. 946b1dfec880e605bc154bc963f4b3bd860c1b55 [2832] add value checking for 'cache-type'

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Apr 12 01:27:48 UTC 2013


The branch, trac2832 has been updated
       via  946b1dfec880e605bc154bc963f4b3bd860c1b55 (commit)
      from  9a160a14fcb4d4b781ee79fdd4aa60f8e56918b3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 946b1dfec880e605bc154bc963f4b3bd860c1b55
Author: Paul Selkirk <pselkirk at isc.org>
Date:   Thu Apr 11 21:27:25 2013 -0400

    [2832] add value checking for 'cache-type'

-----------------------------------------------------------------------

Summary of changes:
 src/lib/datasrc/cache_config.cc                |    8 ++++++--
 src/lib/datasrc/tests/cache_config_unittest.cc |    7 +++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/cache_config.cc b/src/lib/datasrc/cache_config.cc
index 9cfe3b1..b1d583f 100644
--- a/src/lib/datasrc/cache_config.cc
+++ b/src/lib/datasrc/cache_config.cc
@@ -37,12 +37,16 @@ getEnabledFromConf(const Element& conf) {
 
 std::string
 getSegmentTypeFromConf(const Element& conf) {
-    // If cache-zones is not explicitly configured, use the default type.
+    // If cache-type is not explicitly configured, use the default type.
     // (Ideally we should retrieve the default from the spec).
     if (!conf.contains("cache-type")) {
         return ("local");
     }
-    return (conf.get("cache-type")->stringValue());
+    std::string cache_type = conf.get("cache-type")->stringValue();
+    if ((cache_type != "local") && (cache_type != "mapped")) {
+        isc_throw(CacheConfigError, "invalid cache-type");
+    }
+    return (cache_type);
 }
 }
 
diff --git a/src/lib/datasrc/tests/cache_config_unittest.cc b/src/lib/datasrc/tests/cache_config_unittest.cc
index 8c266ec..cce2462 100644
--- a/src/lib/datasrc/tests/cache_config_unittest.cc
+++ b/src/lib/datasrc/tests/cache_config_unittest.cc
@@ -238,6 +238,13 @@ TEST_F(CacheConfigTest, getSegmentType) {
                                                 " \"params\": {}}"));
     EXPECT_THROW(CacheConfig("MasterFiles", 0, *badconfig, true),
                  isc::data::TypeError);
+
+    // Bad value: should be rejected at construction time
+    ConstElementPtr badconfig2(Element::fromJSON("{\"cache-enable\": true,"
+                                                " \"cache-type\": \"bogus\","
+                                                " \"params\": {}}"));
+    EXPECT_THROW(CacheConfig("MasterFiles", 0, *badconfig2, true),
+                 isc::datasrc::internal::CacheConfigError);
 }
 
 }



More information about the bind10-changes mailing list