2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +00:00

[#92,!13] Moved DB access parser from dhcpsrv to database library.

This commit is contained in:
Marcin Siodelski
2018-08-29 13:54:05 +02:00
parent 11f9193ef8
commit cc98fc37da
10 changed files with 76 additions and 107 deletions

View File

@@ -7,6 +7,7 @@
#include <config.h>
#include <cc/command_interpreter.h>
#include <database/dbaccess_parser.h>
#include <dhcp4/dhcp4_log.h>
#include <dhcp4/dhcp4_srv.h>
#include <dhcp/libdhcp++.h>
@@ -16,7 +17,6 @@
#include <dhcp4/json_config_parser.h>
#include <dhcpsrv/db_type.h>
#include <dhcpsrv/parsers/client_class_def_parser.h>
#include <dhcpsrv/parsers/dbaccess_parser.h>
#include <dhcpsrv/parsers/dhcp_parsers.h>
#include <dhcpsrv/parsers/expiration_config_parser.h>
#include <dhcpsrv/parsers/host_reservation_parser.h>
@@ -429,7 +429,7 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
// Please move at the end when migration will be finished.
if (config_pair.first == "lease-database") {
DbAccessParser parser;
db::DbAccessParser parser;
std::string access_string;
parser.parse(access_string, config_pair.second);
CfgDbAccessPtr cfg_db_access = srv_cfg->getCfgDbAccess();
@@ -438,7 +438,7 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
}
if (config_pair.first == "hosts-database") {
DbAccessParser parser;
db::DbAccessParser parser;
std::string access_string;
parser.parse(access_string, config_pair.second);
CfgDbAccessPtr cfg_db_access = srv_cfg->getCfgDbAccess();
@@ -448,7 +448,7 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
if (config_pair.first == "hosts-databases") {
CfgDbAccessPtr cfg_db_access = srv_cfg->getCfgDbAccess();
DbAccessParser parser;
db::DbAccessParser parser;
auto list = config_pair.second->listValue();
for (auto it : list) {
std::string access_string;

View File

@@ -10,6 +10,7 @@
#include <cc/data.h>
#include <cc/command_interpreter.h>
#include <config/command_mgr.h>
#include <database/dbaccess_parser.h>
#include <dhcp/libdhcp++.h>
#include <dhcp6/json_config_parser.h>
#include <dhcp6/dhcp6_log.h>
@@ -23,7 +24,6 @@
#include <dhcpsrv/timer_mgr.h>
#include <dhcpsrv/triplet.h>
#include <dhcpsrv/parsers/client_class_def_parser.h>
#include <dhcpsrv/parsers/dbaccess_parser.h>
#include <dhcpsrv/parsers/dhcp_parsers.h>
#include <dhcpsrv/parsers/duid_config_parser.h>
#include <dhcpsrv/parsers/expiration_config_parser.h>
@@ -542,7 +542,7 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
// Please move at the end when migration will be finished.
if (config_pair.first == "lease-database") {
DbAccessParser parser;
db::DbAccessParser parser;
std::string access_string;
parser.parse(access_string, config_pair.second);
CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess();
@@ -551,7 +551,7 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
}
if (config_pair.first == "hosts-database") {
DbAccessParser parser;
db::DbAccessParser parser;
std::string access_string;
parser.parse(access_string, config_pair.second);
CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess();
@@ -561,7 +561,7 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
if (config_pair.first == "hosts-databases") {
CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess();
DbAccessParser parser;
db::DbAccessParser parser;
auto list = config_pair.second->listValue();
for (auto it : list) {
std::string access_string;

View File

@@ -24,16 +24,17 @@ CLEANFILES = *.gcno *.gcda http_messages.h http_messages.cc s-messages
lib_LTLIBRARIES = libkea-database.la
libkea_database_la_SOURCES = database_connection.cc database_connection.h
libkea_database_la_SOURCES += dbaccess_parser.h dbaccess_parser.cc
libkea_database_la_SOURCES += db_exceptions.h
libkea_database_la_SOURCES += db_log.cc db_log.h
nodist_libkea_database_la_SOURCES = db_messages.cc db_messages.h
libkea_database_la_LIBADD = $(top_builddir)/src/lib/log/libkea-log.la
libkea_database_la_LIBADD += $(top_builddir)/src/lib/log/interprocess/libkea-log_interprocess.la
libkea_database_la_LIBADD = $(top_builddir)/src/lib/cc/libkea-cc.la
libkea_database_la_LIBADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libkea_database_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la
libkea_database_la_LIBADD += $(top_builddir)/src/lib/util/threads/libkea-threads.la
libkea_database_la_LIBADD += $(top_builddir)/src/lib/util/libkea-util.la
libkea_database_la_LIBADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libkea_database_la_LIBADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libkea_database_la_LIBADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS)

View File

@@ -74,6 +74,13 @@ public:
isc::Exception(file, line, what) {}
};
/// @brief Error detected in the database configuration.
class DbConfigError : public Exception {
public:
DbConfigError(const char* file, size_t line, const char* what) :
isc::Exception(file, line, what) {}
};
} // namespace isc
} // namespace db

View File

@@ -6,17 +6,10 @@
#include <config.h>
#include <dhcp/option.h>
#include <dhcpsrv/cfg_db_access.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/db_type.h>
#include <dhcpsrv/dhcpsrv_log.h>
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/host_mgr.h>
#include <dhcpsrv/parsers/dbaccess_parser.h>
#include <database/db_exceptions.h>
#include <database/dbaccess_parser.h>
#include <dhcpsrv/parsers/dhcp_parsers.h>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <map>
@@ -27,7 +20,7 @@ using namespace std;
using namespace isc::data;
namespace isc {
namespace dhcp {
namespace db {
// Factory function to build the parser
@@ -63,7 +56,7 @@ DbAccessParser::parse(std::string& access_string,
int64_t tcp_keepalive = 0;
// 2. Update the copy with the passed keywords.
BOOST_FOREACH(ConfigPair param, database_config->mapValue()) {
for (std::pair<std::string, ConstElementPtr> param : database_config->mapValue()) {
try {
if ((param.first == "persist") || (param.first == "readonly") ||
(param.first == "tcp-nodelay")) {
@@ -110,7 +103,7 @@ DbAccessParser::parse(std::string& access_string,
}
} catch (const isc::data::TypeError& ex) {
// Append position of the element.
isc_throw(DhcpConfigError, "invalid value type specified for "
isc_throw(DbConfigError, "invalid value type specified for "
"parameter '" << param.first << "' ("
<< param.second->getPosition() << ")");
}
@@ -121,7 +114,7 @@ DbAccessParser::parse(std::string& access_string,
// a. Check if the "type" keyword exists and thrown an exception if not.
StringPairMap::const_iterator type_ptr = values_copy.find("type");
if (type_ptr == values_copy.end()) {
isc_throw(DhcpConfigError,
isc_throw(DbConfigError,
"database access parameters must "
"include the keyword 'type' to determine type of database "
"to be accessed (" << database_config->getPosition() << ")");
@@ -137,7 +130,7 @@ DbAccessParser::parse(std::string& access_string,
(dbtype != "postgresql") &&
(dbtype != "cql")) {
ConstElementPtr value = database_config->get("type");
isc_throw(DhcpConfigError, "unknown backend database type: " << dbtype
isc_throw(DbConfigError, "unknown backend database type: " << dbtype
<< " (" << value->getPosition() << ")");
}
@@ -145,7 +138,7 @@ DbAccessParser::parse(std::string& access_string,
if ((lfc_interval < 0) ||
(lfc_interval > std::numeric_limits<uint32_t>::max())) {
ConstElementPtr value = database_config->get("lfc-interval");
isc_throw(DhcpConfigError, "lfc-interval value: " << lfc_interval
isc_throw(DbConfigError, "lfc-interval value: " << lfc_interval
<< " is out of range, expected value: 0.."
<< std::numeric_limits<uint32_t>::max()
<< " (" << value->getPosition() << ")");
@@ -155,7 +148,7 @@ DbAccessParser::parse(std::string& access_string,
if ((timeout < 0) ||
(timeout > std::numeric_limits<uint32_t>::max())) {
ConstElementPtr value = database_config->get("connect-timeout");
isc_throw(DhcpConfigError, "connect-timeout value: " << timeout
isc_throw(DbConfigError, "connect-timeout value: " << timeout
<< " is out of range, expected value: 0.."
<< std::numeric_limits<uint32_t>::max()
<< " (" << value->getPosition() << ")");
@@ -165,7 +158,7 @@ DbAccessParser::parse(std::string& access_string,
if ((port < 0) ||
(port > std::numeric_limits<uint16_t>::max())) {
ConstElementPtr value = database_config->get("port");
isc_throw(DhcpConfigError, "port value: " << port
isc_throw(DbConfigError, "port value: " << port
<< " is out of range, expected value: 0.."
<< std::numeric_limits<uint16_t>::max()
<< " (" << value->getPosition() << ")");
@@ -174,7 +167,7 @@ DbAccessParser::parse(std::string& access_string,
// Check that the max-reconnect-retries reasonable.
if (max_reconnect_tries < 0) {
ConstElementPtr value = database_config->get("max-reconnect-tries");
isc_throw(DhcpConfigError, "max-reconnect-tries cannot be less than zero: "
isc_throw(DbConfigError, "max-reconnect-tries cannot be less than zero: "
<< " (" << value->getPosition() << ")");
}
@@ -182,7 +175,7 @@ DbAccessParser::parse(std::string& access_string,
if ((reconnect_wait_time < 0) ||
(reconnect_wait_time > std::numeric_limits<uint32_t>::max())) {
ConstElementPtr value = database_config->get("reconnect-wait-time");
isc_throw(DhcpConfigError, "reconnect-wait-time " << reconnect_wait_time
isc_throw(DbConfigError, "reconnect-wait-time " << reconnect_wait_time
<< " must be in range 0...MAX_UINT32 (4294967295) "
<< " (" << value->getPosition() << ")");
}
@@ -191,7 +184,7 @@ DbAccessParser::parse(std::string& access_string,
if ((reconnect_wait_time < 0) ||
(reconnect_wait_time > std::numeric_limits<uint32_t>::max())) {
ConstElementPtr value = database_config->get("reconnect-wait-time");
isc_throw(DhcpConfigError, "reconnect-wait-time " << reconnect_wait_time
isc_throw(DbConfigError, "reconnect-wait-time " << reconnect_wait_time
<< " must be in range 0...MAX_UINT32 (4294967295) "
<< " (" << value->getPosition() << ")");
}
@@ -199,7 +192,7 @@ DbAccessParser::parse(std::string& access_string,
if ((tcp_keepalive < 0) ||
(tcp_keepalive > std::numeric_limits<uint32_t>::max())) {
ConstElementPtr value = database_config->get("reconnect-wait-time");
isc_throw(DhcpConfigError, "tcp-keepalive " << tcp_keepalive
isc_throw(DbConfigError, "tcp-keepalive " << tcp_keepalive
<< " must be in range 0...MAX_UINT32 (4294967295) "
<< " (" << value->getPosition() << ")");
}
@@ -221,7 +214,7 @@ DbAccessParser::getDbAccessString() const {
// Construct the database access string from all keywords and values in the
// parameter map where the value is not null.
string dbaccess;
BOOST_FOREACH(StringPair keyval, values_) {
for (StringPair keyval : values_) {
if (!keyval.second.empty()) {
// Separate keyword/value pair from predecessor (if there is one).
@@ -237,5 +230,5 @@ DbAccessParser::getDbAccessString() const {
return (dbaccess);
}
} // namespace dhcp
} // namespace db
} // namespace isc

View File

@@ -9,13 +9,12 @@
#include <cc/data.h>
#include <cc/simple_parser.h>
#include <dhcpsrv/cfg_db_access.h>
#include <exceptions/exceptions.h>
#include <string>
namespace isc {
namespace dhcp {
namespace db {
/// @brief Parse Database Parameters
///
@@ -55,7 +54,7 @@ public:
/// @param database_config The configuration value for the "*-database"
/// identifier.
///
/// @throw isc::dhcp::DhcpConfigError The 'type' keyword contains an
/// @throw isc::dhcp::DbConfigError The 'type' keyword contains an
/// unknown database type or is missing from the list of
/// database access keywords.
void parse(std::string& access_string,
@@ -88,7 +87,7 @@ private:
std::map<std::string, std::string> values_; ///< Stored parameter values
};
}; // namespace dhcp
}; // namespace db
}; // namespace isc

View File

@@ -20,17 +20,17 @@ if HAVE_GTEST
TESTS += libdatabase_unittests
libdatabase_unittests_SOURCES = database_connection_unittest.cc
libdatabase_unittests_SOURCES += dbaccess_parser_unittest.cc
libdatabase_unittests_SOURCES += run_unittests.cc
libdatabase_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
libdatabase_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
libdatabase_unittests_LDADD = $(top_builddir)/src/lib/database/libkea-database.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/log/interprocess/libkea-log_interprocess.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/util/threads/libkea-threads.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libdatabase_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD)

View File

@@ -7,11 +7,9 @@
#include <config.h>
#include <cc/command_interpreter.h>
#include <dhcpsrv/db_type.h>
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/parsers/dbaccess_parser.h>
#include <dhcpsrv/testutils/mysql_schema.h>
#include <dhcpsrv/host_mgr.h>
#include <database/database_connection.h>
#include <database/db_exceptions.h>
#include <database/dbaccess_parser.h>
#include <log/logger_support.h>
#include <gtest/gtest.h>
@@ -22,8 +20,6 @@
using namespace std;
using namespace isc;
using namespace isc::db;
using namespace isc::dhcp;
using namespace isc::dhcp::test;
using namespace isc::data;
using namespace isc::config;
@@ -33,22 +29,14 @@ namespace {
class DbAccessParserTest : public ::testing::Test {
public:
/// @brief Constructor
///
/// Just make sure that the lease database is closed before every test
/// (the first in particular).
DbAccessParserTest() {
LeaseMgrFactory::destroy();
}
/// @brief Destructor
///
/// Just make sure that the lease database is closed after every test
/// (the last in particular).
///
/// As some of the tests have the side-effect of altering the logging
/// settings (when the parser's "parse" method is called), ensure that
/// the logging is reset to the default after each test completes.
~DbAccessParserTest() {
LeaseMgrFactory::destroy();
isc::log::setDefaultLoggingOutput();
}
@@ -195,10 +183,8 @@ class TestDbAccessParser : public DbAccessParser {
public:
/// @brief Constructor
///
/// @brief Keyword/value collection of database access parameters
TestDbAccessParser(DBType type)
: DbAccessParser(), type_(type)
TestDbAccessParser()
: DbAccessParser()
{}
/// @brief Destructor
@@ -209,21 +195,10 @@ public:
///
/// @param database_config Configuration to be parsed.
void parse(ConstElementPtr database_config) {
CfgDbAccessPtr cfg_db(new CfgDbAccess());
std::string db_access_string;
DbAccessParser::parse(db_access_string, database_config);
if (type_ == DBType::LEASE_DB) {
cfg_db->setLeaseDbAccessString(db_access_string);
} else {
cfg_db->setHostDbAccessString(db_access_string);
}
}
/// Allow use of superclass's protected functions.
using DbAccessParser::getDbAccessParameters;
using DbAccessParser::getDbAccessString;
/// @brief Get database access parameters
///
/// Used in testing to check that the configuration information has been
@@ -243,8 +218,6 @@ public:
std::string getDbAccessString() const {
return (DbAccessParser::getDbAccessString());
}
DBType type_;
};
// Check that the parser works with a simple configuration.
@@ -256,7 +229,7 @@ TEST_F(DbAccessParserTest, validTypeMemfile) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
TestDbAccessParser parser;
EXPECT_NO_THROW(parser.parse(json_elements));
checkAccessString("Valid memfile", parser.getDbAccessParameters(), config);
}
@@ -270,7 +243,7 @@ TEST_F(DbAccessParserTest, hosts) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::HOSTS_DB);
TestDbAccessParser parser;
EXPECT_NO_THROW(parser.parse(json_elements));
checkAccessString("Valid memfile", parser.getDbAccessParameters(), config);
}
@@ -286,7 +259,7 @@ TEST_F(DbAccessParserTest, emptyKeyword) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
TestDbAccessParser parser;
EXPECT_NO_THROW(parser.parse(json_elements));
checkAccessString("Valid memfile", parser.getDbAccessParameters(), config);
}
@@ -303,7 +276,7 @@ TEST_F(DbAccessParserTest, persistV4Memfile) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
TestDbAccessParser parser;
EXPECT_NO_THROW(parser.parse(json_elements));
checkAccessString("Valid memfile", parser.getDbAccessParameters(),
@@ -322,7 +295,7 @@ TEST_F(DbAccessParserTest, persistV6Memfile) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
TestDbAccessParser parser;
EXPECT_NO_THROW(parser.parse(json_elements));
checkAccessString("Valid memfile", parser.getDbAccessParameters(),
@@ -341,7 +314,7 @@ TEST_F(DbAccessParserTest, validLFCInterval) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
TestDbAccessParser parser;
EXPECT_NO_THROW(parser.parse(json_elements));
checkAccessString("Valid LFC Interval", parser.getDbAccessParameters(),
config);
@@ -359,8 +332,8 @@ TEST_F(DbAccessParserTest, negativeLFCInterval) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
EXPECT_THROW(parser.parse(json_elements), DhcpConfigError);
TestDbAccessParser parser;
EXPECT_THROW(parser.parse(json_elements), DbConfigError);
}
// This test checks that the parser rejects the too large (greater than
@@ -375,8 +348,8 @@ TEST_F(DbAccessParserTest, largeLFCInterval) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
EXPECT_THROW(parser.parse(json_elements), DhcpConfigError);
TestDbAccessParser parser;
EXPECT_THROW(parser.parse(json_elements), DbConfigError);
}
// This test checks that the parser accepts the valid value of the
@@ -391,7 +364,7 @@ TEST_F(DbAccessParserTest, validTimeout) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
TestDbAccessParser parser;
EXPECT_NO_THROW(parser.parse(json_elements));
checkAccessString("Valid timeout", parser.getDbAccessParameters(),
config);
@@ -409,8 +382,8 @@ TEST_F(DbAccessParserTest, negativeTimeout) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
EXPECT_THROW(parser.parse(json_elements), DhcpConfigError);
TestDbAccessParser parser;
EXPECT_THROW(parser.parse(json_elements), DbConfigError);
}
// This test checks that the parser rejects a too large (greater than
@@ -425,8 +398,8 @@ TEST_F(DbAccessParserTest, largeTimeout) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
EXPECT_THROW(parser.parse(json_elements), DhcpConfigError);
TestDbAccessParser parser;
EXPECT_THROW(parser.parse(json_elements), DbConfigError);
}
// This test checks that the parser accepts the valid value of the
@@ -441,7 +414,7 @@ TEST_F(DbAccessParserTest, validPort) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
TestDbAccessParser parser;
EXPECT_NO_THROW(parser.parse(json_elements));
checkAccessString("Valid port", parser.getDbAccessParameters(),
config);
@@ -459,8 +432,8 @@ TEST_F(DbAccessParserTest, negativePort) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
EXPECT_THROW(parser.parse(json_elements), DhcpConfigError);
TestDbAccessParser parser;
EXPECT_THROW(parser.parse(json_elements), DbConfigError);
}
// This test checks that the parser rejects a too large (greater than
@@ -475,8 +448,8 @@ TEST_F(DbAccessParserTest, largePort) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
EXPECT_THROW(parser.parse(json_elements), DhcpConfigError);
TestDbAccessParser parser;
EXPECT_THROW(parser.parse(json_elements), DbConfigError);
}
// Check that the parser works with a valid MySQL configuration
@@ -493,7 +466,7 @@ TEST_F(DbAccessParserTest, validTypeMysql) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
TestDbAccessParser parser;
EXPECT_NO_THROW(parser.parse(json_elements));
checkAccessString("Valid mysql", parser.getDbAccessParameters(), config);
}
@@ -511,8 +484,8 @@ TEST_F(DbAccessParserTest, missingTypeKeyword) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
EXPECT_THROW(parser.parse(json_elements), DhcpConfigError);
TestDbAccessParser parser;
EXPECT_THROW(parser.parse(json_elements), DbConfigError);
}
// Check reconfiguration. Checks that incremental changes applied to the
@@ -562,7 +535,7 @@ TEST_F(DbAccessParserTest, incrementalChanges) {
"name", "keatest",
NULL};
TestDbAccessParser parser(DBType::LEASE_DB);
TestDbAccessParser parser;
// First configuration string should cause a representation of that string
// to be held.
@@ -600,7 +573,7 @@ TEST_F(DbAccessParserTest, incrementalChanges) {
json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
EXPECT_THROW(parser.parse(json_elements), DhcpConfigError);
EXPECT_THROW(parser.parse(json_elements), DbConfigError);
checkAccessString("Incompatible incremental change", parser.getDbAccessParameters(),
config3);
@@ -626,7 +599,7 @@ TEST_F(DbAccessParserTest, getDbAccessString) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
TestDbAccessParser parser;
EXPECT_NO_THROW(parser.parse(json_elements));
// Get the database access string
@@ -652,7 +625,7 @@ TEST_F(DbAccessParserTest, validReadOnly) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
TestDbAccessParser parser;
EXPECT_NO_THROW(parser.parse(json_elements));
checkAccessString("Valid readonly parameter",
@@ -674,8 +647,8 @@ TEST_F(DbAccessParserTest, invalidReadOnly) {
ConstElementPtr json_elements = Element::fromJSON(json_config);
EXPECT_TRUE(json_elements);
TestDbAccessParser parser(DBType::LEASE_DB);
EXPECT_THROW(parser.parse(json_elements), DhcpConfigError);
TestDbAccessParser parser;
EXPECT_THROW(parser.parse(json_elements), DbConfigError);
}
// Check that multiple host storages are correctly parsed.
@@ -692,8 +665,8 @@ TEST_F(DbAccessParserTest, multipleHost) {
ConstElementPtr json_elements1 = Element::fromJSON(json_config1);
ConstElementPtr json_elements2 = Element::fromJSON(json_config2);
TestDbAccessParser parser1(DBType::HOSTS_DB);
TestDbAccessParser parser2(DBType::HOSTS_DB);
TestDbAccessParser parser1;
TestDbAccessParser parser2;
EXPECT_NO_THROW(parser1.parse(json_elements1));
EXPECT_NO_THROW(parser2.parse(json_elements2));

View File

@@ -174,8 +174,6 @@ libkea_dhcpsrv_la_SOURCES += writable_host_data_source.h
# Configuration parsers
libkea_dhcpsrv_la_SOURCES += parsers/client_class_def_parser.cc
libkea_dhcpsrv_la_SOURCES += parsers/client_class_def_parser.h
libkea_dhcpsrv_la_SOURCES += parsers/dbaccess_parser.cc
libkea_dhcpsrv_la_SOURCES += parsers/dbaccess_parser.h
libkea_dhcpsrv_la_SOURCES += parsers/dhcp_parsers.cc
libkea_dhcpsrv_la_SOURCES += parsers/dhcp_parsers.h
libkea_dhcpsrv_la_SOURCES += parsers/duid_config_parser.cc
@@ -334,7 +332,6 @@ endif
libkea_dhcpsrv_parsers_includedir = $(pkgincludedir)/dhcpsrv/parsers
libkea_dhcpsrv_parsers_include_HEADERS = \
parsers/client_class_def_parser.h \
parsers/dbaccess_parser.h \
parsers/dhcp_parsers.h \
parsers/duid_config_parser.h \
parsers/expiration_config_parser.h \

View File

@@ -85,7 +85,6 @@ libdhcpsrv_unittests_SOURCES += csv_lease_file6_unittest.cc
libdhcpsrv_unittests_SOURCES += d2_client_unittest.cc
libdhcpsrv_unittests_SOURCES += d2_udp_unittest.cc
libdhcpsrv_unittests_SOURCES += daemon_unittest.cc
libdhcpsrv_unittests_SOURCES += dbaccess_parser_unittest.cc
libdhcpsrv_unittests_SOURCES += dhcp4o6_ipc_unittest.cc
libdhcpsrv_unittests_SOURCES += duid_config_parser_unittest.cc
libdhcpsrv_unittests_SOURCES += expiration_config_parser_unittest.cc