|
@@ -451,6 +451,48 @@ TEST_F(CSVLeaseFile6Test, downGrade) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// Verifies that leases with no DUID are invalid, and that leases
|
|
|
+// with the "Empty" DUID (1 byte duid = 0x0) are valid only when
|
|
|
+// in the declined state.
|
|
|
+TEST_F(CSVLeaseFile6Test, declinedLeaseTest) {
|
|
|
+ io_.writeFile("address,duid,valid_lifetime,expire,subnet_id,"
|
|
|
+ "pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,"
|
|
|
+ "fqdn_rev,hostname,hwaddr,state\n"
|
|
|
+ "2001:db8:1::1,00,"
|
|
|
+ "200,200,8,100,0,7,0,1,1,host.example.com,,0\n"
|
|
|
+ "2001:db8:1::1,,"
|
|
|
+ "200,200,8,100,0,7,0,1,1,host.example.com,,0\n"
|
|
|
+ "2001:db8:1::1,00,"
|
|
|
+ "200,200,8,100,0,7,0,1,1,host.example.com,,1\n");
|
|
|
+
|
|
|
+ CSVLeaseFile6 lf(filename_);
|
|
|
+ ASSERT_NO_THROW(lf.open());
|
|
|
+ EXPECT_FALSE(lf.needsConversion());
|
|
|
+ EXPECT_EQ(util::VersionedCSVFile::CURRENT, lf.getInputSchemaState());
|
|
|
+ Lease6Ptr lease;
|
|
|
+
|
|
|
+ {
|
|
|
+ SCOPED_TRACE("\"Empty\" DUID and not declined, invalid");
|
|
|
+ EXPECT_FALSE(lf.next(lease));
|
|
|
+ ASSERT_FALSE(lease);
|
|
|
+ EXPECT_EQ(lf.getReadErrs(),1);
|
|
|
+ }
|
|
|
+
|
|
|
+ {
|
|
|
+ SCOPED_TRACE("Missing (blank) DUID and not declined, invalid");
|
|
|
+ EXPECT_FALSE(lf.next(lease));
|
|
|
+ ASSERT_FALSE(lease);
|
|
|
+ EXPECT_EQ(lf.getReadErrs(),2);
|
|
|
+ }
|
|
|
+
|
|
|
+ {
|
|
|
+ SCOPED_TRACE("\"Empty\" DUID and declined, valid");
|
|
|
+ EXPECT_TRUE(lf.next(lease));
|
|
|
+ ASSERT_TRUE(lease);
|
|
|
+ EXPECT_EQ(lf.getReadErrs(),2);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
/// @todo Currently we don't check invalid lease attributes, such as invalid
|
|
|
/// lease type, invalid preferred lifetime vs valid lifetime etc. The Lease6
|