From: Thomas Markwalder Date: Mon, 27 Jan 2020 17:44:22 +0000 (-0500) Subject: [#981] Addressed review comments X-Git-Tag: Kea-1.7.4~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7bc3b87f9f35b2f04776d7deaebb2064e03f6fea;p=thirdparty%2Fkea.git [#981] Addressed review comments Minor clean ups src/lib/dhcpsrv/tests/srv_config_unittest.cc TEST_F(SrvConfigTest, getDdnsParamsNoSubnetTest4) TEST_F(SrvConfigTest, getDdnsParamsNoSubnetTest6) - new unit tests --- diff --git a/src/lib/dhcpsrv/d2_client_cfg.cc b/src/lib/dhcpsrv/d2_client_cfg.cc index c584295d97..78d7ffd75c 100644 --- a/src/lib/dhcpsrv/d2_client_cfg.cc +++ b/src/lib/dhcpsrv/d2_client_cfg.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,8 +11,6 @@ #include #include -#include - #include using namespace std; diff --git a/src/lib/dhcpsrv/d2_client_cfg.h b/src/lib/dhcpsrv/d2_client_cfg.h index f1f33eedfa..98c77a515e 100644 --- a/src/lib/dhcpsrv/d2_client_cfg.h +++ b/src/lib/dhcpsrv/d2_client_cfg.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -17,7 +17,6 @@ #include #include #include -#include #include #include diff --git a/src/lib/dhcpsrv/srv_config.h b/src/lib/dhcpsrv/srv_config.h index 2d11c43399..efbe06aebf 100644 --- a/src/lib/dhcpsrv/srv_config.h +++ b/src/lib/dhcpsrv/srv_config.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -29,6 +29,8 @@ #include #include #include +#include + #include #include #include diff --git a/src/lib/dhcpsrv/tests/srv_config_unittest.cc b/src/lib/dhcpsrv/tests/srv_config_unittest.cc index 534c4cc493..fa17dfc81f 100644 --- a/src/lib/dhcpsrv/tests/srv_config_unittest.cc +++ b/src/lib/dhcpsrv/tests/srv_config_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -1377,12 +1377,49 @@ TEST_F(SrvConfigTest, getDdnsParamsTest4) { EXPECT_TRUE(params->getEnableUpdates()); } +// Verifies that the fallback values for DDNS parameters when +// no Subnet4 has been selected. In theory, we should never want +// these values without a selected subnet. +TEST_F(SrvConfigTest, getDdnsParamsNoSubnetTest4) { + DdnsParamsPtr params; + + CfgMgr::instance().setFamily(AF_INET); + SrvConfig conf(32); + + // Enable D2 connectivity. + enableD2Client(true); + + // Give all of the parameters a global value. + conf.addConfiguredGlobal("ddns-send-updates", Element::create(true)); + conf.addConfiguredGlobal("ddns-override-no-update", Element::create(true)); + conf.addConfiguredGlobal("ddns-override-client-update", Element::create(true)); + conf.addConfiguredGlobal("ddns-replace-client-name", Element::create("always")); + conf.addConfiguredGlobal("ddns-generated-prefix", Element::create("some_prefix")); + conf.addConfiguredGlobal("ddns-qualifying-suffix", Element::create("example.com")); + conf.addConfiguredGlobal("hostname-char-set", Element::create("[^A-Z]")); + conf.addConfiguredGlobal("hostname-char-replacement", Element::create("x")); + + // Get DDNS params for no subnet. + Subnet4Ptr subnet4; + ASSERT_NO_THROW(params = conf_.getDdnsParams(subnet4)); + + // Verify fallback values are right. Note, updates should be disabled. + EXPECT_FALSE(params->getEnableUpdates()); + EXPECT_FALSE(params->getOverrideNoUpdate()); + EXPECT_FALSE(params->getOverrideClientUpdate()); + EXPECT_EQ(D2ClientConfig::RCM_NEVER, params->getReplaceClientNameMode()); + EXPECT_TRUE(params->getGeneratedPrefix().empty()); + EXPECT_TRUE(params->getQualifyingSuffix().empty()); + EXPECT_TRUE(params->getHostnameCharSet().empty()); + EXPECT_TRUE(params->getHostnameCharReplacement().empty()); +} + // Verifies that the scoped values for DDNS parameters can be fetched // for a given Subnet6. TEST_F(SrvConfigTest, getDdnsParamsTest6) { DdnsParamsPtr params; - CfgMgr::instance().setFamily(AF_INET); + CfgMgr::instance().setFamily(AF_INET6); SrvConfig conf(32); // This disables D2 connectivity. When it is false, updates @@ -1487,4 +1524,42 @@ TEST_F(SrvConfigTest, getDdnsParamsTest6) { EXPECT_TRUE(params->getEnableUpdates()); } +// Verifies that the fallback values for DDNS parameters when +// no Subnet6 has been selected. In theory, we should never want +// these values without a selected subnet. +TEST_F(SrvConfigTest, getDdnsParamsNoSubnetTest6) { + DdnsParamsPtr params; + + CfgMgr::instance().setFamily(AF_INET6); + SrvConfig conf(32); + + // Enable D2 connectivity. + enableD2Client(true); + + // Give all of the parameters a global value. + conf.addConfiguredGlobal("ddns-send-updates", Element::create(true)); + conf.addConfiguredGlobal("ddns-override-no-update", Element::create(true)); + conf.addConfiguredGlobal("ddns-override-client-update", Element::create(true)); + conf.addConfiguredGlobal("ddns-replace-client-name", Element::create("always")); + conf.addConfiguredGlobal("ddns-generated-prefix", Element::create("some_prefix")); + conf.addConfiguredGlobal("ddns-qualifying-suffix", Element::create("example.com")); + conf.addConfiguredGlobal("hostname-char-set", Element::create("[^A-Z]")); + conf.addConfiguredGlobal("hostname-char-replacement", Element::create("x")); + + // Get DDNS params for no subnet. + Subnet6Ptr subnet6; + ASSERT_NO_THROW(params = conf_.getDdnsParams(subnet6)); + + // Verify fallback values are right. Note, updates should be disabled. + EXPECT_FALSE(params->getEnableUpdates()); + EXPECT_FALSE(params->getOverrideNoUpdate()); + EXPECT_FALSE(params->getOverrideClientUpdate()); + EXPECT_EQ(D2ClientConfig::RCM_NEVER, params->getReplaceClientNameMode()); + EXPECT_TRUE(params->getGeneratedPrefix().empty()); + EXPECT_TRUE(params->getQualifyingSuffix().empty()); + EXPECT_TRUE(params->getHostnameCharSet().empty()); + EXPECT_TRUE(params->getHostnameCharReplacement().empty()); +} + + } // end of anonymous namespace