From: Razvan Becheriu Date: Fri, 9 Oct 2020 16:02:20 +0000 (+0300) Subject: [#1405] updated unittests X-Git-Tag: Kea-1.9.2~148 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3252fb43b8d3d60111bc77a1a2c1060efa87e545;p=thirdparty%2Fkea.git [#1405] updated unittests --- diff --git a/src/bin/dhcp4/tests/host_unittest.cc b/src/bin/dhcp4/tests/host_unittest.cc index dbfc45d5dc..9f9f7f38a2 100644 --- a/src/bin/dhcp4/tests/host_unittest.cc +++ b/src/bin/dhcp4/tests/host_unittest.cc @@ -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" diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc index 61755958ec..37651e7e2f 100644 --- a/src/bin/dhcp6/tests/config_parser_unittest.cc +++ b/src/bin/dhcp6/tests/config_parser_unittest.cc @@ -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)); diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index 17411ff4f9..cb762fda0d 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -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; + } } }