diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc index de9f5ee6ba..b9e3b19462 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc @@ -2941,7 +2941,7 @@ MySqlConfigBackendDHCPv4::deleteSharedNetworkSubnets4(const db::ServerSelector& const std::string& shared_network_name) { if (!server_selector.amAny()) { isc_throw(InvalidOperation, "deleting all subnets from a shared " - "network is defined only using ANY server"); + "network requires using ANY server selector"); } LOG_DEBUG(mysql_cb_logger, DBGLVL_TRACE_BASIC, MYSQL_CB_DELETE_SHARED_NETWORK_SUBNETS4) .arg(shared_network_name); diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc index 2e4ae9d149..6b8fdfde18 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc @@ -3321,7 +3321,7 @@ MySqlConfigBackendDHCPv6::deleteSharedNetworkSubnets6(const db::ServerSelector& const std::string& shared_network_name) { if (!server_selector.amAny()) { isc_throw(InvalidOperation, "deleting all subnets from a shared " - "network is defined only using ANY server"); + "network requires using ANY server selector"); } LOG_DEBUG(mysql_cb_logger, DBGLVL_TRACE_BASIC, MYSQL_CB_DELETE_SHARED_NETWORK_SUBNETS6) .arg(shared_network_name); diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc index 9c7a4a8944..f562bf1a77 100644 --- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc +++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc @@ -2231,6 +2231,19 @@ TEST_F(MySqlConfigBackendDHCPv4Test, getAllSharedNetworks4) { EXPECT_EQ(0, cbptr_->deleteAllSharedNetworks4(ServerSelector::ONE("server1"))); // Delete first shared network with it subnets and verify it is gone. + // It requires ANY so verifies that all other choices throw. + EXPECT_THROW(cbptr_->deleteSharedNetworkSubnets4(ServerSelector::UNASSIGNED(), + test_networks_[1]->getName()), + isc::InvalidOperation); + EXPECT_THROW(cbptr_->deleteSharedNetworkSubnets4(ServerSelector::ALL(), + test_networks_[1]->getName()), + isc::InvalidOperation); + EXPECT_THROW(cbptr_->deleteSharedNetworkSubnets4(ServerSelector::ONE("server1"), + test_networks_[1]->getName()), + isc::InvalidOperation); + EXPECT_THROW(cbptr_->deleteSharedNetworkSubnets4(ServerSelector::MULTIPLE({ "server1", "server2" }), + test_networks_[1]->getName()), + isc::InvalidOperation); // Begin by its subnet. EXPECT_EQ(1, cbptr_->deleteSharedNetworkSubnets4(ServerSelector::ANY(), diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc index 705b81ddf5..b5fdc39c00 100644 --- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc +++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc @@ -2246,6 +2246,19 @@ TEST_F(MySqlConfigBackendDHCPv6Test, getAllSharedNetworks6) { EXPECT_EQ(0, cbptr_->deleteAllSharedNetworks6(ServerSelector::ONE("server1"))); // Delete first shared network with it subnets and verify it is gone. + // It requires ANY so verifies that all other choices throw. + EXPECT_THROW(cbptr_->deleteSharedNetworkSubnets6(ServerSelector::UNASSIGNED(), + test_networks_[1]->getName()), + isc::InvalidOperation); + EXPECT_THROW(cbptr_->deleteSharedNetworkSubnets6(ServerSelector::ALL(), + test_networks_[1]->getName()), + isc::InvalidOperation); + EXPECT_THROW(cbptr_->deleteSharedNetworkSubnets6(ServerSelector::ONE("server1"), + test_networks_[1]->getName()), + isc::InvalidOperation); + EXPECT_THROW(cbptr_->deleteSharedNetworkSubnets6(ServerSelector::MULTIPLE({ "server1", "server2" }), + test_networks_[1]->getName()), + isc::InvalidOperation); // Begin by its subnet. EXPECT_EQ(1, cbptr_->deleteSharedNetworkSubnets6(ServerSelector::ANY(),