Commit 4289cec8 authored by Thomas Markwalder's avatar Thomas Markwalder
Browse files

[3282] Addes support for full parsing of disable dhcp-ddns entry

D2CLientConfigParser now supports parsing all parameters even if
enable-updates is false.  This allows values like generated-prefix
and qualifying-suffix to be used even if udpates are turned off.
The parser still supports an abbreviated dhcp-ddns entry that has only
enable-updates defined as false.
parent 8534089c
......@@ -1182,10 +1182,11 @@ D2ClientConfigParser::build(isc::data::ConstElementPtr client_config) {
}
bool enable_updates = boolean_values_->getParam("enable-updates");
if (!enable_updates) {
// If it's not enabled, don't bother validating the rest. This
// allows for an abbreviated config entry that only contains
// the flag. The default constructor creates a disabled instance.
if (!enable_updates && (client_config->mapValue().size() == 1)) {
// If enable-updates is the only parameter and it is false then
// we're done. This allows for an abbreviated configuration entry
// that only contains that flag. Use the default D2ClientConfig
// constructor to a create a disabled instance.
local_client_config_.reset(new D2ClientConfig());
return;
}
......
......@@ -755,12 +755,12 @@ TEST_F(ParseConfigTest, validD2Config) {
EXPECT_EQ("test.suffix.", d2_client_config->getQualifyingSuffix());
// Another valid Configuration string.
// This one has IPV6 server ip, control flags false,
// This one is disabled, has IPV6 server ip, control flags false,
// empty prefix/suffix
std::string config_str2 =
"{ \"dhcp-ddns\" :"
" {"
" \"enable-updates\" : true, "
" \"enable-updates\" : false, "
" \"server-ip\" : \"2001:db8::\", "
" \"server-port\" : 43567, "
" \"ncr-protocol\" : \"UDP\", "
......@@ -779,13 +779,13 @@ TEST_F(ParseConfigTest, validD2Config) {
rcode = parseConfiguration(config_str2);
ASSERT_TRUE(rcode == 0) << error_text_;
// Verify that DHCP-DDNS is enabled and we can fetch the configuration.
EXPECT_TRUE(CfgMgr::instance().ddnsEnabled());
// Verify that DHCP-DDNS is disabled and we can fetch the configuration.
EXPECT_FALSE(CfgMgr::instance().ddnsEnabled());
ASSERT_NO_THROW(d2_client_config = CfgMgr::instance().getD2ClientConfig());
ASSERT_TRUE(d2_client_config);
// Verify that the configuration values are as expected.
EXPECT_TRUE(d2_client_config->getEnableUpdates());
EXPECT_FALSE(d2_client_config->getEnableUpdates());
EXPECT_EQ("2001:db8::", d2_client_config->getServerIp().toText());
EXPECT_EQ(43567, d2_client_config->getServerPort());
EXPECT_EQ(dhcp_ddns::NCR_UDP, d2_client_config->getNcrProtocol());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment