Commit 8ce85344 authored by Thomas Markwalder's avatar Thomas Markwalder
Browse files

[5058] Added unit test to check loading declined leases from CSV file

src/lib/dhcpsrv/tests/csv_lease_file4_unittest.cc
    TEST_F(CSVLeaseFile4Test, declinedLeaseTest) - new test
parent b10a7ab9
...@@ -385,6 +385,36 @@ TEST_F(CSVLeaseFile4Test, downGrade) { ...@@ -385,6 +385,36 @@ TEST_F(CSVLeaseFile4Test, downGrade) {
} }
} }
// Verifies that leases with no hardware address or only permitted
// if they are in the declined state.
TEST_F(CSVLeaseFile4Test, declinedLeaseTest) {
io_.writeFile("address,hwaddr,client_id,valid_lifetime,expire,subnet_id,"
"fqdn_fwd,fqdn_rev,hostname,state\n"
"192.0.2.1,,,200,200,8,1,1,host.example.com,0\n"
"192.0.2.1,,,200,200,8,1,1,host.example.com,1\n");
// Lease file should open and report as needing downgrade.
CSVLeaseFile4 lf(filename_);
ASSERT_NO_THROW(lf.open());
EXPECT_FALSE(lf.needsConversion());
EXPECT_EQ(util::VersionedCSVFile::CURRENT,
lf.getInputSchemaState());
Lease4Ptr lease;
{
SCOPED_TRACE("No hardware and not declined, invalid");
EXPECT_FALSE(lf.next(lease));
ASSERT_FALSE(lease);
EXPECT_EQ(lf.getReadErrs(),1);
}
{
SCOPED_TRACE("No hardware and declined, valid");
EXPECT_TRUE(lf.next(lease));
ASSERT_TRUE(lease);
EXPECT_EQ(lf.getReadErrs(),1);
}
}
/// @todo Currently we don't check invalid lease attributes, such as invalid /// @todo Currently we don't check invalid lease attributes, such as invalid
/// lease type, invalid preferred lifetime vs valid lifetime etc. The Lease6 /// lease type, invalid preferred lifetime vs valid lifetime etc. The Lease6
......
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