]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[392-search-of-reservations-by-hostname] Addressed comments
authorFrancis Dupont <fdupont@isc.org>
Fri, 11 Oct 2019 23:04:53 +0000 (01:04 +0200)
committerFrancis Dupont <fdupont@isc.org>
Tue, 15 Oct 2019 09:45:32 +0000 (11:45 +0200)
doc/sphinx/arm/hooks.rst
src/lib/dhcpsrv/cql_host_data_source.cc
src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc
src/lib/dhcpsrv/tests/host_mgr_unittest.cc
src/lib/dhcpsrv/tests/mysql_host_data_source_unittest.cc
src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc
src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc
src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.h

index 7e3cd5ee39c80f9a608dfe3f5407af739fa67e1e..9f8dba39a0d1485280ac547cd207d165144cfdd8 100644 (file)
@@ -1231,7 +1231,7 @@ The subnet-id Parameter
 
 Prior to diving into the individual commands, it is worth discussing the
 parameter, ``subnet-id``. Currently this parameter is mandatory for all of the
-commands supplied by this library at the exception of
+commands supplied by this library with the exception of
 reservation-get-by-hostname where it is optional.
 In previous versions of Kea, reservations had
 to belong to a specific subnet; as of Kea 1.5.0, reservations may
@@ -1687,7 +1687,7 @@ returns some IPv4 hosts:
            ]
        },
        "result": 0,
-       "text": "72 IPv4 host(s) found."
+       "text": "5 IPv4 host(s) found."
    }
 
 The response returned by ``reservation-get-by-hostname`` can be long
