]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4589] Add unit tests
authorAndrei Pavel <andrei@isc.org>
Mon, 15 Jun 2026 13:51:07 +0000 (16:51 +0300)
committerAndrei Pavel <andrei@isc.org>
Tue, 21 Jul 2026 07:52:34 +0000 (10:52 +0300)
src/bin/admin/tests/data/lease6_dump_test.reference.csv
src/bin/admin/tests/mysql_tests.sh.in
src/bin/admin/tests/pgsql_tests.sh.in
src/bin/lfc/tests/lfc_controller_unittests.cc
src/lib/dhcpsrv/tests/csv_lease_file6_unittest.cc
src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc

index d937ae88f5d1ec69b6059462033575b5cf2f1569..2eb5242082ac06446247507c8f762f31a207065c 100644 (file)
@@ -1,4 +1,5 @@
 address,duid,valid_lifetime,expire,subnet_id,pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname,hwaddr,state,user_context,hwtype,hwaddr_source,pool_id
 ::10,32:30:33,30,1642000000,40,50,0,60,128,1,1,one.example.com,38:30,0,,90,16,0
 ::11,32:31:33,30,1643210000,40,50,0,60,128,1,1,,38:30,1,{  },90,1,0
-::12,32:32:33,30,1643212345,40,50,0,60,128,1,1,three&#x2cexample&#x2ccom,38:30,2,{ "a": 1&#x2c "b": "c" },90,4,0
+::12,32:32:33,30,1643212345,40,50,0,60,128,1,1,three&#x2cexample&#x2ccom,38:30,2,{ "a": 1&#x2c "b": "c" },0,0,0
+::13,32:33:33,30,1700000000,40,50,0,60,128,1,1,no.hwaddr.only.duid,,2,,0,0,0
index 4c91939e2ceebf55d07cfb6d423bd19edada69b2..c48a1a6374bada04b30ee59b342324009b730541 100755 (executable)
@@ -2079,9 +2079,11 @@ mysql_lease6_dump_test() {
 
     # Insert the reference record
     insert_sql="\
-insert into lease6 values(inet6_aton('::10'),203,30,(SELECT FROM_UNIXTIME(1642000000)),40,50,0,60,128,1,1,'one.example.com',80,90,16,0,NULL,0);\
-insert into lease6 values(inet6_aton('::11'),213,30,(SELECT FROM_UNIXTIME(1643210000)),40,50,0,60,128,1,1,'',80,90,1,1,'{  }',0);\
-insert into lease6 values(inet6_aton('::12'),223,30,(SELECT FROM_UNIXTIME(1643212345)),40,50,0,60,128,1,1,'three,example,com',80,90,4,2,'{ \"a\": 1, \"b\": \"c\" }',0)"
+insert into lease6 values(inet6_aton('::10'),203,30,(SELECT FROM_UNIXTIME(1642000000)),40,50,0,60,128,1,1,'one.example.com',80,90,16,0,NULL,0); \
+insert into lease6 values(inet6_aton('::11'),213,30,(SELECT FROM_UNIXTIME(1643210000)),40,50,0,60,128,1,1,'',80,90,1,1,'{  }',0); \
+insert into lease6 values(inet6_aton('::12'),223,30,(SELECT FROM_UNIXTIME(1643212345)),40,50,0,60,128,1,1,'three,example,com',80,0,0,2,'{ \"a\": 1, \"b\": \"c\" }',0); \
+insert into lease6 values(inet6_aton('::13'),233,30,(SELECT FROM_UNIXTIME(1700000000)),40,50,0,60,128,1,1,'no.hwaddr.only.duid',NULL,0,0,2,'',0); \
+"
 
     run_command \
         mysql_execute "$insert_sql"
index 2a95db7ec1a0df55a32647a7f6fdd8d8c89a6d79..0a5c947a5a5740930817f05a0c686bae6f3a4df9 100755 (executable)
@@ -1488,7 +1488,9 @@ pgsql_lease6_dump_test() {
     insert_sql="\
 insert into lease6 values(cast('::10' as inet),E'\\\\x323033',30,TO_TIMESTAMP(1642000000),40,50,0,60,128,'t','t','one.example.com',0,decode(encode('80','hex'),'hex'),90,16,'',0); \
 insert into lease6 values(cast('::11' as inet),E'\\\\x323133',30,TO_TIMESTAMP(1643210000),40,50,0,60,128,'t','t','',1,decode(encode('80','hex'),'hex'),90,1,'{  }',0); \
-insert into lease6 values(cast('::12' as inet),E'\\\\x323233',30,TO_TIMESTAMP(1643212345),40,50,0,60,128,'t','t','three,example,com',2,decode(encode('80','hex'),'hex'),90,4,'{ \"a\": 1, \"b\": \"c\" }',0)"
+insert into lease6 values(cast('::12' as inet),E'\\\\x323233',30,TO_TIMESTAMP(1643212345),40,50,0,60,128,'t','t','three,example,com',2,decode(encode('80','hex'),'hex'),0,0,'{ \"a\": 1, \"b\": \"c\" }',0); \
+insert into lease6 values(cast('::13' as inet),E'\\\\x323333',30,TO_TIMESTAMP(1700000000),40,50,0,60,128,'t','t','no.hwaddr.only.duid',2,NULL,0,0,'',0); \
+"
 
     run_command \
         pgsql_execute "$insert_sql"
index aade9bc8145caa93fafd99476b82d8b556b4af1d..5403ab35aacb6283169f27a72200ab02ac1a27a1 100644 (file)
@@ -551,42 +551,42 @@ TEST_F(LFCControllerTest, launch6) {
     // We have several entries for different leases, the naming is:
     // <lease letter>_<version#>.
     string a_1 = "2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
-                 "200,200,8,100,0,7,0,1,1,host.example.com,,1,,,,0\n";
+                 "200,200,8,100,0,7,0,1,1,host.example.com,,1,,0,0,0\n";
     string a_2 = "2001:db8:1::1,,200,200,8,100,0,7,0,1,1,"
-                 "host.example.com,,1,,,,0\n";
+                 "host.example.com,,1,,0,0,0\n";
     string a_3 = "2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
-                 "200,400,8,100,0,7,0,1,1,host.example.com,,1,,,,0\n";
+                 "200,400,8,100,0,7,0,1,1,host.example.com,,1,,0,0,0\n";
     string a_4 = "2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
                  "0,200,8,100,0,7,0,1,1,host.example.com,,1,"
-                 "{ \"foo\": true },,,0\n";
+                 "{ \"foo\": true },0,0,0\n";
 
     string b_1 = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
-                 "300,300,6,150,0,8,0,0,0,,,1,{ \"bar\": false },,,0\n";
+                 "300,300,6,150,0,8,0,0,0,,,1,{ \"bar\": false },0,0,0\n";
     string b_2 = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
-                 "300,800,6,150,0,8,0,0,0,,,1,,,,0\n";
+                 "300,800,6,150,0,8,0,0,0,,,1,,0,0,0\n";
     string b_3 = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
-                 "300,1000,6,150,0,8,0,0,0,,,1,,,,0\n";
+                 "300,1000,6,150,0,8,0,0,0,,,1,,0,0,0\n";
 
     string c_1 = "3000:1::,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
-                 "100,200,8,0,2,16,64,0,0,,,1,,,,0\n";
+                 "100,200,8,0,2,16,64,0,0,,,1,,0,0,0\n";
     string c_2 = "3000:1::,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
-                 "100,400,8,0,2,16,64,0,0,,,1,,,,0\n";
+                 "100,400,8,0,2,16,64,0,0,,,1,,0,0,0\n";
 
     string d_1 = "2001:db8:1::3,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
-                 "200,600,8,100,0,7,0,1,1,host.example.com,,1,,,,0\n";
+                 "200,600,8,100,0,7,0,1,1,host.example.com,,1,,0,0,0\n";
 
     // new files have 128 prefixlen for non PD type
     string a_3_n = "2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
-                 "200,400,8,100,0,7,128,1,1,host.example.com,,1,,,,0\n";
+                 "200,400,8,100,0,7,128,1,1,host.example.com,,1,,0,0,0\n";
 
     string b_2_n = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
-                   "300,800,6,150,0,8,128,0,0,,,1,,,,0\n";
+                   "300,800,6,150,0,8,128,0,0,,,1,,0,0,0\n";
 
     string b_3_n = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
-                   "300,1000,6,150,0,8,128,0,0,,,1,,,,0\n";
+                   "300,1000,6,150,0,8,128,0,0,,,1,,0,0,0\n";
 
     string d_1_n = "2001:db8:1::3,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
-                   "200,600,8,100,0,7,128,1,1,host.example.com,,1,,,,0\n";
+                   "200,600,8,100,0,7,128,1,1,host.example.com,,1,,0,0,0\n";
 
     // Subtest 1: both previous and copy available
     // Create the test previous file
index 0311debc8ebbdc1ed9070e924ed20d1a5b122eee..3b224c4a51973c66e2d54d51ddf4ffbd0afaafac 100644 (file)
@@ -328,12 +328,12 @@ TEST_F(CSVLeaseFile6Test, recreate) {
               "lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname,hwaddr,"
               "state,user_context,hwtype,hwaddr_source,pool_id\n"
               "2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
-              "200,200,8,100,0,7,128,1,1,host.example.com,,0,,,,0\n"
+              "200,200,8,100,0,7,128,1,1,host.example.com,,0,,0,0,0\n"
               "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05"
-              ",300,300,6,150,0,8,128,0,0,,,0,,,,0\n"
+              ",300,300,6,150,0,8,128,0,0,,,0,,0,0,0\n"
               "3000:1:1::,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
-              "300,300,10,150,2,7,64,0,0,,,0,{ \"foobar\": true },,,0\n"
-              "2001:db8:2::10,00:00:00,300,300,6,150,0,8,128,0,0,,,1,,,,0\n",
+              "300,300,10,150,2,7,64,0,0,,,0,{ \"foobar\": true },0,0,0\n"
+              "2001:db8:2::10,00:00:00,300,300,6,150,0,8,128,0,0,,,1,,0,0,0\n",
               io_.readFile());
 }
 
index 3d23e5946effec7d67fca83ae8055bf70be86137..8082f269b76166f2c0cd4a118ee523ed1eab5c17 100644 (file)
@@ -532,20 +532,20 @@ TEST_F(LeaseFileLoaderTest, loadWrite6) {
                       "{ \"foobar\": true },,,0\n";
 
     std::string b_1 = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
-                      "300,300,6,150,0,8,0,0,0,,,1,,,,0\n";
+                      "300,300,6,150,0,8,0,0,0,,,1,,0,0,0\n";
     std::string b_2 = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
-                      "300,800,6,150,0,8,0,0,0,,,1,,,,0\n";
+                      "300,800,6,150,0,8,0,0,0,,,1,,0,0,0\n";
 
     std::string c_1 = "3000:1::,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
-                      "100,200,8,0,2,16,64,0,0,,,1,,,,0\n";
+                      "100,200,8,0,2,16,64,0,0,,,1,,0,0,0\n";
 
     // new files have 128 prefixlen for non PD type
     std::string a_3_n = "2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,"
                         "200,400,8,100,0,7,128,1,1,host.example.com,,1,"
-                        "{ \"foobar\": true },,,0\n";
+                        "{ \"foobar\": true },0,0,0\n";
 
     std::string b_2_n = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
-                        "300,800,6,150,0,8,128,0,0,,,1,,,,0\n";
+                        "300,800,6,150,0,8,128,0,0,,,1,,0,0,0\n";
 
     // Create a lease file with three valid leases: 2001:db8:1::1,
     // 3000:1:: and 2001:db8:2::10.
@@ -623,7 +623,7 @@ TEST_F(LeaseFileLoaderTest, loadWrite6LeaseRemove) {
 
     // new files have 128 prefixlen for non PD type
     std::string b_2_n = "2001:db8:2::10,01:01:01:01:0a:01:02:03:04:05,"
-                        "300,800,6,150,0,8,128,0,0,,,1,,,,0\n";
+                        "300,800,6,150,0,8,128,0,0,,,1,,0,0,0\n";
 
     // Create lease file in which one of the entries for the 2001:db8:1::1
     // has valid lifetime set to 0, in which case the lease should be
index 90cfd78567fe162dd48b2286eb760ef697340634..a0b17119a1c5beeed6bdaadc88f591253410f428 100644 (file)
@@ -889,7 +889,7 @@ TEST_F(MemfileLeaseMgrTest, leaseFileCleanup6) {
 
     std::string update_file_contents = new_file_contents +
         "3000::1,00:00:00:00:00:00:00:00:00:00:00:00:00,400,"
-        "400,2,300,0,123,128,0,0,,,0,,,,0\n";
+        "400,2,300,0,123,128,0,0,,,0,,0,0,0\n";
     EXPECT_EQ(update_file_contents, current_file.readFile());
 
     // This string contains the contents of the lease file we
@@ -897,9 +897,9 @@ TEST_F(MemfileLeaseMgrTest, leaseFileCleanup6) {
     // entry each.
     std::string result_file_contents = new_file_contents +
         "2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,200,800,"
-        "8,100,0,7,128,1,1,,,1,{ \"foo\": true },,,0\n"
+        "8,100,0,7,128,1,1,,,1,{ \"foo\": true },0,0,0\n"
         "2001:db8:1::2,01:01:01:01:01:01:01:01:01:01:01:01:01,200,800,"
-        "8,100,0,7,128,1,1,,,1,,,,0\n";
+        "8,100,0,7,128,1,1,,,1,,0,0,0\n";
 
     // The LFC should have created a file with the two leases and moved it
     // to leasefile6_0.csv.2
@@ -1031,7 +1031,7 @@ TEST_F(MemfileLeaseMgrTest, leaseFileCopy) {
     // the same.
     std::string input_file_contents = new_file_contents +
         "2001:db8:1::2,01:01:01:01:01:01:01:01:01:01:01:01:01,200,800,"
-        "8,100,0,7,128,1,1,,,1,{ \"foo\": true },,,0\n";
+        "8,100,0,7,128,1,1,,,1,{ \"foo\": true },0,0,0\n";
     LeaseFileIO input_file(getLeaseFilePath("leasefile6_0.csv.1"));
     input_file.writeFile(input_file_contents);
 
@@ -2268,7 +2268,7 @@ TEST_F(MemfileLeaseMgrTest, leaseUpgrade6) {
     // Verify cleaned, converted contents
     std::string result_file_contents = header_5_0 +
         "2001:db8:1::1,00:01:02:03:04:05:06:0a:0b:0c:0d:0e:0f,200,800,"
-        "8,100,0,7,128,1,1,,,0,,,,0\n"
+        "8,100,0,7,128,1,1,,,0,,0,0,0\n"
         "2001:db8:1::2,01:01:01:01:01:01:01:01:01:01:01:01:01,200,800,"
         "8,100,0,7,128,1,1,,11:22:33:44:55,0,,1,0,0\n";
     EXPECT_EQ(result_file_contents, input_file.readFile());