resetConfiguration();
resetHooksPath();
- resetSocketPath();
+ Dhcpv4SrvTest::resetSocketPath();
}
~Dhcp4ParserTest() {
static_cast<void>(remove(UNLOAD_MARKER_FILE));
resetHooksPath();
- resetSocketPath();
+ Dhcpv4SrvTest::resetSocketPath();
};
/// @brief Sets the Hooks path from which hooks can be loaded.
HooksLibrariesParser::getHooksPath(true);
}
- /// @brief Sets the path in which the socket can be created.
- /// @param explicit_path path to use as the socket path.
- void setSocketTestPath(const std::string explicit_path = "") {
- UnixCommandConfig::getSocketPath(true, (!explicit_path.empty() ?
- explicit_path : TEST_DATA_BUILDDIR));
-
- auto path = UnixCommandConfig::getSocketPath();
- UnixCommandConfig::setSocketPathPerms(file::getPermissions(path));
- }
-
- /// @brief Resets the socket path to the default.
- void resetSocketPath() {
- UnixCommandConfig::getSocketPath(true);
- UnixCommandConfig::setSocketPathPerms();
- }
-
// Checks if the result of DHCP server configuration has
// expected code (0 for success, other for failures).
// Also stores result in rcode_ and comment_.
// This test checks comments. Please keep it last.
TEST_F(Dhcp4ParserTest, comments) {
- setSocketTestPath();
+ Dhcpv4SrvTest::setSocketTestPath();
string config = PARSER_CONFIGS[6];
extractConfig(config);
/// @brief Destructor
~CtrlChannelDhcpv4SrvTest() {
resetLogPath();
- resetSocketPath();
+ Dhcpv4SrvTest::resetSocketPath();
if (test_timer_) {
test_timer_->cancel();
getIOService()->stopAndPoll();
/// @brief Sets the path in which the socket can be created.
/// @param explicit_path path to use as the socket path.
void setSocketTestPath(const std::string explicit_path = "") {
- UnixCommandConfig::getSocketPath(true,
- (!explicit_path.empty() ?
- explicit_path : TEST_DATA_BUILDDIR));
-
- auto path = UnixCommandConfig::getSocketPath();
- UnixCommandConfig::setSocketPathPerms(file::getPermissions(path));
- socket_path_ = path + "/kea4.sock";
- }
-
- /// @brief Resets the socket path to the default.
- void resetSocketPath() {
- UnixCommandConfig::getSocketPath(true);
- UnixCommandConfig::setSocketPathPerms();
+ Dhcpv4SrvTest::setSocketTestPath(explicit_path);
+ socket_path_ = UnixCommandConfig::getSocketPath() + "/kea4.sock";
}
-
/// @brief Returns pointer to the server's IO service.
///
/// @return Pointer to the server's IO service or null pointer if the server
/// @brief Sets the path in which the socket can be created.
/// @param explicit_path path to use as the socket path.
- void setSocketTestPath(const std::string explicit_path = "");
+ static void setSocketTestPath(const std::string explicit_path = "");
/// @brief Resets the socket path to the default.
- void resetSocketPath();
+ static void resetSocketPath();
/// @brief Add 'Parameter Request List' option to the packet.
///
" ],\n"
" \"control-sockets\": [\n"
" {\n"
-" \"socket-name\": \"/tmp/kea4-ctrl-socket\",\n"
+" \"socket-name\": \"kea4-ctrl-socket\",\n"
" \"socket-type\": \"unix\",\n"
" \"user-context\": {\n"
" \"comment\": \"Indirect comment\"\n"
" ],\n"
" \"control-sockets\": [\n"
" {\n"
-" \"socket-name\": \"/tmp/kea4-ctrl-socket\",\n"
+" \"socket-name\": \"kea4-ctrl-socket\",\n"
" \"socket-type\": \"unix\",\n"
" \"user-context\": {\n"
" \"comment\": \"Indirect comment\"\n"
srv_.reset(new ControlledDhcpv4Srv(0));
// Create fresh context.
resetConfiguration();
+ Dhcpv4SrvTest::setSocketTestPath();
}
~Dhcp4GetConfigTest() {
resetConfiguration();
+ Dhcpv4SrvTest::resetSocketPath();
};
/// @brief Parse and Execute configuration
/// @brief Sets the path in which the socket can be created.
/// @param explicit_path path to use as the socket path.
- void setSocketTestPath(const std::string explicit_path = "");
+ static void setSocketTestPath(const std::string explicit_path = "");
/// @brief Resets the socket path to the default.
- void resetSocketPath();
+ static void resetSocketPath();
private:
/// @brief Holds the original data directory.
#include <cc/command_interpreter.h>
#include <cc/data.h>
#include <cc/simple_parser.h>
+#include <config/unix_command_config.h>
#include <dhcp/testutils/iface_mgr_test_config.h>
#include <dhcp6/ctrl_dhcp6_srv.h>
#include <dhcp6/dhcp6_srv.h>
#include <dhcp6/tests/dhcp6_test_utils.h>
#include <dhcp6/tests/get_config_unittest.h>
#include <dhcpsrv/cfgmgr.h>
+#include <util/filesystem.h>
#include <testutils/gtest_utils.h>
#include <testutils/user_context_utils.h>
using namespace isc::dhcp;
using namespace isc::dhcp::test;
using namespace isc::test;
+using namespace isc::util;
namespace {
" ],\n"
" \"control-sockets\": [\n"
" {\n"
-" \"socket-name\": \"/tmp/kea6-ctrl-socket\",\n"
+" \"socket-name\": \"kea6-ctrl-socket\",\n"
" \"socket-type\": \"unix\",\n"
" \"user-context\": {\n"
" \"comment\": \"Indirect comment\"\n"
" ],\n"
" \"control-sockets\": [\n"
" {\n"
-" \"socket-name\": \"/tmp/kea6-ctrl-socket\",\n"
+" \"socket-name\": \"kea6-ctrl-socket\",\n"
" \"socket-type\": \"unix\",\n"
" \"user-context\": {\n"
" \"comment\": \"Indirect comment\"\n"
// Reset configuration for each test.
resetConfiguration();
+ BaseServerTest::setSocketTestPath();
}
~Dhcp6GetConfigTest() {
// Reset configuration database after each test.
resetConfiguration();
+ BaseServerTest::resetSocketPath();
};
/// @brief Parse and Execute configuration