]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3282] Added D2ClientMgr accessor to CfgMgr
authorThomas Markwalder <tmark@isc.org>
Mon, 20 Jan 2014 15:26:49 +0000 (10:26 -0500)
committerThomas Markwalder <tmark@isc.org>
Mon, 20 Jan 2014 15:26:49 +0000 (10:26 -0500)
Added an accessor to CfgMgr to return a reference to the singlton's
D2ClientMgr instance.

src/lib/dhcpsrv/cfgmgr.cc
src/lib/dhcpsrv/cfgmgr.h
src/lib/dhcpsrv/tests/cfgmgr_unittest.cc

index 6f008f17999acafd7add647d6933888f6ec899ef..b9e48c6e51f1d5b88133a53f33d58f9c28397393 100644 (file)
@@ -363,6 +363,12 @@ CfgMgr::getD2ClientConfig() const {
     return (d2_client_mgr_.getD2ClientConfig());
 }
 
+D2ClientMgr&
+CfgMgr::getD2ClientMgr() {
+    return (d2_client_mgr_);
+}
+
+
 
 CfgMgr::CfgMgr()
     : datadir_(DHCP_DATA_DIR),
index fcec8bfc28447e6e89d6c149d5399149bd16364b..086782604549248713bf3d919c29f480ee3664ca 100644 (file)
@@ -341,7 +341,7 @@ public:
     /// pointer.
     void setD2ClientConfig(D2ClientConfigPtr& new_config);
 
-    /// @param Convenience method for checking if DHCP-DDNS updates are enabled.
+    /// @brief Convenience method for checking if DHCP-DDNS updates are enabled.
     ///
     /// @return True if the D2 configuration is enabled.
     bool ddnsEnabled();
@@ -351,6 +351,11 @@ public:
     /// @return a reference to the current configuration pointer.
     const D2ClientConfigPtr& getD2ClientConfig() const;
 
+    /// @brief Fetches the DHCP-DDNS manager.
+    ///
+    /// @return a reference to the DHCP-DDNS manager.
+    D2ClientMgr& getD2ClientMgr();
+
 protected:
 
     /// @brief Protected constructor.
index 8c3d2eace89338fb602ef9d95a2563f5ab3e2033..4a0ccc447f4d967abd6877d7cbfbda48b5cc05ba 100644 (file)
@@ -672,15 +672,17 @@ TEST_F(CfgMgrTest, echoClientId) {
 
 // This test checks the D2ClientMgr wrapper methods.
 TEST_F(CfgMgrTest, d2ClientConfig) {
-    // After CfgMgr construction, D2 configuration should be disabled.
-    // Fetch it and verify this is the case.
+    // After CfgMgr construction, D2ClientMgr member should be initialized
+    // with a D2 configuration that is disabled.
+    // Verify we can Fetch the mgr.
+    D2ClientMgr d2_mgr = CfgMgr::instance().getD2ClientMgr();
+    EXPECT_FALSE(d2_mgr.ddnsEnabled());
+
+    // Make sure the convenience method fetches the config correctly.
     D2ClientConfigPtr original_config = CfgMgr::instance().getD2ClientConfig();
     ASSERT_TRUE(original_config);
     EXPECT_FALSE(original_config->getEnableUpdates());
 
-    // Make sure convenience method agrees.
-    EXPECT_FALSE(CfgMgr::instance().ddnsEnabled());
-
     // Verify that we cannot set the configuration to an empty pointer.
     D2ClientConfigPtr new_cfg;
     ASSERT_THROW(CfgMgr::instance().setD2ClientConfig(new_cfg), D2ClientError);