}
CtrlAgentCfgContext::CtrlAgentCfgContext(const CtrlAgentCfgContext& orig)
- : DCfgContextBase(),http_host_(orig.http_host_), http_port_(orig.http_port_),
+ : DCfgContextBase(), ctrl_sockets_(orig.ctrl_sockets_),
+ http_host_(orig.http_host_), http_port_(orig.http_port_),
hooks_config_(orig.hooks_config_) {
-
- // We're copying pointers here only. The underlying data will be shared by
- // old and new context. That's how shared pointers work and I see no reason
- // why it would be different in this particular here.
- ctrl_sockets_[TYPE_D2] = orig.ctrl_sockets_[TYPE_D2];
- ctrl_sockets_[TYPE_DHCP4] = orig.ctrl_sockets_[TYPE_DHCP4];
- ctrl_sockets_[TYPE_DHCP6] = orig.ctrl_sockets_[TYPE_DHCP6];
-}
-
-CtrlAgentCfgContext::ServerType
-CtrlAgentCfgContext::toServerType(const std::string& service) {
- if (service == "dhcp4") {
- return (CtrlAgentCfgContext::TYPE_DHCP4);
-
- } else if (service == "dhcp6") {
- return (CtrlAgentCfgContext::TYPE_DHCP6);
-
- } else if (service == "d2") {
- return (CtrlAgentCfgContext::TYPE_D2);
- }
-
- isc_throw(isc::BadValue, "invalid service value " << service);
}
CtrlAgentCfgMgr::CtrlAgentCfgMgr()
<< ctx->getHttpPort() << ", control sockets: ";
// Then print the control-sockets
- bool socks = false;
- if (ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2)) {
- s << "d2 ";
- socks = true;
- }
- if (ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4)) {
- s << "dhcp4 ";
- socks = true;
- }
- if (ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6)) {
- s << "dhcp6 ";
- socks = true;
- }
- if (!socks) {
- // That's uncommon, but correct scenario. CA can respond to some
- // commands on its own. Further down the road we will possibly get the
- // capability to tell CA to start other servers.
- s << "none";
- }
+ s << ctx->getControlSocketInfoSummary();
// Finally, print the hook libraries names
const isc::hooks::HookLibsCollection libs = ctx->getHooksConfig().get();
return (answer);
}
-const data::ConstElementPtr
-CtrlAgentCfgContext::getControlSocketInfo(ServerType type) const {
- if (type > MAX_TYPE_SUPPORTED) {
- isc_throw(BadValue, "Invalid server type");
- }
- return (ctrl_sockets_[static_cast<uint8_t>(type)]);
+data::ConstElementPtr
+CtrlAgentCfgContext::getControlSocketInfo(const std::string& service) const {
+ auto si = ctrl_sockets_.find(service);
+ return ((si != ctrl_sockets_.end()) ? si->second : ConstElementPtr());
}
void
CtrlAgentCfgContext::setControlSocketInfo(const isc::data::ConstElementPtr& control_socket,
- ServerType type) {
- if (type > MAX_TYPE_SUPPORTED) {
- isc_throw(BadValue, "Invalid server type");
+ const std::string& service) {
+ ctrl_sockets_[service] = control_socket;
+}
+
+std::string
+CtrlAgentCfgContext::getControlSocketInfoSummary() const {
+ std::ostringstream s;
+ for (auto si = ctrl_sockets_.cbegin(); si != ctrl_sockets_.end(); ++si) {
+ if (s.tellp() != 0) {
+ s << " ";
+ }
+ s << si->first;
+ }
+
+ if (s.tellp() == 0) {
+ s << "none";
}
- ctrl_sockets_[static_cast<uint8_t>(type)] = control_socket;
+
+ return (s.str());
}
ElementPtr
ca->set("hooks-libraries", hooks_config_.toElement());
// Set control-sockets
ElementPtr control_sockets = Element::createMap();
- // Set dhcp4 server socket
- if (ctrl_sockets_[TYPE_DHCP4]) {
- control_sockets->set("dhcp4", ctrl_sockets_[TYPE_DHCP4]);
- }
- // Set dhcp6 server socket
- if (ctrl_sockets_[TYPE_DHCP6]) {
- control_sockets->set("dhcp6", ctrl_sockets_[TYPE_DHCP6]);
- }
- // Set d2 server socket
- if (ctrl_sockets_[TYPE_D2]) {
- control_sockets->set("d2", ctrl_sockets_[TYPE_D2]);
+ for (auto si = ctrl_sockets_.cbegin(); si != ctrl_sockets_.cend(); ++si) {
+ control_sockets->set(si->first, si->second);
}
ca->set("control-sockets", control_sockets);
// Set Control-agent
#include <hooks/hooks_config.h>
#include <process/d_cfg_mgr.h>
#include <boost/pointer_cast.hpp>
+#include <map>
#include <string>
namespace isc {
/// @brief Default constructor
CtrlAgentCfgContext();
- /// @brief Specifies type of the server being controlled.
- enum ServerType {
- TYPE_DHCP4 = 0, ///< kea-dhcp4
- TYPE_DHCP6 = 1, ///< kea-dhcp6
- TYPE_D2 = 2 ///< kea-dhcp-ddns
- };
-
- /// @brief Used check that specified ServerType is within valid range.
- static const uint32_t MAX_TYPE_SUPPORTED = TYPE_D2;
-
- /// @brief Converts service specified as a string to ServerType.
- ///
- /// @param service Service value as a string: 'dhcp4', 'dhcp6', 'd2'.
- static ServerType toServerType(const std::string& service);
-
/// @brief Creates a clone of this context object.
///
/// Note this method does not do deep copy the information about control sockets.
/// server type). This information is expected to be compatible with
/// data passed to @ref isc::config::CommandMgr::openCommandSocket.
///
- /// @param type type of the server being controlled
+ /// @param service server being controlled
/// @return pointer to the Element that holds control-socket map (or NULL)
- const isc::data::ConstElementPtr getControlSocketInfo(ServerType type) const;
+ isc::data::ConstElementPtr
+ getControlSocketInfo(const std::string& service) const;
/// @brief Sets information about the control socket
///
/// data passed to @ref isc::config::CommandMgr::openCommandSocket.
///
/// @param control_socket Element that holds control-socket map
- /// @param type type of the server being controlled
+ /// @param service server being controlled
void setControlSocketInfo(const isc::data::ConstElementPtr& control_socket,
- ServerType type);
+ const std::string& service);
+
+ /// @brief Returns socket configuration summary in a textual format.
+ std::string getControlSocketInfoSummary() const;
/// @brief Sets http-host parameter
///
CtrlAgentCfgContext& operator=(const CtrlAgentCfgContext& rhs);
/// Socket information will be stored here (for all supported servers)
- isc::data::ConstElementPtr ctrl_sockets_[MAX_TYPE_SUPPORTED + 1];
+ std::map<std::string, isc::data::ConstElementPtr> ctrl_sockets_;
/// Hostname the CA should listen on.
std::string http_host_;
" Control Agent configuration information");
}
- // Convert the service to the server type values. Make sure the client
- // provided right value.
- CtrlAgentCfgContext::ServerType server_type;
- try {
- server_type = CtrlAgentCfgContext::toServerType(service);
-
- } catch (const std::exception& ex) {
- // Invalid value in service list. Can't proceed.
- isc_throw(CommandForwardingError, ex.what());
- }
-
// Now that we know what service it should be forwarded to, we should
// find a matching forwarding socket. If this socket is not configured,
// we have to communicate it to the client.
- ConstElementPtr socket_info = ctx->getControlSocketInfo(server_type);
+ ConstElementPtr socket_info = ctx->getControlSocketInfo(service);
if (!socket_info) {
isc_throw(CommandForwardingError, "forwarding socket is not configured"
" for the server type " << service);
// Control sockets are second.
ConstElementPtr ctrl_sockets = config->get("control-sockets");
if (ctrl_sockets) {
- ConstElementPtr d2_socket = ctrl_sockets->get("d2");
- ConstElementPtr d4_socket = ctrl_sockets->get("dhcp4");
- ConstElementPtr d6_socket = ctrl_sockets->get("dhcp6");
-
- if (d2_socket) {
- ctx->setControlSocketInfo(d2_socket, CtrlAgentCfgContext::TYPE_D2);
- }
-
- if (d4_socket) {
- ctx->setControlSocketInfo(d4_socket, CtrlAgentCfgContext::TYPE_DHCP4);
- }
-
- if (d6_socket) {
- ctx->setControlSocketInfo(d6_socket, CtrlAgentCfgContext::TYPE_DHCP6);
+ auto sockets_map = ctrl_sockets->mapValue();
+ for (auto cs = sockets_map.cbegin(); cs != sockets_map.cend(); ++cs) {
+ ctx->setControlSocketInfo(cs->second, cs->first);
}
}
using CtrlAgentCfgMgr::parse;
};
-// Tests conversion of the 'service' parameter to ServerType.
-TEST(CtrlAgentCfgContextTest, toServerType) {
- EXPECT_EQ(CtrlAgentCfgContext::TYPE_DHCP4,
- CtrlAgentCfgContext::toServerType("dhcp4"));
- EXPECT_EQ(CtrlAgentCfgContext::TYPE_DHCP6,
- CtrlAgentCfgContext::toServerType("dhcp6"));
- EXPECT_EQ(CtrlAgentCfgContext::TYPE_D2,
- CtrlAgentCfgContext::toServerType("d2"));
- EXPECT_THROW(CtrlAgentCfgContext::toServerType("other"),
- isc::BadValue);
-}
-
// Tests construction of CtrlAgentCfgMgr class.
TEST(CtrlAgentCfgMgr, construction) {
boost::scoped_ptr<CtrlAgentCfgMgr> cfg_mgr;
// Check control socket parameters
// By default, there are no control sockets stored.
- EXPECT_FALSE(ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2));
- EXPECT_FALSE(ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4));
- EXPECT_FALSE(ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6));
+ EXPECT_FALSE(ctx.getControlSocketInfo("d2"));
+ EXPECT_FALSE(ctx.getControlSocketInfo("dhcp4"));
+ EXPECT_FALSE(ctx.getControlSocketInfo("dhcp6"));
ConstElementPtr socket1 = Element::fromJSON("{ \"socket-type\": \"unix\",\n"
" \"socket-name\": \"socket1\" }");
ConstElementPtr socket3 = Element::fromJSON("{ \"socket-type\": \"unix\",\n"
" \"socket-name\": \"socket3\" }");
// Ok, now set the control socket for D2
- EXPECT_NO_THROW(ctx.setControlSocketInfo(socket1, CtrlAgentCfgContext::TYPE_D2));
+ EXPECT_NO_THROW(ctx.setControlSocketInfo(socket1, "d2"));
// Now check the values returned
- EXPECT_EQ(socket1, ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2));
- EXPECT_FALSE(ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4));
- EXPECT_FALSE(ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6));
+ EXPECT_EQ(socket1, ctx.getControlSocketInfo("d2"));
+ EXPECT_FALSE(ctx.getControlSocketInfo("dhcp4"));
+ EXPECT_FALSE(ctx.getControlSocketInfo("dhcp6"));
// Now set the v6 socket and sanity check again
- EXPECT_NO_THROW(ctx.setControlSocketInfo(socket2, CtrlAgentCfgContext::TYPE_DHCP6));
+ EXPECT_NO_THROW(ctx.setControlSocketInfo(socket2, "dhcp6"));
// Should be possible to retrieve two sockets.
- EXPECT_EQ(socket1, ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2));
- EXPECT_EQ(socket2, ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6));
- EXPECT_FALSE(ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4));
+ EXPECT_EQ(socket1, ctx.getControlSocketInfo("d2"));
+ EXPECT_EQ(socket2, ctx.getControlSocketInfo("dhcp6"));
+ EXPECT_FALSE(ctx.getControlSocketInfo("dhcp4"));
// Finally, set the third control socket.
- EXPECT_NO_THROW(ctx.setControlSocketInfo(socket3, CtrlAgentCfgContext::TYPE_DHCP4));
- EXPECT_EQ(socket1, ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2));
- EXPECT_EQ(socket2, ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6));
- EXPECT_EQ(socket3, ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4));
+ EXPECT_NO_THROW(ctx.setControlSocketInfo(socket3, "dhcp4"));
+ EXPECT_EQ(socket1, ctx.getControlSocketInfo("d2"));
+ EXPECT_EQ(socket2, ctx.getControlSocketInfo("dhcp6"));
+ EXPECT_EQ(socket3, ctx.getControlSocketInfo("dhcp4"));
}
// Tests if copied context retains all parameters.
ConstElementPtr socket3 = Element::fromJSON("{ \"socket-type\": \"unix\",\n"
" \"socket-name\": \"socket3\" }");
// Ok, now set the control sockets
- EXPECT_NO_THROW(ctx.setControlSocketInfo(socket1, CtrlAgentCfgContext::TYPE_D2));
- EXPECT_NO_THROW(ctx.setControlSocketInfo(socket2, CtrlAgentCfgContext::TYPE_DHCP4));
- EXPECT_NO_THROW(ctx.setControlSocketInfo(socket3, CtrlAgentCfgContext::TYPE_DHCP6));
+ EXPECT_NO_THROW(ctx.setControlSocketInfo(socket1, "d2"));
+ EXPECT_NO_THROW(ctx.setControlSocketInfo(socket2, "dhcp4"));
+ EXPECT_NO_THROW(ctx.setControlSocketInfo(socket3, "dhcp6"));
EXPECT_NO_THROW(ctx.setHttpPort(12345));
EXPECT_NO_THROW(ctx.setHttpHost("bellatrix"));
EXPECT_EQ("bellatrix", copy->getHttpHost());
// Check socket info
- ASSERT_TRUE(copy->getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2));
- ASSERT_TRUE(copy->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4));
- ASSERT_TRUE(copy->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6));
- EXPECT_EQ(socket1->str(), copy->getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2)->str());
- EXPECT_EQ(socket2->str(), copy->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4)->str());
- EXPECT_EQ(socket3->str(), copy->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6)->str());
+ ASSERT_TRUE(copy->getControlSocketInfo("d2"));
+ ASSERT_TRUE(copy->getControlSocketInfo("dhcp4"));
+ ASSERT_TRUE(copy->getControlSocketInfo("dhcp6"));
+ EXPECT_EQ(socket1->str(), copy->getControlSocketInfo("d2")->str());
+ EXPECT_EQ(socket2->str(), copy->getControlSocketInfo("dhcp4")->str());
+ EXPECT_EQ(socket3->str(), copy->getControlSocketInfo("dhcp6")->str());
// Check hook libs
const HookLibsCollection& libs2 = copy->getHooksConfig().get();
CtrlAgentCfgContextPtr ctx = cfg_mgr_.getCtrlAgentCfgContext();
ASSERT_TRUE(ctx);
- ConstElementPtr socket = ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4);
+ ConstElementPtr socket = ctx->getControlSocketInfo("dhcp4");
ASSERT_TRUE(socket);
EXPECT_EQ("{ \"socket-name\": \"/tmp/socket-v4\", \"socket-type\": \"unix\" }",
socket->str());
- EXPECT_FALSE(ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6));
- EXPECT_FALSE(ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2));
+ EXPECT_FALSE(ctx->getControlSocketInfo("dhcp6"));
+ EXPECT_FALSE(ctx->getControlSocketInfo("d2"));
}
// Tests if a single socket can be configured. BTW this test also checks
CtrlAgentCfgContextPtr ctx = cfg_mgr_.getCtrlAgentCfgContext();
ASSERT_TRUE(ctx);
- ConstElementPtr socket = ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2);
+ ConstElementPtr socket = ctx->getControlSocketInfo("d2");
ASSERT_TRUE(socket);
EXPECT_EQ("{ \"socket-name\": \"/tmp/socket-d2\", \"socket-type\": \"unix\" }",
socket->str());
- EXPECT_FALSE(ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4));
- EXPECT_FALSE(ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6));
+ EXPECT_FALSE(ctx->getControlSocketInfo("dhcp4"));
+ EXPECT_FALSE(ctx->getControlSocketInfo("dhcp6"));
}
// Tests if a single socket can be configured. BTW this test also checks
CtrlAgentCfgContextPtr ctx = cfg_mgr_.getCtrlAgentCfgContext();
ASSERT_TRUE(ctx);
- ConstElementPtr socket = ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6);
+ ConstElementPtr socket = ctx->getControlSocketInfo("dhcp6");
ASSERT_TRUE(socket);
EXPECT_EQ("{ \"socket-name\": \"/tmp/socket-v6\", \"socket-type\": \"unix\" }",
socket->str());
- EXPECT_FALSE(ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4));
- EXPECT_FALSE(ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2));
+ EXPECT_FALSE(ctx->getControlSocketInfo("dhcp4"));
+ EXPECT_FALSE(ctx->getControlSocketInfo("d2"));
}
// This tests if all 3 sockets can be configured and makes sure the parser
configParse(AGENT_CONFIGS[3], 0);
CtrlAgentCfgContextPtr ctx = cfg_mgr_.getCtrlAgentCfgContext();
ASSERT_TRUE(ctx);
- ConstElementPtr socket2 = ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2);
- ConstElementPtr socket4 = ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4);
- ConstElementPtr socket6 = ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6);
+ ConstElementPtr socket2 = ctx->getControlSocketInfo("d2");
+ ConstElementPtr socket4 = ctx->getControlSocketInfo("dhcp4");
+ ConstElementPtr socket6 = ctx->getControlSocketInfo("dhcp6");
ASSERT_TRUE(socket2);
EXPECT_EQ("{ \"socket-name\": \"/tmp/socket-d2\", \"socket-type\": \"unix\" }",
socket2->str());
/// @brief Adds configuration of the control socket.
///
- /// @param server_type Server type for which socket configuration is to
- /// be added.
+ /// @param service Service for which socket configuration is to be added.
void
- configureControlSocket(const CtrlAgentCfgContext::ServerType& server_type) {
+ configureControlSocket(const std::string& service) {
CtrlAgentCfgContextPtr ctx = getCtrlAgentCfgContext();
ASSERT_TRUE(ctx);
ElementPtr control_socket = Element::createMap();
control_socket->set("socket-name",
Element::create(unixSocketFilePath()));
- ctx->setControlSocketInfo(control_socket, server_type);
+ ctx->setControlSocketInfo(control_socket, service);
}
/// @brief Create and bind server side socket.
/// server socket after which the IO service should be stopped.
/// @param expected_responses Number of responses after which the test finishes.
/// @param server_response Stub response to be sent by the server.
- void testForward(const CtrlAgentCfgContext::ServerType& server_type,
+ void testForward(const std::string& configured_service,
const std::string& service,
const int expected_result0,
const int expected_result1 = -1,
const size_t expected_responses = 1,
const std::string& server_response = "{ \"result\": 0 }") {
// Configure client side socket.
- configureControlSocket(server_type);
+ configureControlSocket(configured_service);
// Create server side socket.
bindServerSocket(server_response);
/// Check that control command is successfully forwarded to the DHCPv4 server.
TEST_F(CtrlAgentCommandMgrTest, forwardToDHCPv4Server) {
- testForward(CtrlAgentCfgContext::TYPE_DHCP4, "dhcp4",
- isc::config::CONTROL_RESULT_SUCCESS);
+ testForward("dhcp4", "dhcp4", isc::config::CONTROL_RESULT_SUCCESS);
}
/// Check that control command is successfully forwarded to the DHCPv6 server.
TEST_F(CtrlAgentCommandMgrTest, forwardToDHCPv6Server) {
- testForward(CtrlAgentCfgContext::TYPE_DHCP6, "dhcp6",
- isc::config::CONTROL_RESULT_SUCCESS);
+ testForward("dhcp6", "dhcp6", isc::config::CONTROL_RESULT_SUCCESS);
}
/// Check that the same command is forwarded to multiple servers.
TEST_F(CtrlAgentCommandMgrTest, forwardToBothDHCPServers) {
- configureControlSocket(CtrlAgentCfgContext::TYPE_DHCP6);
+ configureControlSocket("dhcp6");
- testForward(CtrlAgentCfgContext::TYPE_DHCP4, "dhcp4,dhcp6",
- isc::config::CONTROL_RESULT_SUCCESS,
- isc::config::CONTROL_RESULT_SUCCESS,
- -1, 2);
+ testForward("dhcp4", "dhcp4,dhcp6", isc::config::CONTROL_RESULT_SUCCESS,
+ isc::config::CONTROL_RESULT_SUCCESS, -1, 2);
}
/// Check that the command may forwarded to the second server even if
/// forwarding to a first server fails.
TEST_F(CtrlAgentCommandMgrTest, failForwardToServer) {
- testForward(CtrlAgentCfgContext::TYPE_DHCP6, "dhcp4,dhcp6",
+ testForward("dhcp6", "dhcp4,dhcp6",
isc::config::CONTROL_RESULT_ERROR,
isc::config::CONTROL_RESULT_SUCCESS);
}
/// Check that control command is not forwarded if the service is not specified.
TEST_F(CtrlAgentCommandMgrTest, noService) {
- testForward(CtrlAgentCfgContext::TYPE_DHCP6, "",
+ testForward("dhcp6", "",
isc::config::CONTROL_RESULT_COMMAND_UNSUPPORTED,
-1, -1, 0);
}
/// Check that error is returned to the client when the server to which the
/// command was forwarded sent an invalid message.
TEST_F(CtrlAgentCommandMgrTest, invalidAnswer) {
- testForward(CtrlAgentCfgContext::TYPE_DHCP6, "dhcp6",
+ testForward("dhcp6", "dhcp6",
isc::config::CONTROL_RESULT_ERROR, -1, -1, 1,
"{ \"result\": 0");
}
/// Check that error is returned to the client if the remote server to
/// which the control command is to be forwarded is not available.
TEST_F(CtrlAgentCommandMgrTest, noServerSocket) {
- configureControlSocket(CtrlAgentCfgContext::TYPE_DHCP6);
+ configureControlSocket("dhcp6");
ConstElementPtr command = createCommand("foo", "dhcp6");
ConstElementPtr answer = mgr_.handleCommand("foo", ConstElementPtr(),
// value is specified.
TEST_F(CtrlAgentCommandMgrTest, forwardListCommands) {
// Configure client side socket.
- configureControlSocket(CtrlAgentCfgContext::TYPE_DHCP4);
+ configureControlSocket("dhcp4");
// Create server side socket.
bindServerSocket("{ \"result\" : 3 }");
/// @brief Tests that socket info structure contains 'unix' socket-type
/// value and the expected socket-name.
///
- /// @param type Server type.
+ /// @param service Service type.
/// @param exp_socket_name Expected socket name.
- void testUnixSocketInfo(const CtrlAgentCfgContext::ServerType& type,
+ void testUnixSocketInfo(const std::string& service,
const std::string& exp_socket_name) {
CtrlAgentCfgContextPtr ctx = getCtrlAgentCfgContext();
ASSERT_TRUE(ctx);
- ConstElementPtr sock_info = ctx->getControlSocketInfo(type);
+ ConstElementPtr sock_info = ctx->getControlSocketInfo(service);
ASSERT_TRUE(sock_info);
ASSERT_TRUE(sock_info->contains("socket-type"));
EXPECT_EQ("unix", sock_info->get("socket-type")->stringValue());
EXPECT_EQ(8080, ctx->getHttpPort());
// The forwarding configuration should have been updated too.
- testUnixSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4, "/second/dhcp4/socket");
- testUnixSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6, "/second/dhcp6/socket");
+ testUnixSocketInfo("dhcp4", "/second/dhcp4/socket");
+ testUnixSocketInfo("dhcp6", "/second/dhcp6/socket");
CtrlAgentProcessPtr process = getCtrlAgentProcess();
ASSERT_TRUE(process);
EXPECT_EQ(8081, ctx->getHttpPort());
// Same for forwarding.
- testUnixSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4, "/first/dhcp4/socket");
- testUnixSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6, "/first/dhcp6/socket");
+ testUnixSocketInfo("dhcp4", "/first/dhcp4/socket");
+ testUnixSocketInfo("dhcp6", "/first/dhcp6/socket");
CtrlAgentProcessPtr process = getCtrlAgentProcess();
ASSERT_TRUE(process);
EXPECT_EQ(8081, ctx->getHttpPort());
// The forwarding configuration should have been updated.
- testUnixSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4, "/second/dhcp4/socket");
- testUnixSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6, "/second/dhcp6/socket");
+ testUnixSocketInfo("dhcp4", "/second/dhcp4/socket");
+ testUnixSocketInfo("dhcp6", "/second/dhcp6/socket");
CtrlAgentProcessPtr process = getCtrlAgentProcess();
ASSERT_TRUE(process);