From: Slawek Figiel Date: Tue, 11 Apr 2023 16:30:47 +0000 (+0200) Subject: [#2815] Extend unit test X-Git-Tag: Kea-2.3.8~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36acefe9f44f8eb8961abcff13e4ddfd0cf3878a;p=thirdparty%2Fkea.git [#2815] Extend unit test --- diff --git a/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc b/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc index 47289f6e47..fe12926cc8 100644 --- a/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc +++ b/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc @@ -3985,6 +3985,31 @@ HostMgrTest::testGet4Any() { &duids_[0]->getDuid()[0], duids_[0]->getDuid().size()); EXPECT_FALSE(host); + + // Make sure that the operation target is supported. + // Select host by explicit, matched operation target. + host = HostMgr::instance().get4Any(SubnetID(1), Host::IDENT_DUID, + &duids_[0]->getDuid()[0], + duids_[0]->getDuid().size(), + HostMgrOperationTarget::PRIMARY_SOURCE); + ASSERT_TRUE(host); + EXPECT_EQ(1, host->getIPv4SubnetID()); + EXPECT_EQ("192.0.2.5", host->getIPv4Reservation().toText()); + EXPECT_TRUE(host->getNegative()); + + // Select host by explicit but unmatched operation target. + host = HostMgr::instance().get4Any(SubnetID(1), Host::IDENT_DUID, + &duids_[0]->getDuid()[0], + duids_[0]->getDuid().size(), + HostMgrOperationTarget::ALTERNATE_SOURCES); + ASSERT_FALSE(host); + + // Select host for an unspecified operation target. + host = HostMgr::instance().get4Any(SubnetID(1), Host::IDENT_DUID, + &duids_[0]->getDuid()[0], + duids_[0]->getDuid().size(), + HostMgrOperationTarget::UNSPECIFIED_SOURCE); + ASSERT_FALSE(host); } void