using namespace isc::hooks;
using namespace isc::dhcp;
+namespace isc {
+namespace hooks {
+
// ******************** HooksLibrariesParser *************************
void
HooksLibrariesParser::parse(ConstElementPtr value) {
HooksLibrariesParser::getLibraries(isc::hooks::HookLibsCollection& libraries) {
libraries = libraries_;
}
+
+}
+}
isc::data::ConstElementPtr
DCfgMgrBase::simpleParseConfig(isc::data::ConstElementPtr config_set,
bool check_only) {
- LOG_DEBUG(dctl_logger, DBGLVL_COMMAND,
- DCTL_CONFIG_START).arg(config_set->str());
-
if (!config_set) {
return (isc::config::createAnswer(1,
std::string("Can't parse NULL config")));
}
+ LOG_DEBUG(dctl_logger, DBGLVL_COMMAND,
+ DCTL_CONFIG_START).arg(config_set->str());
// The parsers implement data inheritance by directly accessing
// configuration context. For this reason the data parsers must store
-// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2017 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
EXPECT_EQ(pos.file_, isc::data::Element::ZERO_POSITION().file_);
}
+// This tests if some aspects of simpleParseConfig are behaving properly.
+// Thorough testing is only possible for specific implementations. This
+// is done for control agent (see CtrlAgentControllerTest tests in
+// src/bin/agent/tests/ctrl_agent_controller_unittest.cc for example).
+// Also, shell tests in src/bin/agent/ctrl_agent_process_tests.sh test
+// the whole CA process that uses simpleParseConfig. The alternative
+// would be to implement whole parser that would set the context
+// properly. The ROI for this is not worth the effort.
+TEST_F(DStubCfgMgrTest, simpleParseConfig) {
+ using namespace isc::data;
+
+ // Passing just null pointer should result in error return code
+ answer_ = cfg_mgr_->simpleParseConfig(ConstElementPtr(), false);
+ EXPECT_TRUE(checkAnswer(1));
+
+ // Ok, now try with a dummy, but valid json code
+ string config = "{ \"bool_test\": true , \n"
+ " \"uint32_test\": 77 , \n"
+ " \"string_test\": \"hmmm chewy\" }";
+ ASSERT_NO_THROW(fromJSON(config));
+
+ answer_ = cfg_mgr_->simpleParseConfig(config_set_, false);
+ EXPECT_TRUE(checkAnswer(0));
+}
+
} // end of anonymous namespace
#include <process/d_log.h>
#include <process/spec_config.h>
#include <process/testutils/d_test_stubs.h>
+#include <cc/command_interpreter.h>
using namespace boost::asio;
return (parser);
}
+isc::data::ConstElementPtr
+DStubCfgMgr::parse(isc::data::ConstElementPtr /*config*/, bool /*check_only*/) {
+ return (isc::config::createAnswer(0, "It all went fine. I promise"));
+}
+
}; // namespace isc::process
}; // namespace isc
const isc::data::Element::Position& pos
= isc::data::Element::Position());
+ /// @brief Pretends to parse the config
+ ///
+ /// This method pretends to parse the configuration specified on input
+ /// and returns a positive answer. The check_only flag is currently ignored.
+ ///
+ /// @param config configuration specified
+ /// @param check_only whether it's real configuration (false) or just
+ /// configuration check (true)
+ /// @return always positive answer
+ ///
+ isc::data::ConstElementPtr
+ parse(isc::data::ConstElementPtr config, bool check_only);
+
/// @brief Returns a summary of the configuration in the textual format.
///
/// @return Always an empty string.