]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2815] Extend unit test
authorSlawek Figiel <slawek@isc.org>
Tue, 11 Apr 2023 16:30:47 +0000 (18:30 +0200)
committerSlawek Figiel <slawek@isc.org>
Thu, 25 May 2023 11:29:29 +0000 (13:29 +0200)
src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc

index 47289f6e4781f900b736845fd8bcb903c26bc732..fe12926cc84e12142ec88242fc02b618f3418c60 100644 (file)
@@ -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