Commit 8a8b8605 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[3961_rebase] Changes after review:

 - DataSource renamed to DatabaseConnection
 - exception now prints missing parameter name
 - description updated
 - unnecessary this removed
parent 66fb7589
...@@ -92,7 +92,7 @@ libkea_dhcpsrv_la_SOURCES += csv_lease_file6.cc csv_lease_file6.h ...@@ -92,7 +92,7 @@ libkea_dhcpsrv_la_SOURCES += csv_lease_file6.cc csv_lease_file6.h
libkea_dhcpsrv_la_SOURCES += d2_client_cfg.cc d2_client_cfg.h libkea_dhcpsrv_la_SOURCES += d2_client_cfg.cc d2_client_cfg.h
libkea_dhcpsrv_la_SOURCES += d2_client_mgr.cc d2_client_mgr.h libkea_dhcpsrv_la_SOURCES += d2_client_mgr.cc d2_client_mgr.h
libkea_dhcpsrv_la_SOURCES += daemon.cc daemon.h libkea_dhcpsrv_la_SOURCES += daemon.cc daemon.h
libkea_dhcpsrv_la_SOURCES += data_source.cc data_source.h libkea_dhcpsrv_la_SOURCES += database_connection.cc database_connection.h
libkea_dhcpsrv_la_SOURCES += dhcpsrv_log.cc dhcpsrv_log.h libkea_dhcpsrv_la_SOURCES += dhcpsrv_log.cc dhcpsrv_log.h
libkea_dhcpsrv_la_SOURCES += host.cc host.h libkea_dhcpsrv_la_SOURCES += host.cc host.h
libkea_dhcpsrv_la_SOURCES += host_container.h libkea_dhcpsrv_la_SOURCES += host_container.h
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE. // PERFORMANCE OF THIS SOFTWARE.
#include <dhcpsrv/data_source.h> #include <dhcpsrv/database_connection.h>
#include <dhcpsrv/dhcpsrv_log.h> #include <dhcpsrv/dhcpsrv_log.h>
#include <exceptions/exceptions.h> #include <exceptions/exceptions.h>
...@@ -26,17 +26,17 @@ using namespace std; ...@@ -26,17 +26,17 @@ using namespace std;
namespace isc { namespace isc {
namespace dhcp { namespace dhcp {
std::string DataSource::getParameter(const std::string& name) const { std::string DatabaseConnection::getParameter(const std::string& name) const {
ParameterMap::const_iterator param = parameters_.find(name); ParameterMap::const_iterator param = parameters_.find(name);
if (param == parameters_.end()) { if (param == parameters_.end()) {
isc_throw(BadValue, "Parameter not found"); isc_throw(BadValue, "Parameter " << name << " not found");
} }
return (param->second); return (param->second);
} }
DataSource::ParameterMap DatabaseConnection::ParameterMap
DataSource::parse(const std::string& dbaccess) { DatabaseConnection::parse(const std::string& dbaccess) {
DataSource::ParameterMap mapped_tokens; DatabaseConnection::ParameterMap mapped_tokens;
if (!dbaccess.empty()) { if (!dbaccess.empty()) {
vector<string> tokens; vector<string> tokens;
...@@ -64,11 +64,11 @@ DataSource::parse(const std::string& dbaccess) { ...@@ -64,11 +64,11 @@ DataSource::parse(const std::string& dbaccess) {
} }
std::string std::string
DataSource::redactedAccessString(const DataSource::ParameterMap& parameters) { DatabaseConnection::redactedAccessString(const ParameterMap& parameters) {
// Reconstruct the access string: start of with an empty string, then // Reconstruct the access string: start of with an empty string, then
// work through all the parameters in the original string and add them. // work through all the parameters in the original string and add them.
std::string access; std::string access;
for (DataSource::ParameterMap::const_iterator i = parameters.begin(); for (DatabaseConnection::ParameterMap::const_iterator i = parameters.begin();
i != parameters.end(); ++i) { i != parameters.end(); ++i) {
// Separate second and subsequent tokens are preceded by a space. // Separate second and subsequent tokens are preceded by a space.
......
...@@ -49,8 +49,11 @@ public: ...@@ -49,8 +49,11 @@ public:
/// ///
/// This class provides functions that are common for establishing /// This class provides functions that are common for establishing
/// connection with different types of databases; enables operations /// connection with different types of databases; enables operations
/// on access parameters strings. /// on access parameters strings. In particular, it provides a way
class DataSource : public boost::noncopyable { /// to parse parameters in key=value format. This class is expected
/// to be a base class for all LeaseMgr and possibly HostDataSource
/// derived classes.
class DatabaseConnection : public boost::noncopyable {
public: public:
/// Database configuration parameter map /// Database configuration parameter map
...@@ -60,7 +63,7 @@ public: ...@@ -60,7 +63,7 @@ public:
/// ///
/// @param parameters A data structure relating keywords and values /// @param parameters A data structure relating keywords and values
/// concerned with the database. /// concerned with the database.
DataSource(const ParameterMap& parameters) DatabaseConnection(const ParameterMap& parameters)
:parameters_(parameters) { :parameters_(parameters) {
} }
...@@ -77,7 +80,7 @@ public: ...@@ -77,7 +80,7 @@ public:
/// @param dbaccess Database access string. /// @param dbaccess Database access string.
/// ///
/// @return std::map<std::string, std::string> Map of keyword/value pairs. /// @return std::map<std::string, std::string> Map of keyword/value pairs.
static DataSource::ParameterMap parse(const std::string& dbaccess); static DatabaseConnection::ParameterMap parse(const std::string& dbaccess);
/// @brief Redact database access string /// @brief Redact database access string
/// ///
...@@ -88,7 +91,7 @@ public: ...@@ -88,7 +91,7 @@ public:
/// ///
/// @return Redacted database access string. /// @return Redacted database access string.
static std::string redactedAccessString( static std::string redactedAccessString(
const DataSource::ParameterMap& parameters); const DatabaseConnection::ParameterMap& parameters);
protected: protected:
......
...@@ -51,8 +51,8 @@ LeaseMgrFactory::create(const std::string& dbaccess) { ...@@ -51,8 +51,8 @@ LeaseMgrFactory::create(const std::string& dbaccess) {
const std::string type = "type"; const std::string type = "type";
// Parse the access string and create a redacted string for logging. // Parse the access string and create a redacted string for logging.
DataSource::ParameterMap parameters = DataSource::parse(dbaccess); DatabaseConnection::ParameterMap parameters = DatabaseConnection::parse(dbaccess);
std::string redacted = DataSource::redactedAccessString(parameters); std::string redacted = DatabaseConnection::redactedAccessString(parameters);
// Is "type" present? // Is "type" present?
if (parameters.find(type) == parameters.end()) { if (parameters.find(type) == parameters.end()) {
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#define LEASE_MGR_FACTORY_H #define LEASE_MGR_FACTORY_H
#include <dhcpsrv/lease_mgr.h> #include <dhcpsrv/lease_mgr.h>
#include <dhcpsrv/data_source.h> #include <dhcpsrv/database_connection.h>
#include <exceptions/exceptions.h> #include <exceptions/exceptions.h>
#include <string> #include <string>
......
...@@ -220,9 +220,8 @@ LFCSetup::getExitStatus() const { ...@@ -220,9 +220,8 @@ LFCSetup::getExitStatus() const {
return (process_->getExitStatus(pid_)); return (process_->getExitStatus(pid_));
} }
Memfile_LeaseMgr::Memfile_LeaseMgr(const ParameterMap& parameters) Memfile_LeaseMgr::Memfile_LeaseMgr(const ParameterMap& parameters)
: DataSource(parameters), : DatabaseConnection(parameters),
lfc_setup_(new LFCSetup(boost::bind(&Memfile_LeaseMgr::lfcCallback, this), lfc_setup_(new LFCSetup(boost::bind(&Memfile_LeaseMgr::lfcCallback, this),
*getIOService())) *getIOService()))
{ {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <dhcpsrv/csv_lease_file4.h> #include <dhcpsrv/csv_lease_file4.h>
#include <dhcpsrv/csv_lease_file6.h> #include <dhcpsrv/csv_lease_file6.h>
#include <dhcpsrv/memfile_lease_storage.h> #include <dhcpsrv/memfile_lease_storage.h>
#include <dhcpsrv/data_source.h> #include <dhcpsrv/database_connection.h>
#include <dhcpsrv/lease_mgr.h> #include <dhcpsrv/lease_mgr.h>
#include <util/process_spawn.h> #include <util/process_spawn.h>
...@@ -86,7 +86,7 @@ class LFCSetup; ...@@ -86,7 +86,7 @@ class LFCSetup;
/// is not specified, the default location in the installation /// is not specified, the default location in the installation
/// directory is used: var/kea/kea-leases4.csv and /// directory is used: var/kea/kea-leases4.csv and
/// var/kea/kea-leases6.csv. /// var/kea/kea-leases6.csv.
class Memfile_LeaseMgr : public LeaseMgr, public DataSource { class Memfile_LeaseMgr : public LeaseMgr, public DatabaseConnection {
public: public:
/// @defgroup versions Specified memfile backend version. /// @defgroup versions Specified memfile backend version.
......
...@@ -147,21 +147,21 @@ void ...@@ -147,21 +147,21 @@ void
MySqlConnection::prepareStatement(uint32_t index, const char* text) { MySqlConnection::prepareStatement(uint32_t index, const char* text) {
// Validate that there is space for the statement in the statements array // Validate that there is space for the statement in the statements array
// and that nothing has been placed there before. // and that nothing has been placed there before.
if ((index >= this->statements_.size()) || (this->statements_[index] != NULL)) { if ((index >= statements_.size()) || (statements_[index] != NULL)) {
isc_throw(InvalidParameter, "invalid prepared statement index (" << isc_throw(InvalidParameter, "invalid prepared statement index (" <<
static_cast<int>(index) << ") or indexed prepared " << static_cast<int>(index) << ") or indexed prepared " <<
"statement is not null"); "statement is not null");
} }
// All OK, so prepare the statement // All OK, so prepare the statement
this->text_statements_[index] = std::string(text); text_statements_[index] = std::string(text);
this->statements_[index] = mysql_stmt_init(mysql_); statements_[index] = mysql_stmt_init(mysql_);
if (this->statements_[index] == NULL) { if (statements_[index] == NULL) {
isc_throw(DbOperationError, "unable to allocate MySQL prepared " isc_throw(DbOperationError, "unable to allocate MySQL prepared "
"statement structure, reason: " << mysql_error(mysql_)); "statement structure, reason: " << mysql_error(mysql_));
} }
int status = mysql_stmt_prepare(this->statements_[index], text, strlen(text)); int status = mysql_stmt_prepare(statements_[index], text, strlen(text));
if (status != 0) { if (status != 0) {
isc_throw(DbOperationError, "unable to prepare MySQL statement <" << isc_throw(DbOperationError, "unable to prepare MySQL statement <" <<
text << ">, reason: " << mysql_error(mysql_)); text << ">, reason: " << mysql_error(mysql_));
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <dhcp/hwaddr.h> #include <dhcp/hwaddr.h>
#include <dhcpsrv/lease_mgr.h> #include <dhcpsrv/lease_mgr.h>
#include <dhcpsrv/data_source.h> #include <dhcpsrv/database_connection.h>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <mysql.h> #include <mysql.h>
...@@ -140,14 +140,14 @@ private: ...@@ -140,14 +140,14 @@ private:
/// used by both MySqlLeaseMgr and MySqlHostDataSource. It manages connecting /// used by both MySqlLeaseMgr and MySqlHostDataSource. It manages connecting
/// to the database and preparing compiled statements. /// to the database and preparing compiled statements.
class MySqlConnection : public DataSource { class MySqlConnection : public DatabaseConnection {
public: public:
/// @brief Constructor /// @brief Constructor
/// ///
/// Initialize MySqlConnection object with parameters needed for connection. /// Initialize MySqlConnection object with parameters needed for connection.
MySqlConnection(const ParameterMap& parameters) MySqlConnection(const ParameterMap& parameters)
: DataSource(parameters) { : DatabaseConnection(parameters) {
} }
/// @brief Destructor /// @brief Destructor
...@@ -190,13 +190,13 @@ public: ...@@ -190,13 +190,13 @@ public:
/// @throw DbOpenError Error opening the database /// @throw DbOpenError Error opening the database
void openDatabase(); void openDatabase();
protected:
std::vector<MYSQL_STMT*> statements_; ///< Prepared statements std::vector<MYSQL_STMT*> statements_; ///< Prepared statements
std::vector<std::string> text_statements_; ///< Raw text of statements std::vector<std::string> text_statements_; ///< Raw text of statements
protected: /// @brief MySQL connection handle
MySqlHolder mysql_; MySqlHolder mysql_;
}; };
......
...@@ -942,8 +942,8 @@ private: ...@@ -942,8 +942,8 @@ private:
//@} //@}
}; };
PgSqlLeaseMgr::PgSqlLeaseMgr(const DataSource::ParameterMap& parameters) PgSqlLeaseMgr::PgSqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters)
: LeaseMgr(), DataSource(parameters), exchange4_(new PgSqlLease4Exchange()), : LeaseMgr(), DatabaseConnection(parameters), exchange4_(new PgSqlLease4Exchange()),
exchange6_(new PgSqlLease6Exchange()), conn_(NULL) { exchange6_(new PgSqlLease6Exchange()), conn_(NULL) {
openDatabase(); openDatabase();
prepareStatements(); prepareStatements();
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <dhcp/hwaddr.h> #include <dhcp/hwaddr.h>
#include <dhcpsrv/lease_mgr.h> #include <dhcpsrv/lease_mgr.h>
#include <dhcpsrv/data_source.h> #include <dhcpsrv/database_connection.h>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp> #include <boost/utility.hpp>
#include <libpq-fe.h> #include <libpq-fe.h>
...@@ -121,7 +121,7 @@ const uint32_t PG_CURRENT_MINOR = 0; ...@@ -121,7 +121,7 @@ const uint32_t PG_CURRENT_MINOR = 0;
/// This class provides the \ref isc::dhcp::LeaseMgr interface to the PostgreSQL /// This class provides the \ref isc::dhcp::LeaseMgr interface to the PostgreSQL
/// database. Use of this backend presupposes that a PostgreSQL database is /// database. Use of this backend presupposes that a PostgreSQL database is
/// available and that the Kea schema has been created within it. /// available and that the Kea schema has been created within it.
class PgSqlLeaseMgr : public LeaseMgr, DataSource { class PgSqlLeaseMgr : public LeaseMgr, DatabaseConnection {
public: public:
/// @brief Constructor /// @brief Constructor
...@@ -146,7 +146,7 @@ public: ...@@ -146,7 +146,7 @@ public:
/// @throw isc::dhcp::DbOpenError Error opening the database /// @throw isc::dhcp::DbOpenError Error opening the database
/// @throw isc::dhcp::DbOperationError An operation on the open database has /// @throw isc::dhcp::DbOperationError An operation on the open database has
/// failed. /// failed.
PgSqlLeaseMgr(const DataSource::ParameterMap& parameters); PgSqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters);
/// @brief Destructor (closes database) /// @brief Destructor (closes database)
virtual ~PgSqlLeaseMgr(); virtual ~PgSqlLeaseMgr();
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <config.h> #include <config.h>
#include <exceptions/exceptions.h> #include <exceptions/exceptions.h>
#include <dhcpsrv/data_source.h> #include <dhcpsrv/database_connection.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
using namespace isc::dhcp; using namespace isc::dhcp;
...@@ -24,12 +24,12 @@ using namespace isc::dhcp; ...@@ -24,12 +24,12 @@ using namespace isc::dhcp;
/// ///
/// This test checks if the LeaseMgr can be instantiated and that it /// This test checks if the LeaseMgr can be instantiated and that it
/// parses parameters string properly. /// parses parameters string properly.
TEST(DataSourceTest, getParameter) { TEST(DatabaseConnectionTest, getParameter) {
DataSource::ParameterMap pmap; DatabaseConnection::ParameterMap pmap;
pmap[std::string("param1")] = std::string("value1"); pmap[std::string("param1")] = std::string("value1");
pmap[std::string("param2")] = std::string("value2"); pmap[std::string("param2")] = std::string("value2");
DataSource datasrc(pmap); DatabaseConnection datasrc(pmap);
EXPECT_EQ("value1", datasrc.getParameter("param1")); EXPECT_EQ("value1", datasrc.getParameter("param1"));
EXPECT_EQ("value2", datasrc.getParameter("param2")); EXPECT_EQ("value2", datasrc.getParameter("param2"));
...@@ -37,9 +37,9 @@ TEST(DataSourceTest, getParameter) { ...@@ -37,9 +37,9 @@ TEST(DataSourceTest, getParameter) {
} }
// This test checks that a database access string can be parsed correctly. // This test checks that a database access string can be parsed correctly.
TEST(DataSourceTest, parse) { TEST(DatabaseConnectionTest, parse) {
DataSource::ParameterMap parameters = DataSource::parse( DatabaseConnection::ParameterMap parameters = DatabaseConnection::parse(
"user=me password=forbidden name=kea somethingelse= type=mysql"); "user=me password=forbidden name=kea somethingelse= type=mysql");
EXPECT_EQ(5, parameters.size()); EXPECT_EQ(5, parameters.size());
...@@ -51,25 +51,25 @@ TEST(DataSourceTest, parse) { ...@@ -51,25 +51,25 @@ TEST(DataSourceTest, parse) {
} }
// This test checks that an invalid database access string behaves as expected. // This test checks that an invalid database access string behaves as expected.
TEST(DataSourceTest, parseInvalid) { TEST(DatabaseConnectionTest, parseInvalid) {
// No tokens in the string, so we expect no parameters // No tokens in the string, so we expect no parameters
std::string invalid = ""; std::string invalid = "";
DataSource::ParameterMap parameters = DataSource::parse(invalid); DatabaseConnection::ParameterMap parameters = DatabaseConnection::parse(invalid);
EXPECT_EQ(0, parameters.size()); EXPECT_EQ(0, parameters.size());
// With spaces, there are some tokens so we expect invalid parameter // With spaces, there are some tokens so we expect invalid parameter
// as there are no equals signs. // as there are no equals signs.
invalid = " \t "; invalid = " \t ";
EXPECT_THROW(DataSource::parse(invalid), isc::InvalidParameter); EXPECT_THROW(DatabaseConnection::parse(invalid), isc::InvalidParameter);
invalid = " noequalshere "; invalid = " noequalshere ";
EXPECT_THROW(DataSource::parse(invalid), isc::InvalidParameter); EXPECT_THROW(DatabaseConnection::parse(invalid), isc::InvalidParameter);
// A single "=" is valid string, but is placed here as the result is // A single "=" is valid string, but is placed here as the result is
// expected to be nothing. // expected to be nothing.
invalid = "="; invalid = "=";
parameters = DataSource::parse(invalid); parameters = DatabaseConnection::parse(invalid);
EXPECT_EQ(1, parameters.size()); EXPECT_EQ(1, parameters.size());
EXPECT_EQ("", parameters[""]); EXPECT_EQ("", parameters[""]);
} }
...@@ -78,10 +78,10 @@ TEST(DataSourceTest, parseInvalid) { ...@@ -78,10 +78,10 @@ TEST(DataSourceTest, parseInvalid) {
/// ///
/// Checks that the redacted configuration string includes the password only /// Checks that the redacted configuration string includes the password only
/// as a set of asterisks. /// as a set of asterisks.
TEST(DataSourceTest, redactAccessString) { TEST(DatabaseConnectionTest, redactAccessString) {
DataSource::ParameterMap parameters = DatabaseConnection::ParameterMap parameters =
DataSource::parse("user=me password=forbidden name=kea type=mysql"); DatabaseConnection::parse("user=me password=forbidden name=kea type=mysql");
EXPECT_EQ(4, parameters.size()); EXPECT_EQ(4, parameters.size());
EXPECT_EQ("me", parameters["user"]); EXPECT_EQ("me", parameters["user"]);
EXPECT_EQ("forbidden", parameters["password"]); EXPECT_EQ("forbidden", parameters["password"]);
...@@ -90,8 +90,8 @@ TEST(DataSourceTest, redactAccessString) { ...@@ -90,8 +90,8 @@ TEST(DataSourceTest, redactAccessString) {
// Redact the result. To check, break the redacted string down into its // Redact the result. To check, break the redacted string down into its
// components. // components.
std::string redacted = DataSource::redactedAccessString(parameters); std::string redacted = DatabaseConnection::redactedAccessString(parameters);
parameters = DataSource::parse(redacted); parameters = DatabaseConnection::parse(redacted);
EXPECT_EQ(4, parameters.size()); EXPECT_EQ(4, parameters.size());
EXPECT_EQ("me", parameters["user"]); EXPECT_EQ("me", parameters["user"]);
...@@ -104,10 +104,10 @@ TEST(DataSourceTest, redactAccessString) { ...@@ -104,10 +104,10 @@ TEST(DataSourceTest, redactAccessString) {
/// ///
/// Checks that the redacted configuration string includes the password only /// Checks that the redacted configuration string includes the password only
/// as a set of asterisks, even if the password is null. /// as a set of asterisks, even if the password is null.
TEST(DataSourceTest, redactAccessStringEmptyPassword) { TEST(DatabaseConnectionTest, redactAccessStringEmptyPassword) {
DataSource::ParameterMap parameters = DatabaseConnection::ParameterMap parameters =
DataSource::parse("user=me name=kea type=mysql password="); DatabaseConnection::parse("user=me name=kea type=mysql password=");
EXPECT_EQ(4, parameters.size()); EXPECT_EQ(4, parameters.size());
EXPECT_EQ("me", parameters["user"]); EXPECT_EQ("me", parameters["user"]);
EXPECT_EQ("", parameters["password"]); EXPECT_EQ("", parameters["password"]);
...@@ -116,8 +116,8 @@ TEST(DataSourceTest, redactAccessStringEmptyPassword) { ...@@ -116,8 +116,8 @@ TEST(DataSourceTest, redactAccessStringEmptyPassword) {
// Redact the result. To check, break the redacted string down into its // Redact the result. To check, break the redacted string down into its
// components. // components.
std::string redacted = DataSource::redactedAccessString(parameters); std::string redacted = DatabaseConnection::redactedAccessString(parameters);
parameters = DataSource::parse(redacted); parameters = DatabaseConnection::parse(redacted);
EXPECT_EQ(4, parameters.size()); EXPECT_EQ(4, parameters.size());
EXPECT_EQ("me", parameters["user"]); EXPECT_EQ("me", parameters["user"]);
...@@ -127,15 +127,15 @@ TEST(DataSourceTest, redactAccessStringEmptyPassword) { ...@@ -127,15 +127,15 @@ TEST(DataSourceTest, redactAccessStringEmptyPassword) {
// ... and again to check that the position of the empty password in the // ... and again to check that the position of the empty password in the
// string does not matter. // string does not matter.
parameters = DataSource::parse("user=me password= name=kea type=mysql"); parameters = DatabaseConnection::parse("user=me password= name=kea type=mysql");
EXPECT_EQ(4, parameters.size()); EXPECT_EQ(4, parameters.size());
EXPECT_EQ("me", parameters["user"]); EXPECT_EQ("me", parameters["user"]);
EXPECT_EQ("", parameters["password"]); EXPECT_EQ("", parameters["password"]);
EXPECT_EQ("kea", parameters["name"]); EXPECT_EQ("kea", parameters["name"]);
EXPECT_EQ("mysql", parameters["type"]); EXPECT_EQ("mysql", parameters["type"]);
redacted = DataSource::redactedAccessString(parameters); redacted = DatabaseConnection::redactedAccessString(parameters);
parameters = DataSource::parse(redacted); parameters = DatabaseConnection::parse(redacted);
EXPECT_EQ(4, parameters.size()); EXPECT_EQ(4, parameters.size());
EXPECT_EQ("me", parameters["user"]); EXPECT_EQ("me", parameters["user"]);
...@@ -148,10 +148,10 @@ TEST(DataSourceTest, redactAccessStringEmptyPassword) { ...@@ -148,10 +148,10 @@ TEST(DataSourceTest, redactAccessStringEmptyPassword) {
/// ///
/// Checks that the redacted configuration string excludes the password if there /// Checks that the redacted configuration string excludes the password if there
/// was no password to begin with. /// was no password to begin with.
TEST(DataSourceTest, redactAccessStringNoPassword) { TEST(DatabaseConnectionTest, redactAccessStringNoPassword) {
DataSource::ParameterMap parameters = DatabaseConnection::ParameterMap parameters =
DataSource::parse("user=me name=kea type=mysql"); DatabaseConnection::parse("user=me name=kea type=mysql");
EXPECT_EQ(3, parameters.size()); EXPECT_EQ(3, parameters.size());
EXPECT_EQ("me", parameters["user"]); EXPECT_EQ("me", parameters["user"]);
EXPECT_EQ("kea", parameters["name"]); EXPECT_EQ("kea", parameters["name"]);
...@@ -159,8 +159,8 @@ TEST(DataSourceTest, redactAccessStringNoPassword) { ...@@ -159,8 +159,8 @@ TEST(DataSourceTest, redactAccessStringNoPassword) {
// Redact the result. To check, break the redacted string down into its // Redact the result. To check, break the redacted string down into its
// components. // components.
std::string redacted = DataSource::redactedAccessString(parameters); std::string redacted = DatabaseConnection::redactedAccessString(parameters);
parameters = DataSource::parse(redacted); parameters = DatabaseConnection::parse(redacted);
EXPECT_EQ(3, parameters.size()); EXPECT_EQ(3, parameters.size());
EXPECT_EQ("me", parameters["user"]); EXPECT_EQ("me", parameters["user"]);
......
...@@ -161,7 +161,7 @@ public: ...@@ -161,7 +161,7 @@ public:
// Check that the keywords and keyword values are the same: loop // Check that the keywords and keyword values are the same: loop
// through the keywords in the database access string. // through the keywords in the database access string.
for (DataSource::ParameterMap::const_iterator actual = parameters.begin(); for (DatabaseConnection::ParameterMap::const_iterator actual = parameters.begin();
actual != parameters.end(); ++actual) { actual != parameters.end(); ++actual) {
// Does the keyword exist in the set of expected keywords? // Does the keyword exist in the set of expected keywords?
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <config.h> #include <config.h>
#include <dhcpsrv/tests/generic_lease_mgr_unittest.h> #include <dhcpsrv/tests/generic_lease_mgr_unittest.h>
#include <dhcpsrv/tests/test_utils.h> #include <dhcpsrv/tests/test_utils.h>
#include <dhcpsrv/data_source.h> #include <dhcpsrv/database_connection.h>
#include <asiolink/io_address.h> #include <asiolink/io_address.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>