]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1405] updated unittests
authorRazvan Becheriu <razvan@isc.org>
Fri, 9 Oct 2020 16:02:20 +0000 (19:02 +0300)
committerRazvan Becheriu <razvan@isc.org>
Wed, 18 Nov 2020 13:55:22 +0000 (15:55 +0200)
src/bin/dhcp4/tests/host_unittest.cc
src/bin/dhcp6/tests/config_parser_unittest.cc
src/lib/dhcpsrv/alloc_engine.cc

index dbfc45d5dce2a70c850f8351869b0440ee8bcdb6..9f9f7f38a22443bc09e3ccb2d02a272ee60da886 100644 (file)
@@ -67,7 +67,7 @@ const char* CONFIGS[] = {
         "\"valid-lifetime\": 600,\n"
         "\"subnet4\": [ { \n"
         "    \"subnet\": \"10.0.0.0/24\", \n"
-        "    \"reservation-mode\": \"global\","
+        "    \"reservation-modes\": { \"global\": True },"
         "    \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ]\n"
         "} ]\n"
     "}\n"
@@ -102,7 +102,7 @@ const char* CONFIGS[] = {
         "        \"id\": 20,"
         "        \"pools\": [ { \"pool\": \"192.0.2.10-192.0.2.63\" } ],\n"
         "        \"interface\": \"eth1\",\n"
-        "        \"reservation-mode\": \"global\","
+        "        \"reservation-modes\": { \"global\": True },"
         "        \"reservations\": [ \n"
         "        {\n"
         "           \"hw-address\": \"aa:bb:cc:dd:ee:ff\",\n"
@@ -129,7 +129,7 @@ const char* CONFIGS[] = {
         "        \"id\": 10,"
         "        \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ],\n"
         "        \"interface\": \"eth0\",\n"
-        "        \"reservation-mode\": \"out-of-pool\","
+        "        \"reservation-modes\": { \"out-of-pool\": True },"
         "        \"reservations\": [ \n"
         "        {\n"
         "           \"hw-address\": \"aa:bb:cc:dd:ee:ff\",\n"
@@ -157,7 +157,7 @@ const char* CONFIGS[] = {
         "        \"id\": 10,"
         "        \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ],\n"
         "        \"interface\": \"eth0\",\n"
-        "        \"reservation-mode\": \"all\","
+        "        \"reservation-modes\": { \"in-subnet\": True, \"out-of-pool\": True },"
         "        \"reservations\": [ \n"
         "        {\n"
         "           \"hw-address\": \"aa:bb:cc:dd:ee:ff\",\n"
@@ -183,7 +183,7 @@ const char* CONFIGS[] = {
         "     \"test\": \"not member('reserved_class')\""
         "}"
         "],\n"
-        "\"reservation-mode\": \"global\","
+        "\"reservation-modes\": { \"global\": True },"
         "\"valid-lifetime\": 600,\n"
         "\"reservations\": [ \n"
         "{\n"
index 61755958ec530f55300585006fbcec9a56afeb9b..37651e7e2fb5c1bb85cf6e322cc0577c8afa5017 100644 (file)
@@ -5661,7 +5661,7 @@ TEST_F(Dhcp6ParserTest, hostReservationPerSubnet) {
     ///       - 2001:db8:3::/64 (reservations disabled)
     ///       - 2001:db8:4::/64 (global reservations)
     ///       - 2001:db8:5::/64 (reservations not specified)
-    const char* HR_CONFIG =
+    const char* hr_config =
         "{"
         "\"preferred-lifetime\": 3000,"
         "\"rebind-timer\": 2000, "
@@ -5693,8 +5693,8 @@ TEST_F(Dhcp6ParserTest, hostReservationPerSubnet) {
         "\"valid-lifetime\": 4000 }";
 
     ConstElementPtr json;
-    ASSERT_NO_THROW(json = parseDHCP6(HR_CONFIG));
-    extractConfig(HR_CONFIG);
+    ASSERT_NO_THROW(json = parseDHCP6(hr_config));
+    extractConfig(hr_config);
 
     ConstElementPtr status;
     EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
@@ -5751,7 +5751,7 @@ TEST_F(Dhcp6ParserTest, hostReservationModesPerSubnet) {
     ///       - 2001:db8:4::/64 (global reservations)
     ///       - 2001:db8:5::/64 (reservations not specified)
     ///       - 2001:db8:5::/64 (global + all enabled)
-    const char* HR_CONFIG =
+    const char* hr_config =
         "{"
         "\"preferred-lifetime\": 3000,"
         "\"rebind-timer\": 2000, "
@@ -5803,8 +5803,8 @@ TEST_F(Dhcp6ParserTest, hostReservationModesPerSubnet) {
         "\"valid-lifetime\": 4000 }";
 
     ConstElementPtr json;
-    ASSERT_NO_THROW(json = parseDHCP6(HR_CONFIG));
-    extractConfig(HR_CONFIG);
+    ASSERT_NO_THROW(json = parseDHCP6(hr_config));
+    extractConfig(hr_config);
 
     ConstElementPtr status;
     EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
@@ -5862,7 +5862,7 @@ TEST_F(Dhcp6ParserTest, hostReservationGlobal) {
     ///   - 2 subnets with:
     ///       - 2001:db8:1::/64 (all reservations enabled)
     ///       - 2001:db8:2::/64 (reservations not specified)
-    const char* HR_CONFIG =
+    const char* hr_config =
         "{"
         "\"preferred-lifetime\": 3000,"
         "\"rebind-timer\": 2000, "
@@ -5880,8 +5880,8 @@ TEST_F(Dhcp6ParserTest, hostReservationGlobal) {
         "\"valid-lifetime\": 4000 }";
 
     ConstElementPtr json;
-    ASSERT_NO_THROW(json = parseDHCP6(HR_CONFIG));
-    extractConfig(HR_CONFIG);
+    ASSERT_NO_THROW(json = parseDHCP6(hr_config));
+    extractConfig(hr_config);
 
     ConstElementPtr status;
     EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
@@ -5919,7 +5919,7 @@ TEST_F(Dhcp6ParserTest, hostReservationModesGlobal) {
     ///   - 2 subnets with:
     ///       - 2001:db8:1::/64 (all reservations enabled)
     ///       - 2001:db8:2::/64 (reservations not specified)
-    const char* HR_CONFIG =
+    const char* hr_config =
         "{"
         "\"preferred-lifetime\": 3000,"
         "\"rebind-timer\": 2000, "
@@ -5942,8 +5942,8 @@ TEST_F(Dhcp6ParserTest, hostReservationModesGlobal) {
         "\"valid-lifetime\": 4000 }";
 
     ConstElementPtr json;
-    ASSERT_NO_THROW(json = parseDHCP6(HR_CONFIG));
-    extractConfig(HR_CONFIG);
+    ASSERT_NO_THROW(json = parseDHCP6(hr_config));
+    extractConfig(hr_config);
 
     ConstElementPtr status;
     EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
index 17411ff4f9361a06ff3cdafbf79db69d68cbaa1e..cb762fda0da98ba8b58f81c1f8342a5feb26706b 100644 (file)
@@ -3320,7 +3320,9 @@ AllocEngine::findReservation(ClientContext4& ctx) {
 
             // @todo In theory, to support global as part of HR_ALL,
             //  we would just keep going, instead of returning.
-            return;
+            if (subnet->getHostReservationMode() == Network::HR_GLOBAL) {
+                return;
+            }
         }
     }