]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5351] Updated servers
authorFrancis Dupont <fdupont@isc.org>
Sun, 17 Dec 2017 17:02:57 +0000 (18:02 +0100)
committerFrancis Dupont <fdupont@isc.org>
Sun, 17 Dec 2017 17:02:57 +0000 (18:02 +0100)
13 files changed:
doc/examples/kea4/advanced.json
doc/examples/kea6/advanced.json
doc/examples/kea6/comments.json
src/bin/dhcp4/dhcp4_parser.cc
src/bin/dhcp4/dhcp4_parser.yy
src/bin/dhcp4/tests/config_parser_unittest.cc
src/bin/dhcp4/tests/get_config_unittest.cc
src/bin/dhcp4/tests/parser_unittest.cc
src/bin/dhcp6/dhcp6_parser.cc
src/bin/dhcp6/dhcp6_parser.yy
src/bin/dhcp6/tests/config_parser_unittest.cc
src/bin/dhcp6/tests/get_config_unittest.cc
src/bin/dhcp6/tests/parser_unittest.cc

index 624ca2b9fd4c6672670d2b2b2088b92ed3959e3a..608a154d2f5ba6d3e7ef34f9c2d83ca14e65b9a9 100644 (file)
             "subnet": "192.0.2.0/24",
             "user-context": {
                 "comment": "Our first subnet!"
-            },
+            }
             // Equivalent using smart parser
