From: Francis Dupont Date: Sun, 17 Dec 2017 17:02:57 +0000 (+0100) Subject: [5351] Updated servers X-Git-Tag: trac5480_base~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=998f40ebaf53782a8b2588f0a6b7b30b18bca498;p=thirdparty%2Fkea.git [5351] Updated servers --- diff --git a/doc/examples/kea4/advanced.json b/doc/examples/kea4/advanced.json index 624ca2b9fd..608a154d2f 100644 --- a/doc/examples/kea4/advanced.json +++ b/doc/examples/kea4/advanced.json @@ -119,9 +119,9 @@ "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. diff --git a/doc/examples/kea6/advanced.json b/doc/examples/kea6/advanced.json index c7db6da2ae..2d324b1a9d 100644 --- a/doc/examples/kea6/advanced.json +++ b/doc/examples/kea6/advanced.json @@ -106,7 +106,7 @@ // 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 diff --git a/doc/examples/kea6/comments.json b/doc/examples/kea6/comments.json index 7baea70fd0..49b37d7e36 100644 --- a/doc/examples/kea6/comments.json +++ b/doc/examples/kea6/comments.json @@ -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", diff --git a/src/bin/dhcp4/dhcp4_parser.cc b/src/bin/dhcp4/dhcp4_parser.cc index 8116508bf2..8425bc2a53 100644 --- a/src/bin/dhcp4/dhcp4_parser.cc +++ b/src/bin/dhcp4/dhcp4_parser.cc @@ -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 diff --git a/src/bin/dhcp4/dhcp4_parser.yy b/src/bin/dhcp4/dhcp4_parser.yy index 3556dcb9f2..6d4c574992 100644 --- a/src/bin/dhcp4/dhcp4_parser.yy +++ b/src/bin/dhcp4/dhcp4_parser.yy @@ -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(); }; diff --git a/src/bin/dhcp4/tests/config_parser_unittest.cc b/src/bin/dhcp4/tests/config_parser_unittest.cc index 09e84ce723..194cef0d75 100644 --- a/src/bin/dhcp4/tests/config_parser_unittest.cc +++ b/src/bin/dhcp4/tests/config_parser_unittest.cc @@ -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()); diff --git a/src/bin/dhcp4/tests/get_config_unittest.cc b/src/bin/dhcp4/tests/get_config_unittest.cc index 19ec5bc379..e6550ee1e7 100644 --- a/src/bin/dhcp4/tests/get_config_unittest.cc +++ b/src/bin/dhcp4/tests/get_config_unittest.cc @@ -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" diff --git a/src/bin/dhcp4/tests/parser_unittest.cc b/src/bin/dhcp4/tests/parser_unittest.cc index 7cc005ea9f..d909e533e8 100644 --- a/src/bin/dhcp4/tests/parser_unittest.cc +++ b/src/bin/dhcp4/tests/parser_unittest.cc @@ -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", diff --git a/src/bin/dhcp6/dhcp6_parser.cc b/src/bin/dhcp6/dhcp6_parser.cc index 7fab22349c..cb0e3542aa 100644 --- a/src/bin/dhcp6/dhcp6_parser.cc +++ b/src/bin/dhcp6/dhcp6_parser.cc @@ -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 diff --git a/src/bin/dhcp6/dhcp6_parser.yy b/src/bin/dhcp6/dhcp6_parser.yy index 126dab4501..15c0e8ebb5 100644 --- a/src/bin/dhcp6/dhcp6_parser.yy +++ b/src/bin/dhcp6/dhcp6_parser.yy @@ -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(); }; diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc index 7e823a0b95..2c7ec3b6e1 100644 --- a/src/bin/dhcp6/tests/config_parser_unittest.cc +++ b/src/bin/dhcp6/tests/config_parser_unittest.cc @@ -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()); diff --git a/src/bin/dhcp6/tests/get_config_unittest.cc b/src/bin/dhcp6/tests/get_config_unittest.cc index 959fbe96cc..1d37d6b80d 100644 --- a/src/bin/dhcp6/tests/get_config_unittest.cc +++ b/src/bin/dhcp6/tests/get_config_unittest.cc @@ -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" diff --git a/src/bin/dhcp6/tests/parser_unittest.cc b/src/bin/dhcp6/tests/parser_unittest.cc index c2286bd9ab..64e3fdc419 100644 --- a/src/bin/dhcp6/tests/parser_unittest.cc +++ b/src/bin/dhcp6/tests/parser_unittest.cc @@ -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");