]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#981] Addressed review comments
authorThomas Markwalder <tmark@isc.org>
Mon, 27 Jan 2020 17:44:22 +0000 (12:44 -0500)
committerThomas Markwalder <tmark@isc.org>
Mon, 27 Jan 2020 17:57:29 +0000 (12:57 -0500)
Minor clean ups

src/lib/dhcpsrv/tests/srv_config_unittest.cc
    TEST_F(SrvConfigTest, getDdnsParamsNoSubnetTest4)
    TEST_F(SrvConfigTest, getDdnsParamsNoSubnetTest6)
    - new unit tests

src/lib/dhcpsrv/d2_client_cfg.cc
src/lib/dhcpsrv/d2_client_cfg.h
src/lib/dhcpsrv/srv_config.h
src/lib/dhcpsrv/tests/srv_config_unittest.cc

index c584295d97a3400d55b8b2174698b586bb36c35d..78d7ffd75c96290a31bec1c71aa51f54d0bc9c6d 100644 (file)
@@ -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 <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/dhcpsrv_log.h>
 
-#include <boost/algorithm/string/predicate.hpp>
-
 #include <string>
 
 using namespace std;
index f1f33eedfabe7e5958e1919f9ae715029f09e107..98c77a515e09e936737ca7251c71fbdfd5aa5219 100644 (file)
@@ -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 <cc/user_context.h>
 #include <dhcp_ddns/ncr_io.h>
 #include <exceptions/exceptions.h>
-#include <util/strutil.h>
 #include <util/optional.h>
 
 #include <boost/shared_ptr.hpp>
index 2d11c43399d0155b90aa0ab3ee257aba8bb6a347..efbe06aebf77e5c8ace76a19a2a00a0b78a0098f 100644 (file)
@@ -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 <cc/data.h>
 #include <cc/user_context.h>
 #include <cc/simple_parser.h>
+#include <util/strutil.h>
+
 #include <boost/shared_ptr.hpp>
 #include <vector>
 #include <stdint.h>
index 534c4cc493d0b3984a7a7c9b97e0f3eff7542cba..fa17dfc81f067834a505d2c56c654d31b43c3aa2 100644 (file)
@@ -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