]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5114] Minor test improvements after review
authorTomek Mrugalski <tomasz@isc.org>
Fri, 10 Mar 2017 17:54:05 +0000 (18:54 +0100)
committerTomek Mrugalski <tomasz@isc.org>
Fri, 10 Mar 2017 17:54:05 +0000 (18:54 +0100)
src/bin/dhcp6/tests/config_parser_unittest.cc
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc
src/lib/dhcpsrv/tests/ifaces_config_parser_unittest.cc

index 71273d0bcf3336136e7e067200df8cc627409888..c279bc022ef9271b304cc42551167677ecc6526c 100644 (file)
@@ -1165,7 +1165,7 @@ TEST_F(Dhcp6ParserTest, subnetLocal) {
 TEST_F(Dhcp6ParserTest, subnetInterface) {
 
     // There should be at least one interface
-
+    // As far as I can tell, this is the first lambda in Kea code. Cool.
     auto config = [this](string iface) {
         return ("{ " + genIfaceConfig() + ","
                 "\"preferred-lifetime\": 3000,"
index 7c6fcc680caaf864a81ad3add1bf791b9b33fb76..69e09646b92cb78246d46c1a84ec2c2925ca8211 100644 (file)
@@ -703,21 +703,7 @@ public:
     void runCfgOptionsTest(uint16_t family, std::string config) {
         ConstElementPtr json;
         ASSERT_NO_THROW(json = Element::fromJSON(config)) << config;
-        ConstElementPtr option_def = json->get("option-def");
-        if (option_def) {
-            SimpleParser::setListDefaults(option_def,
-                                          family == AF_INET ?
-                                          ParseConfigTest::OPTION4_DEF_DEFAULTS :
-                                          ParseConfigTest::OPTION6_DEF_DEFAULTS);
-        }
-        ConstElementPtr option_data = json->get("option-data");
-        if (option_data) {
-            SimpleParser::setListDefaults(option_data,
-                                          family == AF_INET ?
-                                          ParseConfigTest::OPTION4_DEFAULTS :
-                                          ParseConfigTest::OPTION6_DEFAULTS);
-        }
-        runToElementTest<CfgOptionsTest>(json, *this);
+        runCfgOptionsTest(family, json);
     }
 
 private:
index 4fa43342f057768213f4c908dec8ae766337b5a1..f29ecd417355d70df294a0b5a69abe4e6bbea755 100644 (file)
@@ -356,7 +356,7 @@ TEST_F(HostReservationParserTest, dhcp4ClientIdHexWithPrefix) {
 // This test verifies that the parser can parse the reservation entry
 // when IPv4 address is specified, but hostname is not.
 TEST_F(HostReservationParserTest, dhcp4NoHostname) {
-    std::string config = "{ \"duid\": \"01:02:03:04:05:06:07:08:09:0A\","
+    std::string config = "{ \"duid\": \"01:02:03:04:05:06:07:08:09:0a\","
         "\"ip-address\": \"192.0.2.10\" }";
 
     ElementPtr config_element = Element::fromJSON(config);
@@ -376,7 +376,6 @@ TEST_F(HostReservationParserTest, dhcp4NoHostname) {
     EXPECT_TRUE(hosts[0]->getHostname().empty());
 
     // lower duid value
-    boost::algorithm::to_lower(config);
     CfgMgr::instance().setFamily(AF_INET);
     CfgHostsSubnet cfg_subnet(cfg_hosts, SubnetID(10));
     runToElementTest<CfgHostsSubnet>("[" + config + "]", cfg_subnet);
index bfdebaef255c48186c7c8dc87a5047afac75a8e5..3854dc46dfc45e4744f6d116c48a6df201a28347 100644 (file)
@@ -60,6 +60,7 @@ TEST_F(IfacesConfigParserTest, interfaces) {
     // Parse the configuration.
     IfacesConfigParser parser(AF_INET);
     CfgIfacePtr cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface();
+    ASSERT_TRUE(cfg_iface);
     ASSERT_NO_THROW(parser.parse(cfg_iface, config_element));
 
     // Check it can be unparsed.
@@ -84,6 +85,7 @@ TEST_F(IfacesConfigParserTest, interfaces) {
     config_element = Element::fromJSON(config);
 
     cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface();
+    ASSERT_TRUE(cfg_iface);
     ASSERT_NO_THROW(parser.parse(cfg_iface, config_element));
 
     runToElementTest<CfgIface>(config, *cfg_iface);
@@ -137,6 +139,7 @@ TEST_F(IfacesConfigParserTest, socketTypeDatagram) {
     // Parse the configuration.
     IfacesConfigParser parser(AF_INET);
     CfgIfacePtr cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface();
+    ASSERT_TRUE(cfg_iface);
     ASSERT_NO_THROW(parser.parse(cfg_iface, config_element));
 
     // Check it can be unparsed.
@@ -147,6 +150,7 @@ TEST_F(IfacesConfigParserTest, socketTypeDatagram) {
     SrvConfigPtr cfg = CfgMgr::instance().getStagingCfg();
     ASSERT_TRUE(cfg);
     cfg_ref.useSocketType(AF_INET, CfgIface::SOCKET_UDP);
+    ASSERT_TRUE(cfg->getCfgIface());
     EXPECT_TRUE(*cfg->getCfgIface() == cfg_ref);
 }