index 49521aebe48773779882bafbd9b117a7e1decdd8..00988ffb101f554d9e4ad24f5419f6336d3e7db3 100644 (file)
@@ -1503,6 +1503,7 @@ CqlHostExchange::prepareExchange(const HostPtr& host,
         // lower_case_hostname: text
         lower_case_hostname_ = host->getLowerHostname();
         if (lower_case_hostname_.size() > HOSTNAME_MAX_LEN) {
+            // Should never happen...
             isc_throw(BadValue, "CqlHostExchange::prepareExchange(): lower "
                       "case hostname " << lower_case_hostname_ << " of length "
                       << lower_case_hostname_.size()
index bf4602b928308e7dd236e987124c4911543485de..d4fbcf7e966824d6cba519fdf86d9cabc8f36a18 100644 (file)
@@ -339,14 +339,14 @@ TEST_F(CqlHostDataSourceTest, getAllbyHostname) {
 
 // Verifies that IPv4 host reservations with the same hostname and in
 // the same subnet can be retrieved
-TEST_F(CqlHostDataSourceTest, getAllbyHostname4) {
-    testGetAllbyHostname4();
+TEST_F(CqlHostDataSourceTest, getAllbyHostnameSubnet4) {
+    testGetAllbyHostnameSubnet4();
 }
 
 // Verifies that IPv6 host reservations with the same hostname and in
 // the same subnet can be retrieved
-TEST_F(CqlHostDataSourceTest, getAllbyHostname6) {
-    testGetAllbyHostname6();
+TEST_F(CqlHostDataSourceTest, getAllbyHostnameSubnet6) {
+    testGetAllbyHostnameSubnet6();
 }
 
 // Verifies that IPv4 host reservations in the same subnet can be retrieved
index 573cd2429766a323a692fb8f6283449946e855c6..4cd15159ddcd131b17ceeffb3c7a7958b1f584cb 100644 (file)
@@ -145,8 +145,8 @@ protected:
     /// inserted.
     /// @param data_source2 Host data source to which second reservation is
     /// inserted.
-    void testGetAllbyHostname4(BaseHostDataSource& data_source1,
-                               BaseHostDataSource& data_source2);
+    void testGetAllbyHostnameSubnet4(BaseHostDataSource& data_source1,
+                                     BaseHostDataSource& data_source2);
 
     /// @brief This test verifies that HostMgr returns all reservations for the
     /// specified hostname and DHCPv6 subnet.
@@ -158,8 +158,8 @@ protected:
     /// inserted.
     /// @param data_source2 Host data source to which second reservation is
     /// inserted.
-    void testGetAllbyHostname6(BaseHostDataSource& data_source1,
-                               BaseHostDataSource& data_source2);
+    void testGetAllbyHostnameSubnet6(BaseHostDataSource& data_source1,
+                                     BaseHostDataSource& data_source2);
 
     /// @brief This test verifies that HostMgr returns all reservations for the
     /// specified DHCPv4 subnet by pages.
@@ -456,8 +456,8 @@ HostMgrTest::testGetAllbyHostname(BaseHostDataSource& data_source1,
 }
 
 void
-HostMgrTest::testGetAllbyHostname4(BaseHostDataSource& data_source1,
-                                   BaseHostDataSource& data_source2) {
+HostMgrTest::testGetAllbyHostnameSubnet4(BaseHostDataSource& data_source1,
+                                         BaseHostDataSource& data_source2) {
     // Initially, no reservations should be present.
     ConstHostCollection hosts =
         HostMgr::instance().getAllbyHostname4("host", SubnetID(1));
@@ -505,8 +505,8 @@ HostMgrTest::testGetAllbyHostname4(BaseHostDataSource& data_source1,
 }
 
 void
-HostMgrTest::testGetAllbyHostname6(BaseHostDataSource& data_source1,
-                                   BaseHostDataSource& data_source2) {
+HostMgrTest::testGetAllbyHostnameSubnet6(BaseHostDataSource& data_source1,
+                                         BaseHostDataSource& data_source2) {
     // Initially, no reservations should be present.
     ConstHostCollection hosts =
         HostMgr::instance().getAllbyHostname6("host", SubnetID(1));
@@ -982,15 +982,15 @@ TEST_F(HostMgrTest, getAllbyHostname) {
 // This test verifies that HostMgr returns all reservations for the specified
 // hostname and DHCPv4 subnet. The reservations are defined in the server's
 // configuration.
-TEST_F(HostMgrTest, getAllbyHostname4) {
-    testGetAllbyHostname4(*getCfgHosts(), *getCfgHosts());
+TEST_F(HostMgrTest, getAllbyHostnameSubnet4) {
+    testGetAllbyHostnameSubnet4(*getCfgHosts(), *getCfgHosts());
 }
 
 // This test verifies that HostMgr returns all reservations for the specified
 // hostname and DHCPv6 subnet. The reservations are defined in the server's
 // configuration.
 TEST_F(HostMgrTest, getAllbyHostname6) {
-    testGetAllbyHostname4(*getCfgHosts(), *getCfgHosts());
+    testGetAllbyHostnameSubnet4(*getCfgHosts(), *getCfgHosts());
 }
 
 // This test verifies that HostMgr returns all reservations for the
@@ -1246,15 +1246,15 @@ TEST_F(MySQLHostMgrTest, getAllbyHostname) {
 // This test verifies that reservations for a particular hostname and
 // DHCPv4 subnet can be retrieved from the configuration file and a
 // database simultaneously.
-TEST_F(MySQLHostMgrTest, getAllbyHostname4) {
-    testGetAllbyHostname4(*getCfgHosts(), HostMgr::instance());
+TEST_F(MySQLHostMgrTest, getAllbyHostnameSubnet4) {
+    testGetAllbyHostnameSubnet4(*getCfgHosts(), HostMgr::instance());
 }
 
 // This test verifies that reservations for a particular hostname and
 // DHCPv6 subnet can be retrieved from the configuration file and a
 // database simultaneously.
-TEST_F(MySQLHostMgrTest, getAllbyHostname6) {
-    testGetAllbyHostname6(*getCfgHosts(), HostMgr::instance());
+TEST_F(MySQLHostMgrTest, getAllbyHostnameSubnet6) {
+    testGetAllbyHostnameSubnet6(*getCfgHosts(), HostMgr::instance());
 }
 
 // This test verifies that reservations for a particular subnet can
@@ -1391,15 +1391,15 @@ TEST_F(PostgreSQLHostMgrTest, getAllbyHostname) {
 // This test verifies that reservations for a particular hostname and
 // DHCPv4 subnet can be retrieved from the configuration file and a
 // database simultaneously.
-TEST_F(PostgreSQLHostMgrTest, getAllbyHostname4) {
-    testGetAllbyHostname4(*getCfgHosts(), HostMgr::instance());
+TEST_F(PostgreSQLHostMgrTest, getAllbyHostnameSubnet4) {
+    testGetAllbyHostnameSubnet4(*getCfgHosts(), HostMgr::instance());
 }
 
 // This test verifies that reservations for a particular hostname and
 // DHCPv6 subnet can be retrieved from the configuration file and a
 // database simultaneously.
-TEST_F(PostgreSQLHostMgrTest, getAllbyHostname6) {
-    testGetAllbyHostname6(*getCfgHosts(), HostMgr::instance());
+TEST_F(PostgreSQLHostMgrTest, getAllbyHostnameSubnet6) {
+    testGetAllbyHostnameSubnet6(*getCfgHosts(), HostMgr::instance());
 }
 
 // This test verifies that reservations for a particular subnet can
@@ -1517,15 +1517,15 @@ TEST_F(CQLHostMgrTest, getAllbyHostname) {
 // This test verifies that reservations for a particular hostname and
 // DHCPv4 subnet can be retrieved from the configuration file and a
 // database simultaneously.
-TEST_F(CQLHostMgrTest, getAllbyHostname4) {
-    testGetAllbyHostname4(*getCfgHosts(), HostMgr::instance());
+TEST_F(CQLHostMgrTest, getAllbyHostnameSubnet4) {
+    testGetAllbyHostnameSubnet4(*getCfgHosts(), HostMgr::instance());
 }
 
 // This test verifies that reservations for a particular hostname and
 // DHCPv6 subnet can be retrieved from the configuration file and a
 // database simultaneously.
-TEST_F(CQLHostMgrTest, getAllbyHostname6) {
-    testGetAllbyHostname6(*getCfgHosts(), HostMgr::instance());
+TEST_F(CQLHostMgrTest, getAllbyHostnameSubnet6) {
+    testGetAllbyHostnameSubnet6(*getCfgHosts(), HostMgr::instance());
 }
 
 // This test verifies that reservations for a particular subnet can
index e6e8b4506c5e953a474ecee1ee420a7176ac3bc0..54f294ad517b70ba7e387a2198422beaed43233b 100644 (file)
@@ -328,14 +328,14 @@ TEST_F(MySqlHostDataSourceTest, getAllbyHostname) {
 
 // Verifies that IPv4 host reservations with the same hostname and in
 // the same subnet can be retrieved
-TEST_F(MySqlHostDataSourceTest, getAllbyHostname4) {
-    testGetAllbyHostname4();
+TEST_F(MySqlHostDataSourceTest, getAllbyHostnameSubnet4) {
+    testGetAllbyHostnameSubnet4();
 }
 
 // Verifies that IPv6 host reservations with the same hostname and in
 // the same subnet can be retrieved
-TEST_F(MySqlHostDataSourceTest, getAllbyHostname6) {
-    testGetAllbyHostname6();
+TEST_F(MySqlHostDataSourceTest, getAllbyHostnameSubnet6) {
+    testGetAllbyHostnameSubnet6();
 }
 
 // Verifies that IPv4 host reservations in the same subnet can be retrieved
index c456940cf00b4590cd4acbe060cdf069e293ec53..e8e149d48226c5ad97439d8f35a3686025694252 100644 (file)
@@ -314,14 +314,14 @@ TEST_F(PgSqlHostDataSourceTest, getAllbyHostname) {
 
 // Verifies that IPv4 host reservations with the same hostname and in
 // the same subnet can be retrieved
-TEST_F(PgSqlHostDataSourceTest, getAllbyHostname4) {
-    testGetAllbyHostname4();
+TEST_F(PgSqlHostDataSourceTest, getAllbyHostnameSubnet4) {
+    testGetAllbyHostnameSubnet4();
 }
 
 // Verifies that IPv6 host reservations with the same hostname and in
 // the same subnet can be retrieved
-TEST_F(PgSqlHostDataSourceTest, getAllbyHostname6) {
-    testGetAllbyHostname6();
+TEST_F(PgSqlHostDataSourceTest, getAllbyHostnameSubnet6) {
+    testGetAllbyHostnameSubnet6();
 }
 
 // Verifies that IPv4 host reservations in the same subnet can be retrieved
index b3e1c144296ce0111ca1f7711b1cf2bc2f01f5fd..6638a3423d607d0686dc72aa01c8c66465ae9006 100644 (file)
@@ -525,7 +525,7 @@ GenericHostDataSourceTest::testGetAllbyHostname() {
 }
 
 void
-GenericHostDataSourceTest::testGetAllbyHostname4() {
+GenericHostDataSourceTest::testGetAllbyHostnameSubnet4() {
     // Make sure we have a pointer to the host data source.
     ASSERT_TRUE(hdsptr_);
 
@@ -549,7 +549,9 @@ GenericHostDataSourceTest::testGetAllbyHostname4() {
     HostPtr host4 = HostDataSourceUtils::initializeHost4("192.0.2.4", id);
     host4->setHostname("host.example.com");
 
-    // Set them in the same subnets.
+    HostPtr host5 = HostDataSourceUtils::initializeHost4("192.0.2.5", id);
+
+    // Set them in the same subnet at the exception of host5.
     SubnetID subnet4 = host1->getIPv4SubnetID();
     host2->setIPv4SubnetID(subnet4);
     host3->setIPv4SubnetID(subnet4);
@@ -564,6 +566,7 @@ GenericHostDataSourceTest::testGetAllbyHostname4() {
     ASSERT_NO_THROW(hdsptr_->add(host2));
     ASSERT_NO_THROW(hdsptr_->add(host3));
     ASSERT_NO_THROW(hdsptr_->add(host4));
+    ASSERT_NO_THROW(hdsptr_->add(host5));
 
     // Retrieve unknown name.
     ConstHostCollection from_hds = hdsptr_->getAllbyHostname4("foo", subnet4);
@@ -606,7 +609,7 @@ GenericHostDataSourceTest::testGetAllbyHostname4() {
 }
 
 void
-GenericHostDataSourceTest::testGetAllbyHostname6() {
+GenericHostDataSourceTest::testGetAllbyHostnameSubnet6() {
     // Make sure we have a pointer to the host data source.
     ASSERT_TRUE(hdsptr_);
 
@@ -630,7 +633,9 @@ GenericHostDataSourceTest::testGetAllbyHostname6() {
     HostPtr host4 = HostDataSourceUtils::initializeHost6("2001:db8::4", id, false);
     host4->setHostname("host.example.com");
 
-    // Set them in the same subnets.
+    HostPtr host5 = HostDataSourceUtils::initializeHost6("2001:db8::5", id, false);
+
+    // Set them in the same subnet at the exception of host5.
     SubnetID subnet4 = host1->getIPv4SubnetID();
     host2->setIPv4SubnetID(subnet4);
     host3->setIPv4SubnetID(subnet4);
@@ -645,6 +650,7 @@ GenericHostDataSourceTest::testGetAllbyHostname6() {
     ASSERT_NO_THROW(hdsptr_->add(host2));
     ASSERT_NO_THROW(hdsptr_->add(host3));
     ASSERT_NO_THROW(hdsptr_->add(host4));
+    ASSERT_NO_THROW(hdsptr_->add(host5));
 
     // Retrieve unknown name.
     ConstHostCollection from_hds = hdsptr_->getAllbyHostname6("foo", subnet6);
index 7c4103f8727f3076b63582c289fe8b0bcc28abf6..7686cf5447e6c6deb55a90ce09c3783c97774073 100644 (file)
@@ -212,13 +212,13 @@ public:
     /// hostname and in the same subnet can be retrieved properly.
     ///
     /// Uses gtest macros to report failures.
-    void testGetAllbyHostname4();
+    void testGetAllbyHostnameSubnet4();
 
     /// @brief Test that Verifies that IPv6 host reservations with the same
     /// hostname and in the same subnet can be retrieved properly.
     ///
     /// Uses gtest macros to report failures.
-    void testGetAllbyHostname6();
+    void testGetAllbyHostnameSubnet6();
 
     /// @brief Test that Verifies that pages of host reservations in the
     /// same subnet can be retrieved properly.