Commit b7da638f authored by Thomas Markwalder's avatar Thomas Markwalder

[3382] A few more review changes.

Added unit tests for null DUIDs.
Minor nit fixes.
parent 403663bb
......@@ -122,7 +122,7 @@ public:
/// see the documentation of those classes for details.
class LeaseMgr {
public:
/// @brief Defines maxiumum value for time that can be reliably stored.
/// @brief Defines maximum value for time that can be reliably stored.
// If I'm still alive I'll be too old to care. You fix it.
static const time_t MAX_DB_TIME;
......
......@@ -99,7 +99,7 @@ struct PsqlBindArray {
/// Converts the given boolean value to its corresponding to PostgreSQL
/// string value and adds it as a TEXT_FMT value to the bind array.
///
/// @param value std::string containing the value to add.
/// @param value bool value to add.
void add(const bool& value);
/// @brief Dumps the contents of the array to a string.
......
......@@ -1552,6 +1552,18 @@ GenericLeaseMgrTest::testRecreateLease6() {
detailCompareLease(lease, l_returned);
}
void
GenericLeaseMgrTest::testNullDuid() {
// Create leases, although we need only one.
vector<Lease6Ptr> leases = createLeases6();
// Set DUID to empty pointer.
leases[1]->duid_.reset();
// Insert should throw.
ASSERT_THROW(lmptr_->addLease(leases[1]), DbOperationError);
}
}; // namespace test
}; // namespace dhcp
......
......@@ -252,6 +252,9 @@ public:
/// persistent storage has been updated as expected.
void testRecreateLease6();
/// @brief Verifies that a null DUID is not allowed.
void testNullDuid();
/// @brief String forms of IPv4 addresses
std::vector<std::string> straddress4_;
......
......@@ -411,4 +411,14 @@ TEST_F(MemfileLeaseMgrTest, testRecreateLease6) {
// testGetLease4HWAddrSubnetIdSize() - memfile just keeps Lease structure
// and does not do any checks of HWAddr content
/// @brief Checks that null DUID is not allowed.
/// Test is disabled as Memfile does not currently defend against a null DUID.
TEST_F(MemfileLeaseMgrTest, DISABLED_nullDuid) {
// Create leases, although we need only one.
vector<Lease6Ptr> leases = createLeases6();
leases[1]->duid_.reset();
ASSERT_THROW(lmptr_->addLease(leases[1]), DbOperationError);
}
}; // end of anonymous namespace
......@@ -516,4 +516,10 @@ TEST_F(MySqlLeaseMgrTest, testRecreateLease6) {
testRecreateLease6();
}
/// @brief Checks that null DUID is not allowed.
/// Test is disabled as MySqlLeaseMgr does not currently defend against a null DUID.
TEST_F(MySqlLeaseMgrTest, DISABLED_nullDuid) {
testNullDuid();
}
}; // Of anonymous namespace
......@@ -464,4 +464,8 @@ TEST_F(PgSqlLeaseMgrTest, updateLease6) {
testUpdateLease6();
}
TEST_F(PgSqlLeaseMgrTest, nullDuid) {
testNullDuid();
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment