From: Francis Dupont Date: Mon, 16 Oct 2017 13:55:58 +0000 (+0200) Subject: [5297] Other comments and tests X-Git-Tag: Kea-1.3.0~2^2~1^2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=56a001d48b28a75bb178419889fbb5ccf60ca8d8;p=thirdparty%2Fkea.git [5297] Other comments and tests --- diff --git a/src/lib/dhcpsrv/parsers/client_class_def_parser.cc b/src/lib/dhcpsrv/parsers/client_class_def_parser.cc index 9d6eba7613..5829393342 100644 --- a/src/lib/dhcpsrv/parsers/client_class_def_parser.cc +++ b/src/lib/dhcpsrv/parsers/client_class_def_parser.cc @@ -112,6 +112,7 @@ ClientClassDefParser::parse(ClientClassDictionaryPtr& class_dictionary, try { defs->add(def.first, def.second); } catch (const std::exception& ex) { + // Sanity check: it should never happen isc_throw(DhcpConfigError, ex.what() << " (" << option_def->getPosition() << ")"); } diff --git a/src/lib/dhcpsrv/parsers/shared_network_parser.cc b/src/lib/dhcpsrv/parsers/shared_network_parser.cc index 0dc74cbbfc..8a3cb14b31 100644 --- a/src/lib/dhcpsrv/parsers/shared_network_parser.cc +++ b/src/lib/dhcpsrv/parsers/shared_network_parser.cc @@ -70,6 +70,9 @@ SharedNetwork4Parser::parse(const data::ConstElementPtr& shared_network_data) { } } + } catch (const DhcpConfigError&) { + // Position was already added + throw; } catch (const std::exception& ex) { isc_throw(DhcpConfigError, ex.what() << " (" << shared_network_data->getPosition() << ")"); diff --git a/src/lib/dhcpsrv/tests/d2_client_unittest.cc b/src/lib/dhcpsrv/tests/d2_client_unittest.cc index a85cf0a8e5..8bf3d4a86f 100644 --- a/src/lib/dhcpsrv/tests/d2_client_unittest.cc +++ b/src/lib/dhcpsrv/tests/d2_client_unittest.cc @@ -370,6 +370,42 @@ TEST(D2ClientMgr, validConfig) { EXPECT_NE(*original_config, *updated_config); } +/// @brief Checks passing the D2ClientMgr a valid D2 client configuration +/// using IPv6 service. +TEST(D2ClientMgr, ipv6Config) { + D2ClientMgrPtr d2_client_mgr; + + // Construct the manager and fetch its initial configuration. + ASSERT_NO_THROW(d2_client_mgr.reset(new D2ClientMgr())); + D2ClientConfigPtr original_config = d2_client_mgr->getD2ClientConfig(); + ASSERT_TRUE(original_config); + + // Create a new, enabled config. + D2ClientConfigPtr new_cfg; + ASSERT_NO_THROW(new_cfg.reset(new D2ClientConfig(true, + isc::asiolink::IOAddress("::1"), 477, + isc::asiolink::IOAddress("::1"), 478, + 1024, + dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON, + true, true, true, D2ClientConfig::RCM_WHEN_PRESENT, + "pre-fix", "suf-fix"))); + + // Verify that we can assign a new, non-empty configuration. + ASSERT_NO_THROW(d2_client_mgr->setD2ClientConfig(new_cfg)); + + // Verify that we can fetch the newly assigned configuration. + D2ClientConfigPtr updated_config = d2_client_mgr->getD2ClientConfig(); + ASSERT_TRUE(updated_config); + EXPECT_TRUE(updated_config->getEnableUpdates()); + + // Make sure convenience method agrees with the updated configuration. + EXPECT_TRUE(d2_client_mgr->ddnsEnabled()); + + // Make sure the configuration we fetched is the one we assigned, + // and not the original configuration. + EXPECT_EQ(*new_cfg, *updated_config); + EXPECT_NE(*original_config, *updated_config); +} /// @brief Tests that analyzeFqdn detects invalid combination of both the /// client S and N flags set to true.