Browse Source

[1976] The "any" type is compatible with any default

The validation rejected all the values of "item_default" in spec files,
if the desired type was "any". Actually, the exact opposite is required,
since any type is compatible with "any".
Michal 'vorner' Vaner 13 years ago
parent
commit
343dc8e1fe

+ 1 - 1
src/lib/config/module_spec.cc

@@ -37,7 +37,7 @@ check_leaf_item(ConstElementPtr spec, const std::string& name,
                 Element::types type, bool mandatory)
 {
     if (spec->contains(name)) {
-        if (spec->get(name)->getType() == type) {
+        if (type == Element::any || spec->get(name)->getType() == type) {
             return;
         } else {
             isc_throw(ModuleSpecError,

+ 1 - 0
src/lib/config/tests/module_spec_unittests.cc

@@ -110,6 +110,7 @@ TEST(ModuleSpec, SpecfileItems) {
                    "item_default not of type map");
     moduleSpecError("spec15.spec",
                    "badname is not a valid type name");
+    EXPECT_NO_THROW(moduleSpecFromFile(specfile("spec40.spec")));
 }
 
 TEST(ModuleSpec, SpecfileConfigData) {

+ 1 - 0
src/lib/config/tests/testdata/Makefile.am

@@ -66,3 +66,4 @@ EXTRA_DIST += spec36.spec
 EXTRA_DIST += spec37.spec
 EXTRA_DIST += spec38.spec
 EXTRA_DIST += spec39.spec
+EXTRA_DIST += spec40.spec

+ 13 - 0
src/lib/config/tests/testdata/spec40.spec

@@ -0,0 +1,13 @@
+{
+  "module_spec": {
+    "module_name": "Spec40",
+    "config_data": [
+      { "item_name": "item1",
+        "item_type": "any",
+        "item_optional": false,
+        "item_default": "asdf"
+      }
+    ]
+  }
+}
+