Browse Source

[1976] Register for the remote config

Michal 'vorner' Vaner 13 years ago
parent
commit
0e5ceb2ea0

+ 5 - 1
src/bin/auth/datasrc_configurator.h

@@ -82,6 +82,7 @@ public:
         }
         }
         server_ = server;
         server_ = server;
         session_ = session;
         session_ = session;
+        session->addRemoteConfig("data_sources", reconfigureInternal, false);
     }
     }
     /// \brief Deinitializes the class.
     /// \brief Deinitializes the class.
     ///
     ///
@@ -91,6 +92,9 @@ public:
     /// This can be called even if it is not initialized currently. You
     /// This can be called even if it is not initialized currently. You
     /// can initialize it again after this.
     /// can initialize it again after this.
     static void deinit() {
     static void deinit() {
+        if (session_ != NULL) {
+            session_->removeRemoteConfig("data_sources");
+        }
         session_ = NULL;
         session_ = NULL;
         server_ = NULL;
         server_ = NULL;
     }
     }
@@ -104,7 +108,7 @@ public:
     /// \param config The configuration value to parse. It is in the form
     /// \param config The configuration value to parse. It is in the form
     ///     as an update from the config manager.
     ///     as an update from the config manager.
     /// \throw InvalidOperation if it is called when not initialized.
     /// \throw InvalidOperation if it is called when not initialized.
-    static void reconfigure(const isc::data::ConstElementPtr& config) {
+    static void reconfigure(const isc::data::ConstElementPtr& ) {
 
 
     }
     }
 };
 };

+ 1 - 0
src/bin/auth/tests/Makefile.am

@@ -7,6 +7,7 @@ AM_CPPFLAGS += -DAUTH_OBJ_DIR=\"$(abs_top_builddir)/src/bin/auth\"
 AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(abs_top_srcdir)/src/lib/testutils/testdata\"
 AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(abs_top_srcdir)/src/lib/testutils/testdata\"
 AM_CPPFLAGS += -DTEST_OWN_DATA_DIR=\"$(abs_top_srcdir)/src/bin/auth/tests/testdata\"
 AM_CPPFLAGS += -DTEST_OWN_DATA_DIR=\"$(abs_top_srcdir)/src/bin/auth/tests/testdata\"
 AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/testutils/testdata\"
 AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/testutils/testdata\"
+AM_CPPFLAGS += -DPLUGIN_DATA_PATH=\"$(abs_top_srcdir)/src/bin/cfgmgr/plugins\"
 AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
 AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
 
 
 AM_CXXFLAGS = $(B10_CXXFLAGS)
 AM_CXXFLAGS = $(B10_CXXFLAGS)

+ 17 - 3
src/bin/auth/tests/datasrc_configurator_unittest.cc

@@ -57,7 +57,18 @@ protected:
         // Make sure no matter what we did, it is cleaned up.
         // Make sure no matter what we did, it is cleaned up.
         Configurator::deinit();
         Configurator::deinit();
     }
     }
-    void init() {
+    void init(const ElementPtr& config = ElementPtr()) {
+        session.getMessages()->
+            add(createAnswer(0,
+                             moduleSpecFromFile(string(PLUGIN_DATA_PATH) +
+                                                "/datasrc.spec").
+                             getFullSpec()));
+        if (config) {
+            session.getMessages()->add(createAnswer(0, config));
+        } else {
+            session.getMessages()->
+                add(createAnswer(0, ElementPtr(new MapElement)));
+        }
         Configurator::init(mccs.get(), this);
         Configurator::init(mccs.get(), this);
     }
     }
     void SetUp() {
     void SetUp() {
@@ -72,15 +83,18 @@ protected:
 TEST_F(DatasrcConfiguratorTest, initialization) {
 TEST_F(DatasrcConfiguratorTest, initialization) {
     // It can't be initialized again
     // It can't be initialized again
     EXPECT_THROW(init(), InvalidOperation);
     EXPECT_THROW(init(), InvalidOperation);
+    EXPECT_TRUE(session.haveSubscription("data_sources", "*"));
     // Deinitialize to make the tests reasonable
     // Deinitialize to make the tests reasonable
     Configurator::deinit();
     Configurator::deinit();
-    // Make sure there are enough messages in it, etc.
-    initSession();
+    EXPECT_FALSE(session.haveSubscription("data_sources", "*"));
     // If one of them is NULL, it does not work
     // If one of them is NULL, it does not work
     EXPECT_THROW(Configurator::init(NULL, this), InvalidParameter);
     EXPECT_THROW(Configurator::init(NULL, this), InvalidParameter);
+    EXPECT_FALSE(session.haveSubscription("data_sources", "*"));
     EXPECT_THROW(Configurator::init(mccs.get(), NULL), InvalidParameter);
     EXPECT_THROW(Configurator::init(mccs.get(), NULL), InvalidParameter);
+    EXPECT_FALSE(session.haveSubscription("data_sources", "*"));
     // But we can initialize it again now
     // But we can initialize it again now
     EXPECT_NO_THROW(init());
     EXPECT_NO_THROW(init());
+    EXPECT_TRUE(session.haveSubscription("data_sources", "*"));
 }
 }
 
 
 }
 }