From: Francis Dupont Date: Mon, 21 Nov 2016 12:31:04 +0000 (+0100) Subject: [5014] Added 2 unit tests about keywords X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05a12f3fe305a9b850fc7b0bd188b0c6719c57b1;p=thirdparty%2Fkea.git [5014] Added 2 unit tests about keywords --- diff --git a/src/bin/dhcp6/dhcp6.dox b/src/bin/dhcp6/dhcp6.dox index 1d29bf012d..a7a5885e9d 100644 --- a/src/bin/dhcp6/dhcp6.dox +++ b/src/bin/dhcp6/dhcp6.dox @@ -84,10 +84,10 @@ general, the following issues of the existing code were noted: having trailing commas: @code "option-data": [ - { - "code": 12, - "data": "2001:db8:1:0:ff00::1" - }, + { + "code": 12, + "data": "2001:db8:1:0:ff00::1" + }, ] @endcode or having incorrect types, e.g. specifying timer values as strings. @@ -295,16 +295,16 @@ isc::dhcp::Triplet SubnetConfigParser::getParam(const std::string& name) { uint32_t value = 0; try { - // look for local value - value = uint32_values_->getParam(name); + // look for local value + value = uint32_values_->getParam(name); } catch (const DhcpConfigError &) { - try { - // no local, use global value - value = global_context_->uint32_values_->getParam(name); - } catch (const DhcpConfigError &) { - isc_throw(DhcpConfigError, "Mandatory parameter " << name - << " missing (no global default and no subnet-" - << "specific value)"); + try { + // no local, use global value + value = global_context_->uint32_values_->getParam(name); + } catch (const DhcpConfigError &) { + isc_throw(DhcpConfigError, "Mandatory parameter " << name + << " missing (no global default and no subnet-" + << "specific value)"); } } diff --git a/src/bin/dhcp6/parser_context.h b/src/bin/dhcp6/parser_context.h index 22bc6b3161..e3a4f1d4ee 100644 --- a/src/bin/dhcp6/parser_context.h +++ b/src/bin/dhcp6/parser_context.h @@ -120,8 +120,8 @@ public: POOLS, PD_POOLS, RESERVATIONS, - /// client-classes - CLIENT_CLASS, + /// client-classes + CLIENT_CLASS, /// Logging LOGGERS, /// loggers diff --git a/src/bin/dhcp6/tests/parser_unittest.cc b/src/bin/dhcp6/tests/parser_unittest.cc index 7e12155d84..e8ffbbccc7 100644 --- a/src/bin/dhcp6/tests/parser_unittest.cc +++ b/src/bin/dhcp6/tests/parser_unittest.cc @@ -106,6 +106,28 @@ TEST(ParserTest, types) { testParser(txt, Parser6Context::PARSER_GENERIC_JSON); } +TEST(ParserTest, keywordJSON) { + string txt = "{ \"name\": \"user\"," + "\"type\": \"password\"," + "\"user\": \"name\"," + "\"password\": \"type\" }"; + testParser(txt, Parser6Context::PARSER_GENERIC_JSON); +} + +TEST(ParserTest, keywordDhcp6) { + string txt = "{ \"Dhcp6\": { \"interfaces-config\": {" + " \"interfaces\": [ \"type\", \"htype\" ] },\n" + "\"preferred-lifetime\": 3000,\n" + "\"rebind-timer\": 2000, \n" + "\"renew-timer\": 1000, \n" + "\"subnet6\": [ { " + " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ]," + " \"subnet\": \"2001:db8:1::/48\", " + " \"interface\": \"test\" } ],\n" + "\"valid-lifetime\": 4000 } }"; + testParser2(txt, Parser6Context::PARSER_DHCP6); +} + TEST(ParserTest, bashComments) { string txt= "{ \"Dhcp6\": { \"interfaces-config\": {" " \"interfaces\": [ \"*\" ]"