From: Tomek Mrugalski Date: Thu, 15 May 2014 12:34:24 +0000 (+0200) Subject: [3400] Merge remote-tracking branch 'origin/trac3449' into trac3400 X-Git-Tag: trac3434_base~32^2~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=80ef9a69a262e1d79f1cf2e109a7e6f4ce21a193;p=thirdparty%2Fkea.git [3400] Merge remote-tracking branch 'origin/trac3449' into trac3400 Conflicts: ChangeLog --- 80ef9a69a262e1d79f1cf2e109a7e6f4ce21a193 diff --cc ChangeLog index 53f502225f,d70adcda7b..d1f5ec4a5d --- a/ChangeLog +++ b/ChangeLog @@@ -1,10 -1,15 +1,22 @@@ +7XX. [func]* tomek + b10-dhcp6: New parameter added to configure: --with-kea-config. + It allows selecting configuration backend and accepts one of two + values: BIND10, which uses BIND10 framework as Kea 0.8 did, or + JSON, which reads configuration from a JSON file. + (Trac #3400, git TBD) + + 782. [func] tmark + Added sender-ip, sender-port, and max-queue-size parameters to + the dhcp-ddns configuration section of both b10-dhcp4 and b10-dhcp6. + (Trac #3328, git 8d8d0b5eedaab20bf1008dfb3a6913eb006a6e73) + + 781. [func] marcin + libkea-dhcpsrv: the Memfile lease storage backend returns leases + of a specified type. Previously, it ignored the lease type parameter + and returned all leases for a particular client. Thanks to David + Carlier for helping to implement this ticket. + (Trac #3148, git d2f0edf473716cd747a21d6917e89ba55c148d8e) + 780. [func] marcin libkea-cc: JSON parser stores information about the position of the data element values in the JSON string. The position diff --cc src/bin/dhcp6/tests/config_parser_unittest.cc index 71a8a90f54,b77ecbfb19..36f9a861a3 --- a/src/bin/dhcp6/tests/config_parser_unittest.cc +++ b/src/bin/dhcp6/tests/config_parser_unittest.cc @@@ -600,16 -591,9 +591,14 @@@ TEST_F(Dhcp6ParserTest, multipleSubnets ElementPtr json = Element::fromJSON(config); + ofstream out("config.json"); + out << config; + out.close(); + + do { EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json)); - ASSERT_TRUE(x); - comment_ = parseAnswer(rcode_, x); - ASSERT_EQ(0, rcode_); + checkResult(x, 0); const Subnet6Collection* subnets = CfgMgr::instance().getSubnets6(); ASSERT_TRUE(subnets); diff --cc src/lib/cc/tests/data_unittests.cc index 6a5e839957,8ddfae9bd8..b7ec6a2684 --- a/src/lib/cc/tests/data_unittests.cc +++ b/src/lib/cc/tests/data_unittests.cc @@@ -930,61 -939,21 +939,75 @@@ TEST(Element, merge) } +// This test checks whether it is possible to ignore comments. It also checks +// that the comments are ignored only when told to. +TEST(Element, preprocessor) { + + string no_comment = "{ \"a\": 1,\n" + " \"b\": 2}"; + + string head_comment = "# this is a comment, ignore me\n" + "{ \"a\": 1,\n" + " \"b\": 2}"; + + string mid_comment = "{ \"a\": 1,\n" + "# this is a comment, ignore me\n" + " \"b\": 2}"; + + string tail_comment = "{ \"a\": 1,\n" + " \"b\": 2}" + "# this is a comment, ignore me\n"; + + string dbl_head_comment = "# this is a comment, ignore me\n" + "# second line, still ignored\n" + "{ \"a\": 1,\n" + " \"b\": 2}"; + + string dbl_mid_comment = "{ \"a\": 1,\n" + "# this is a comment, ignore me\n" + "# second line, still ignored\n" + " \"b\": 2}"; + + string dbl_tail_comment = "{ \"a\": 1,\n" + " \"b\": 2}" + "# this is a comment, ignore me\n" + "# second line, still ignored\n"; + + // This is what we expect in all cases. + ElementPtr exp = Element::fromJSON(no_comment); + + // Let's convert them all and see that the result it the same every time + EXPECT_TRUE(exp->equals(*Element::fromJSON(head_comment, true))); + EXPECT_TRUE(exp->equals(*Element::fromJSON(mid_comment, true))); + EXPECT_TRUE(exp->equals(*Element::fromJSON(tail_comment, true))); + EXPECT_TRUE(exp->equals(*Element::fromJSON(dbl_head_comment, true))); + EXPECT_TRUE(exp->equals(*Element::fromJSON(dbl_mid_comment, true))); + EXPECT_TRUE(exp->equals(*Element::fromJSON(dbl_tail_comment, true))); + + // With preprocessing disabled, it should fail all around + EXPECT_THROW(Element::fromJSON(head_comment), JSONError); + EXPECT_THROW(Element::fromJSON(mid_comment), JSONError); + EXPECT_THROW(Element::fromJSON(tail_comment), JSONError); + EXPECT_THROW(Element::fromJSON(dbl_head_comment), JSONError); + EXPECT_THROW(Element::fromJSON(dbl_mid_comment), JSONError); + EXPECT_THROW(Element::fromJSON(dbl_tail_comment), JSONError); +} + TEST(Element, getPosition) { + std::istringstream ss("{\n" + " \"a\": 2,\n" + " \"b\":true,\n" + " \"cy\": \"a string\",\n" + " \"dyz\": {\n" + "\n" + " \"e\": 3,\n" + " \"f\": null\n" + "\n" + " },\n" + " \"g\": [ 5, 6,\n" + " 7 ]\n" + "}\n"); + // Create a JSON string holding different type of values. Some of the // values in the config string are not aligned, so as we can check that // the position is set correctly for the elements.