-            "comment": "Our first subnet!"
+            // "comment": "Our first subnet!"
         },
         {
             // This particular subnet has match-client-id value changed.
index c7db6da2aecf219e24bca55d01b1e86a4948bb3c..2d324b1a9d502da02eabdfab09f49a3893427885 100644 (file)
         // Here's the user-context for the whole subnet.
         "user-context": { "comment": "Floor one, west wing" },
         // Equivalent using smart parser
-        "comment": "Floor one, west wing",
+        // "comment": "Floor one, west wing",
 
         // This defines PD (prefix delegation) pools. In this case
         // we have only one pool. That consists of /64 prefixes
index 7baea70fd0ff24824839f3e031ece24a87624e79..49b37d7e36c742442f6a349e4ea82184a855c85d 100644 (file)
@@ -41,7 +41,7 @@
        {
           "name": "none"
        },
-       // A comment and        a user-context can be specified
+       // A comment and a user-context can be specified
        {
           "comment": "a comment",
           "name": "both",
index 8116508bf2f7c126df9abc7f97154f9c139a6334..8425bc2a53727bad0accbe9a4a851986b086dd2f 100644 (file)
@@ -2352,7 +2352,7 @@ namespace isc { namespace dhcp {
     ConstElementPtr old = parent->get("user-context");
     if (old) {
         // Check for duplicate comment
-        if (old->contains("comment") {
+      if (old->contains("comment")) {
             std::stringstream msg;
             msg << "duplicate user-context/comment entries (previous at "
                 << old->getPosition().str() << ")";
@@ -2361,6 +2361,7 @@ namespace isc { namespace dhcp {
         // Merge the user context in the comment
         merge(e, old);
     }
+    parent->set("user-context", e);
     ctx.leave();
 }
 #line 2367 "dhcp4_parser.cc" // lalr1.cc:859
index 3556dcb9f212032db1616facbccd7c4cc72d37b2..6d4c574992355ea161e48ebd135736c97234bb02 100644 (file)
@@ -1376,6 +1376,8 @@ user_context: USER_CONTEXT {
         // Merge the comment
         user_context->set("comment", old->get("comment"));
     }
+
+    // Set the user context
     parent->set("user-context", user_context);
     ctx.leave();
 };
@@ -1384,23 +1386,26 @@ comment: COMMENT {
     ctx.enter(ctx.NO_KEYWORD);
 } COLON STRING {
     ElementPtr parent = ctx.stack_.back();
-    ElementPtr e(new MapElement(ctx.loc2pos(@1)));
-    ElementPtr s(new StringElement($4, ctx.loc2pos(@4)));
-    e->set("comment", s);
+    ElementPtr user_context(new MapElement(ctx.loc2pos(@1)));
+    ElementPtr comment(new StringElement($4, ctx.loc2pos(@4)));
+    user_context->set("comment", comment);
 
     // Handle already existing user context
     ConstElementPtr old = parent->get("user-context");
     if (old) {
         // Check for duplicate comment
-        if (old->contains("comment") {
+        if (old->contains("comment")) {
             std::stringstream msg;
             msg << "duplicate user-context/comment entries (previous at "
                 << old->getPosition().str() << ")";
             error(@1, msg.str());
         }
         // Merge the user context in the comment
-        merge(e, old);
+        merge(user_context, old);
     }
+
+    // Set the user context
+    parent->set("user-context", user_context);
     ctx.leave();
 };
 
index 09e84ce723c284668fb9bca7719332452ae63ad7..194cef0d75c8333ad51dc3af6368e7562ab86306 100644 (file)
@@ -130,6 +130,82 @@ const char* PARSER_CONFIGS[] = {
     "        ],"
     "        \"subnet\": \"192.0.2.0/24\""
     "     } ]"
+    "}",
+
+    // Last Configuration for comments
+    "{"
+    "    \"comment\": \"A DHCPv4 server\","
+    "    \"interfaces-config\": {"
+    "        \"comment\": \"Use wildcard\","
+    "        \"interfaces\": [ \"*\" ] },"
+    "    \"option-def\": [ {"
+    "        \"comment\": \"An option definition\","
+    "        \"name\": \"foo\","
+    "        \"code\": 100,"
+    "        \"type\": \"ipv4-address\","
+    "        \"space\": \"isc\""
+    "     } ],"
+    "    \"option-data\": [ {"
+    "        \"comment\": \"Set option value\","
+    "        \"name\": \"dhcp-message\","
+    "        \"data\": \"ABCDEF0105\","
+    "        \"csv-format\": false"
+    "     } ],"
+    "    \"client-classes\": ["
+    "        {"
+    "           \"comment\": \"match all\","
+    "           \"name\": \"all\","
+    "           \"test\": \"'' == ''\""
+    "        },"
+    "        {"
+    "           \"name\": \"none\""
+    "        },"
+    "        {"
+    "           \"comment\": \"a comment\","
+    "           \"name\": \"both\","
+    "           \"user-context\": {"
+    "               \"version\": 1"
+    "           }"
+    "        }"
+    "        ],"
+    "    \"control-socket\": {"
+    "        \"socket-type\": \"unix\","
+    "        \"socket-name\": \"/tmp/kea4-ctrl-socket\","
+    "        \"user-context\": { \"comment\": \"Indirect comment\" }"
+    "    },"
+    "    \"shared-networks\": [ {"
+    "        \"comment\": \"A shared network\","
+    "        \"name\": \"foo\","
+    "        \"subnet4\": ["
+    "        { "
+    "            \"comment\": \"A subnet\","
+    "            \"subnet\": \"192.0.1.0/24\","
+    "            \"id\": 100,"
+    "            \"pools\": ["
+    "            {"
+    "                 \"comment\": \"A pool\","
+    "                 \"pool\": \"192.0.1.1-192.0.1.10\""
+    "            }"
+    "            ],"
+    "            \"reservations\": ["
+    "            {"
+    "                 \"comment\": \"A host reservation\","
+    "                 \"hw-address\": \"AA:BB:CC:DD:EE:FF\","
+    "                 \"hostname\": \"foo.example.com\","
+    "                 \"option-data\": [ {"
+    "                     \"comment\": \"An option in a reservation\","
+    "                     \"name\": \"domain-name\","
+    "                     \"data\": \"example.com\""
+    "                 } ]"
+    "            }"
+    "            ]"
+    "        }"
+    "        ]"
+    "     } ],"
+    "    \"dhcp-ddns\": {"
+    "        \"comment\": \"No dynamic DNS\","
+    "        \"enable-updates\": false"
+    "    }"
     "}"
 };
 
@@ -5611,87 +5687,7 @@ TEST_F(Dhcp4ParserTest, sharedNetworksDeriveClientClass) {
 // This test checks comments. Please keep it last.
 TEST_F(Dhcp4ParserTest, comments) {
 
-    string config = "{\n"
-        "\"comment\": \"A DHCPv4 server\",\n"
-        "\"interfaces-config\": {\n"
-        "    \"comment\": \"Use wildcard\",\n"
-        "    \"interfaces\": [ \"*\" ] },\n"
-        "\"option-def\": [ {\n"
-        "    \"comment\": \"An option definition\",\n"
-        "    \"name\": \"foo\",\n"
-        "    \"code\": 100,\n"
-        "    \"type\": \"ipv4-address\",\n"
-        "    \"space\": \"isc\"\n"
-        " } ],\n"
-        "\"option-data\": [ {\n"
-        "    \"comment\": \"Set option value\",\n"
-        "    \"name\": \"dhcp-message\",\n"
-        "    \"data\": \"ABCDEF0105\",\n"
-        "    \"csv-format\": false\n"
-        " } ],\n"
-        "\"client-classes\": [\n"
-        "    {\n"
-        "       \"comment\": \"match all\",\n"
-        "       \"name\": \"all\",\n"
-        "       \"test\": \"'' == ''\"\n"
-        "    },\n"
-        "    {\n"
-        "       \"name\": \"none\"\n"
-        "    },\n"
-        "    {\n"
-        "       \"comment\": \"first comment\",\n"
-        "       \"comment\": \"second comment\",\n"
-        "       \"name\": \"two\"\n"
-        "    },\n"
-        "    {\n"
-        "       \"comment\": \"a comment\",\n"
-        "       \"name\": \"both\",\n"
-        "       \"user-context\": {\n"
-        "           \"version\": 1\n"
-        "       }\n"
-        "    }\n"
-        "    ],\n"
-        "\"control-socket\": {\n"
-        "    \"comment\": \"REST API\",\n"
-        "    \"socket-type\": \"unix\",\n"
-        "    \"socket-name\": \"/tmp/kea4-ctrl-socket\",\n"
-        "    \"user-context\": { \"comment\": \"Indirect comment\" }\n"
-        "},\n"
-        "\"shared-networks\": [ {\n"
-        "    \"comment\": \"A shared network\"\n,"
-        "    \"name\": \"foo\"\n,"
-        "    \"subnet4\": [\n"
-        "    { \n"
-        "        \"comment\": \"A subnet\"\n,"
-        "        \"subnet\": \"192.0.1.0/24\",\n"
-        "        \"id\": 100,\n"
-        "        \"pools\": [\n"
-        "        {\n"
-        "             \"comment\": \"A pool\",\n"
-        "             \"pool\": \"192.0.1.1-192.0.1.10\"\n"
-        "        }\n"
-        "        ],\n"
-        "        \"reservations\": [\n"
-        "        {\n"
-        "             \"comment\": \"A host reservation\",\n"
-        "             \"hw-address\": \"AA:BB:CC:DD:EE:FF\",\n"
-        "             \"hostname\": \"foo.example.com\",\n"
-        "             \"option-data\": [ {\n"
-        "                 \"comment\": \"An option in a reservation\",\n"
-        "                 \"name\": \"domain-name\",\n"
-        "                 \"data\": \"example.com\"\n"
-        "             } ]\n"
-        "        }\n"
-        "        ]\n"
-        "    }\n"
-        "    ]\n"
-        " } ],\n"
-        "\"dhcp-ddns\": {\n"
-        "    \"comment\": \"No dynamic DNS\",\n"
-        "    \"enable-updates\": false\n"
-        "}\n"
-        "}\n";
-
+    string config = PARSER_CONFIGS[4];
     extractConfig(config);
     configure(config, CONTROL_RESULT_SUCCESS, "");
 
@@ -5748,7 +5744,7 @@ TEST_F(Dhcp4ParserTest, comments) {
     const ClientClassDictionaryPtr& dict =
         CfgMgr::instance().getStagingCfg()->getClientClassDictionary();
     ASSERT_TRUE(dict);
-    EXPECT_EQ(4, dict->getClasses()->size());
+    EXPECT_EQ(3, dict->getClasses()->size());
     ClientClassDefPtr cclass = dict->findClass("all");
     ASSERT_TRUE(cclass);
     EXPECT_EQ("all", cclass->getName());
@@ -5768,17 +5764,6 @@ TEST_F(Dhcp4ParserTest, comments) {
     EXPECT_EQ("", cclass->getTest());
     EXPECT_FALSE(cclass->getContext());
 
-    // The 'two' class has two comments.
-    cclass = dict->findClass("two");
-    EXPECT_EQ("two", cclass->getName());
-    EXPECT_EQ("", cclass->getTest());
-    ctx_class = cclass->getContext();
-    ASSERT_TRUE(ctx_class);
-    ASSERT_EQ(1, ctx_class->size());
-    ASSERT_TRUE(ctx_class->get("comment"));
-    ASSERT_EQ(Element::list, cclass->getContext()->get("comment")->getType());
-    ASSERT_EQ(2, cclass->getContext()->get("comment")->size());
-
     // The 'both' class has a user context and a comment.
     cclass = dict->findClass("both");
     EXPECT_EQ("both", cclass->getName());
@@ -5801,10 +5786,7 @@ TEST_F(Dhcp4ParserTest, comments) {
     EXPECT_EQ("\"/tmp/kea4-ctrl-socket\"", socket->get("socket-name")->str());
 
     // Check control socket comment and user context.
-    ConstElementPtr ctx_socket = socket->get("comment");
-    ASSERT_TRUE(ctx_socket);
-    EXPECT_EQ("\"REST API\"", ctx_socket->str());
-    ctx_socket = socket->get("user-context");
+    ConstElementPtr ctx_socket = socket->get("user-context");
     ASSERT_EQ(1, ctx_socket->size());
     ASSERT_TRUE(ctx_socket->get("comment"));
     EXPECT_EQ("\"Indirect comment\"", ctx_socket->get("comment")->str());
index 19ec5bc37908336749b30f0eafd66aa9d31c697a..e6550ee1e7f99cb7783afc601e7e93760b41afb5 100644 (file)
@@ -1651,10 +1651,6 @@ const char* EXTRACTED_CONFIGS[] = {
 "                \"name\": \"none\"\n"
 "            },\n"
 "            {\n"
-"                \"comment\": [ \"first comment\", \"second comment\" ],\n"
-"                \"name\": \"two\"\n"
-"            },\n"
-"            {\n"
 "                \"comment\": \"a comment\",\n"
 "                \"name\": \"both\",\n"
 "                \"user-context\": {\n"
@@ -1663,7 +1659,6 @@ const char* EXTRACTED_CONFIGS[] = {
 "            }\n"
 "        ],\n"
 "        \"control-socket\": {\n"
-"            \"comment\": \"REST API\",\n"
 "            \"socket-name\": \"/tmp/kea4-ctrl-socket\",\n"
 "            \"socket-type\": \"unix\",\n"
 "            \"user-context\": {\n"
@@ -6406,19 +6401,9 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"option-data\": [ ],\n"
 "                \"option-def\": [ ],\n"
 "                \"server-hostname\": \"\"\n"
-"            },\n"
-"            {\n"
-"                \"comment\": [ \"first comment\", \"second comment\" ],\n"
-"                \"boot-file-name\": \"\",\n"
-"                \"name\": \"two\",\n"
-"                \"next-server\": \"0.0.0.0\",\n"
-"                \"option-data\": [ ],\n"
-"                \"option-def\": [ ],\n"
-"                \"server-hostname\": \"\"\n"
 "            }\n"
 "        ],\n"
 "        \"control-socket\": {\n"
-"            \"comment\": \"REST API\",\n"
 "            \"socket-name\": \"/tmp/kea4-ctrl-socket\",\n"
 "            \"socket-type\": \"unix\",\n"
 "            \"user-context\": {\n"
index 7cc005ea9f159cf1ffbd14ee399b4da8f451fedc..d909e533e829f634792da1231febb9d90e759b9d 100644 (file)
@@ -247,7 +247,7 @@ TEST(ParserTest, file) {
                                "backends.json",
                                "cassandra.json",
                                "classify.json",
-                               // "comments.json",
+                               "comments.json",
                                "dhcpv4-over-dhcpv6.json",
                                "hooks.json",
                                "leases-expiration.json",
index 7fab22349c05607c3d299c3397735a9d5bd135e6..cb0e3542aa3ab51d04ca7afc3cbd01d3e5d42603 100644 (file)
@@ -2253,7 +2253,7 @@ namespace isc { namespace dhcp {
     ConstElementPtr old = parent->get("user-context");
     if (old) {
         // Check for duplicate comment
-        if (old->contains("comment") {
+        if (old->contains("comment")) {
             std::stringstream msg;
             msg << "duplicate user-context/comment entries (previous at "
                 << old->getPosition().str() << ")";
@@ -2262,6 +2262,7 @@ namespace isc { namespace dhcp {
         // Merge the user context in the comment
         merge(e, old);
     }
+    parent->set("user-context",e);
     ctx.leave();
 }
 #line 2268 "dhcp6_parser.cc" // lalr1.cc:859
index 126dab45019e3fff59461e287899c3bda1500f17..15c0e8ebb5f4f6ba5e7631894d42188a64ddb02e 100644 (file)
@@ -1339,6 +1339,8 @@ user_context: USER_CONTEXT {
         // Merge the comment
         user_context->set("comment", old->get("comment"));
     }
+
+    // Set the user context
     parent->set("user-context", user_context);
     ctx.leave();
 };
@@ -1347,23 +1349,26 @@ comment: COMMENT {
     ctx.enter(ctx.NO_KEYWORD);
 } COLON STRING {
     ElementPtr parent = ctx.stack_.back();
-    ElementPtr e(new MapElement(ctx.loc2pos(@1)));
-    ElementPtr s(new StringElement($4, ctx.loc2pos(@4)));
-    e->set("comment", s);
+    ElementPtr user_context(new MapElement(ctx.loc2pos(@1)));
+    ElementPtr comment(new StringElement($4, ctx.loc2pos(@4)));
+    user_context->set("comment", comment);
 
     // Handle already existing user context
     ConstElementPtr old = parent->get("user-context");
     if (old) {
         // Check for duplicate comment
-        if (old->contains("comment") {
+        if (old->contains("comment")) {
             std::stringstream msg;
             msg << "duplicate user-context/comment entries (previous at "
                 << old->getPosition().str() << ")";
             error(@1, msg.str());
         }
         // Merge the user context in the comment
-        merge(e, old);
+        merge(user_context, old);
     }
+
+    // Set the user context
+    parent->set("user-context", user_context);
     ctx.leave();
 };
 
index 7e823a0b95b3995d77fe8e040121b4f52db6aef4..2c7ec3b6e196dfde0aed92ae6662dce52396e39f 100644 (file)
@@ -209,99 +209,93 @@ const char* PARSER_CONFIGS[] = {
     "     } ]"
     "}",
 
-    // Configuration 7: comments everywhere
-    "{\n"
-    "\"comment\": \"A DHCPv6 server\",\n"
-    "\"server-id\": {\n"
-    "    \"comment\": \"DHCPv6 specific\",\n"
-    "    \"type\": \"LL\"\n"
-    "},\n"
-    "\"interfaces-config\": {\n"
-    "    \"comment\": \"Use wildcard\",\n"
-    "    \"interfaces\": [ \"*\" ] },\n"
-    "\"option-def\": [ {\n"
-    "    \"comment\": \"An option definition\",\n"
-    "    \"name\": \"foo\",\n"
-    "    \"code\": 100,\n"
-    "    \"type\": \"ipv6-address\",\n"
-    "    \"space\": \"isc\"\n"
-    " } ],\n"
-    "\"option-data\": [ {\n"
-    "    \"comment\": \"Set option value\",\n"
-    "    \"name\": \"subscriber-id\",\n"
-    "    \"data\": \"ABCDEF0105\",\n"
-    "        \"csv-format\": false\n"
-    " } ],\n"
-    "\"client-classes\": [\n"
-    "    {\n"
-    "       \"comment\": \"match all\",\n"
-    "       \"name\": \"all\",\n"
-    "       \"test\": \"'' == ''\"\n"
-    "    },\n"
-    "    {\n"
-    "       \"name\": \"none\"\n"
-    "    },\n"
-    "    {\n"
-    "       \"comment\": \"first comment\",\n"
-    "       \"comment\": \"second comment\",\n"
-    "       \"name\": \"two\"\n"
-    "    },\n"
-    "    {\n"
-    "       \"comment\": \"a comment\",\n"
-    "       \"name\": \"both\",\n"
-    "       \"user-context\": {\n"
-    "           \"version\": 1\n"
-    "       }\n"
-    "    }\n"
-    "    ],\n"
-    "\"control-socket\": {\n"
-    "    \"comment\": \"REST API\",\n"
-    "    \"socket-type\": \"unix\",\n"
-    "    \"socket-name\": \"/tmp/kea6-ctrl-socket\",\n"
-    "    \"user-context\": { \"comment\": \"Indirect comment\" }\n"
-    "},\n"
-    "\"shared-networks\": [ {\n"
-    "    \"comment\": \"A shared network\"\n,"
-    "    \"name\": \"foo\"\n,"
-    "    \"subnet6\": [\n"
-    "    { \n"
-    "        \"comment\": \"A subnet\"\n,"
-    "        \"subnet\": \"2001:db1::/48\",\n"
-    "        \"id\": 100,\n"
-    "        \"pools\": [\n"
-    "        {\n"
-    "             \"comment\": \"A pool\",\n"
-    "             \"pool\": \"2001:db1::/64\"\n"
-    "        }\n"
-    "        ],\n"
-    "        \"pd-pools\": [\n"
-    "        {\n"
-    "             \"comment\": \"A prefix pool\",\n"
-    "             \"prefix\": \"2001:db2::\",\n"
-    "             \"prefix-len\": 48,\n"
-    "             \"delegated-len\": 64\n"
-    "        }\n"
-    "        ],\n"
-    "        \"reservations\": [\n"
-    "        {\n"
-    "             \"comment\": \"A host reservation\",\n"
-    "             \"hw-address\": \"AA:BB:CC:DD:EE:FF\",\n"
-    "             \"hostname\": \"foo.example.com\",\n"
-    "             \"option-data\": [ {\n"
-    "                 \"comment\": \"An option in a reservation\",\n"
-    "                 \"name\": \"domain-search\",\n"
-    "                 \"data\": \"example.com\"\n"
-    "             } ]\n"
-    "        }\n"
-    "        ]\n"
-    "    }\n"
-    "    ]\n"
-    " } ],\n"
-    "\"dhcp-ddns\": {\n"
-    "    \"comment\": \"No dynamic DNS\",\n"
-    "    \"enable-updates\": false\n"
-    "}\n"
-    "}\n"
+    // Last configuration for comments
+    "{"
+    "    \"comment\": \"A DHCPv6 server\","
+    "    \"server-id\": {"
+    "        \"comment\": \"DHCPv6 specific\","
+    "        \"type\": \"LL\""
+    "    },"
+    "    \"interfaces-config\": {"
+    "        \"comment\": \"Use wildcard\","
+    "        \"interfaces\": [ \"*\" ] },"
+    "    \"option-def\": [ {"
+    "        \"comment\": \"An option definition\","
+    "        \"name\": \"foo\","
+    "        \"code\": 100,"
+    "        \"type\": \"ipv6-address\","
+    "        \"space\": \"isc\""
+    "     } ],"
+    "    \"option-data\": [ {"
+    "        \"comment\": \"Set option value\","
+    "        \"name\": \"subscriber-id\","
+    "        \"data\": \"ABCDEF0105\","
+    "            \"csv-format\": false"
+    "     } ],"
+    "    \"client-classes\": ["
+    "        {"
+    "           \"comment\": \"match all\","
+    "           \"name\": \"all\","
+    "           \"test\": \"'' == ''\""
+    "        },"
+    "        {"
+    "           \"name\": \"none\""
+    "        },"
+    "        {"
+    "           \"comment\": \"a comment\","
+    "           \"name\": \"both\","
+    "           \"user-context\": {"
+    "               \"version\": 1"
+    "           }"
+    "        }"
+    "        ],"
+    "    \"control-socket\": {"
+    "        \"socket-type\": \"unix\","
+    "        \"socket-name\": \"/tmp/kea6-ctrl-socket\","
+    "        \"user-context\": { \"comment\": \"Indirect comment\" }"
+    "    },"
+    "    \"shared-networks\": [ {"
+    "        \"comment\": \"A shared network\","
+    "        \"name\": \"foo\","
+    "        \"subnet6\": ["
+    "        { "
+    "            \"comment\": \"A subnet\","
+    "            \"subnet\": \"2001:db1::/48\","
+    "            \"id\": 100,"
+    "            \"pools\": ["
+    "            {"
+    "                 \"comment\": \"A pool\","
+    "                 \"pool\": \"2001:db1::/64\""
+    "            }"
+    "            ],"
+    "            \"pd-pools\": ["
+    "            {"
+    "                 \"comment\": \"A prefix pool\","
+    "                 \"prefix\": \"2001:db2::\","
+    "                 \"prefix-len\": 48,"
+    "                 \"delegated-len\": 64"
+    "            }"
+    "            ],"
+    "            \"reservations\": ["
+    "            {"
+    "                 \"comment\": \"A host reservation\","
+    "                 \"hw-address\": \"AA:BB:CC:DD:EE:FF\","
+    "                 \"hostname\": \"foo.example.com\","
+    "                 \"option-data\": [ {"
+    "                     \"comment\": \"An option in a reservation\","
+    "                     \"name\": \"domain-search\","
+    "                     \"data\": \"example.com\""
+    "                 } ]"
+    "            }"
+    "            ]"
+    "        }"
+    "        ]"
+    "     } ],"
+    "    \"dhcp-ddns\": {"
+    "        \"comment\": \"No dynamic DNS\","
+    "        \"enable-updates\": false"
+    "    }"
+    "}"
 };
 
 std::string specfile(const std::string& name) {
@@ -908,7 +902,7 @@ public:
     }
 
     int rcode_; ///< Return code (see @ref isc::config::parseAnswer)
-    Dhcpv6Srv srv_; ///< Instance of the ControlledDhcp6Srv used during tests
+    ControlledDhcpv6Srv srv_; ///< Instance of the ControlledDhcp6Srv used during tests
     ConstElementPtr comment_; ///< Comment (see @ref isc::config::parseAnswer)
     string valid_iface_; ///< Valid network interface name (present in system)
     string bogus_iface_; ///< invalid network interface name (not in system)
@@ -6147,8 +6141,9 @@ TEST_F(Dhcp6ParserTest, sharedNetworksRapidCommitMix) {
 // This test checks comments. Please keep it last.
 TEST_F(Dhcp6ParserTest, comments) {
 
-    extractConfig(PARSER_CONFIGS[7]);
-    configure(PARSER_CONFIGS[7], CONTROL_RESULT_SUCCESS, "");
+    string config = PARSER_CONFIGS[7];
+    extractConfig(config);
+    configure(config, CONTROL_RESULT_SUCCESS, "");
 
     // Check global user context.
     ConstElementPtr ctx = CfgMgr::instance().getStagingCfg()->getContext();
@@ -6215,7 +6210,7 @@ TEST_F(Dhcp6ParserTest, comments) {
     const ClientClassDictionaryPtr& dict =
         CfgMgr::instance().getStagingCfg()->getClientClassDictionary();
     ASSERT_TRUE(dict);
-    EXPECT_EQ(4, dict->getClasses()->size());
+    EXPECT_EQ(3, dict->getClasses()->size());
     ClientClassDefPtr cclass = dict->findClass("all");
     ASSERT_TRUE(cclass);
     EXPECT_EQ("all", cclass->getName());
@@ -6235,17 +6230,6 @@ TEST_F(Dhcp6ParserTest, comments) {
     EXPECT_EQ("", cclass->getTest());
     EXPECT_FALSE(cclass->getContext());
 
-    // The 'two' class has two comments.
-    cclass = dict->findClass("two");
-    EXPECT_EQ("two", cclass->getName());
-    EXPECT_EQ("", cclass->getTest());
-    ctx_class = cclass->getContext();
-    ASSERT_TRUE(ctx_class);
-    ASSERT_EQ(1, ctx_class->size());
-    ASSERT_TRUE(ctx_class->get("comment"));
-    ASSERT_EQ(Element::list, cclass->getContext()->get("comment")->getType());
-    ASSERT_EQ(2, cclass->getContext()->get("comment")->size());
-
     // The 'both' class has a user context and a comment.
     cclass = dict->findClass("both");
     EXPECT_EQ("both", cclass->getName());
@@ -6268,10 +6252,7 @@ TEST_F(Dhcp6ParserTest, comments) {
     EXPECT_EQ("\"/tmp/kea6-ctrl-socket\"", socket->get("socket-name")->str());
 
     // Check control socket comment and user context.
-    ConstElementPtr ctx_socket = socket->get("comment");
-    ASSERT_TRUE(ctx_socket);
-    EXPECT_EQ("\"REST API\"", ctx_socket->str());
-    ctx_socket = socket->get("user-context");
+    ConstElementPtr ctx_socket = socket->get("user-context");
     ASSERT_EQ(1, ctx_socket->size());
     ASSERT_TRUE(ctx_socket->get("comment"));
     EXPECT_EQ("\"Indirect comment\"", ctx_socket->get("comment")->str());
index 959fbe96cc625fb74f8cce4bee48879195649703..1d37d6b80d16f6a68620b5d38fcf120afe4c3e70 100644 (file)
@@ -1521,10 +1521,6 @@ const char* EXTRACTED_CONFIGS[] = {
 "                \"name\": \"none\"\n"
 "            },\n"
 "            {\n"
-"                \"comment\": [ \"first comment\", \"second comment\" ],\n"
-"                \"name\": \"two\"\n"
-"            },\n"
-"            {\n"
 "                \"comment\": \"a comment\",\n"
 "                \"name\": \"both\",\n"
 "                \"user-context\": {\n"
@@ -1533,7 +1529,6 @@ const char* EXTRACTED_CONFIGS[] = {
 "            }\n"
 "        ],\n"
 "        \"control-socket\": {\n"
-"            \"comment\": \"REST API\",\n"
 "            \"socket-name\": \"/tmp/kea6-ctrl-socket\",\n"
 "            \"socket-type\": \"unix\",\n"
 "            \"user-context\": {\n"
@@ -6004,15 +5999,9 @@ const char* UNPARSED_CONFIGS[] = {
 "            {\n"
 "                \"name\": \"none\",\n"
 "                \"option-data\": [ ]\n"
-"            },\n"
-"            {\n"
-"                \"comment\": [ \"first comment\", \"second comment\" ],\n"
-"                \"name\": \"two\",\n"
-"                \"option-data\": [ ]\n"
 "            }\n"
 "        ],\n"
 "        \"control-socket\": {\n"
-"            \"comment\": \"REST API\",\n"
 "            \"socket-name\": \"/tmp/kea6-ctrl-socket\",\n"
 "            \"socket-type\": \"unix\",\n"
 "            \"user-context\": {\n"
index c2286bd9abc1a503f7a88886fcd45bd079a856d3..64e3fdc4199ffad21c3efbdd5186130ee21db16e 100644 (file)
@@ -251,7 +251,7 @@ TEST(ParserTest, file) {
     configs.push_back("backends.json");
     configs.push_back("cassandra.json");
     configs.push_back("classify.json");
-    // configs.push_back("comments.json");
+    configs.push_back("comments.json");
     configs.push_back("dhcpv4-over-dhcpv6.json");
     configs.push_back("duid.json");
     configs.push_back("hooks.json");