From 0e5ceb2ea0871dfd07db2eb8548ba7454df0fa02 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Wed, 20 Jun 2012 18:00:53 +0200 Subject: [PATCH] [1976] Register for the remote config --- src/bin/auth/datasrc_configurator.h | 6 +++++- src/bin/auth/tests/Makefile.am | 1 + .../tests/datasrc_configurator_unittest.cc | 20 ++++++++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/bin/auth/datasrc_configurator.h b/src/bin/auth/datasrc_configurator.h index d5ba5295c6..40eb9ffc1a 100644 --- a/src/bin/auth/datasrc_configurator.h +++ b/src/bin/auth/datasrc_configurator.h @@ -82,6 +82,7 @@ public: } server_ = server; session_ = session; + session->addRemoteConfig("data_sources", reconfigureInternal, false); } /// \brief Deinitializes the class. /// @@ -91,6 +92,9 @@ public: /// This can be called even if it is not initialized currently. You /// can initialize it again after this. static void deinit() { + if (session_ != NULL) { + session_->removeRemoteConfig("data_sources"); + } session_ = NULL; server_ = NULL; } @@ -104,7 +108,7 @@ public: /// \param config The configuration value to parse. It is in the form /// as an update from the config manager. /// \throw InvalidOperation if it is called when not initialized. - static void reconfigure(const isc::data::ConstElementPtr& config) { + static void reconfigure(const isc::data::ConstElementPtr& ) { } }; diff --git a/src/bin/auth/tests/Makefile.am b/src/bin/auth/tests/Makefile.am index bdb5eaa082..52fc5e73de 100644 --- a/src/bin/auth/tests/Makefile.am +++ b/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_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 += -DPLUGIN_DATA_PATH=\"$(abs_top_srcdir)/src/bin/cfgmgr/plugins\" AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\" AM_CXXFLAGS = $(B10_CXXFLAGS) diff --git a/src/bin/auth/tests/datasrc_configurator_unittest.cc b/src/bin/auth/tests/datasrc_configurator_unittest.cc index 032b603fe6..107049a2dd 100644 --- a/src/bin/auth/tests/datasrc_configurator_unittest.cc +++ b/src/bin/auth/tests/datasrc_configurator_unittest.cc @@ -57,7 +57,18 @@ protected: // Make sure no matter what we did, it is cleaned up. 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); } void SetUp() { @@ -72,15 +83,18 @@ protected: TEST_F(DatasrcConfiguratorTest, initialization) { // It can't be initialized again EXPECT_THROW(init(), InvalidOperation); + EXPECT_TRUE(session.haveSubscription("data_sources", "*")); // Deinitialize to make the tests reasonable 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 EXPECT_THROW(Configurator::init(NULL, this), InvalidParameter); + EXPECT_FALSE(session.haveSubscription("data_sources", "*")); EXPECT_THROW(Configurator::init(mccs.get(), NULL), InvalidParameter); + EXPECT_FALSE(session.haveSubscription("data_sources", "*")); // But we can initialize it again now EXPECT_NO_THROW(init()); + EXPECT_TRUE(session.haveSubscription("data_sources", "*")); } } -- 2.47.3