From: Razvan Becheriu Date: Tue, 16 Jun 2026 10:41:06 +0000 (+0300) Subject: [#4415] updated unit tests X-Git-Tag: Kea-3.3.0~123 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8dbe58f3a6b5fbe4fc99e8a9f5fdb4a413d5e1d9;p=thirdparty%2Fkea.git [#4415] updated unit tests --- diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 4f30786ebf..3d8014663b 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -481,6 +481,10 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&, return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str())); } + if (rcode == CONTROL_RESULT_FATAL_ERROR) { + shutdownServer(EXIT_FAILURE); + } + return (result); } diff --git a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc index e16911da99..dc6ba77f19 100644 --- a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc @@ -2655,8 +2655,12 @@ TEST_F(CtrlChannelDhcpv4SrvTest, interfaceAddFatal) { std::string command = "{ \"command\": \"interface-add\", \"arguments\": { \"interfaces\": [ \"eth0\" ] } }"; + EXPECT_FALSE(server_->getShutdown()); + sendUnixCommand(command, response); EXPECT_EQ(response, "{ \"result\": 5, \"text\": \"Interface configuration update triggered a fatal error: shutting down.\" }"); + + EXPECT_TRUE(server_->getShutdown()); } // This test verifies that disable DHCP service command performs sanity check on diff --git a/src/bin/dhcp4/tests/http_control_socket_unittest.cc b/src/bin/dhcp4/tests/http_control_socket_unittest.cc index 13ecc204ee..dca7040c04 100644 --- a/src/bin/dhcp4/tests/http_control_socket_unittest.cc +++ b/src/bin/dhcp4/tests/http_control_socket_unittest.cc @@ -5115,6 +5115,8 @@ TEST_F(HttpCtrlChannelDhcpv4Test, handleHttpToHttpsSwitch) { << "}\n" // close dhcp4 << "}}"; + EXPECT_FALSE(server_->getShutdown()); + // Send the config-set command. sendHttpCommand(second_config_os.str(), response); @@ -5130,6 +5132,8 @@ TEST_F(HttpCtrlChannelDhcpv4Test, handleHttpToHttpsSwitch) { subnets = CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll(); EXPECT_EQ(1U, subnets->size()); + EXPECT_TRUE(server_->getShutdown()); + // Clean up after the test. CfgMgr::instance().clear(); } @@ -5269,6 +5273,8 @@ TEST_F(HttpsCtrlChannelDhcpv4Test, handleHttpsToHttpSwitch) { << "}\n" // close dhcp4 << "}}"; + EXPECT_FALSE(server_->getShutdown()); + // Send the config-set command. sendHttpCommand(second_config_os.str(), response); @@ -5285,6 +5291,8 @@ TEST_F(HttpsCtrlChannelDhcpv4Test, handleHttpsToHttpSwitch) { subnets = CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll(); EXPECT_EQ(1U, subnets->size()); + EXPECT_TRUE(server_->getShutdown()); + // Clean up after the test. CfgMgr::instance().clear(); } diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index d9e6d681cb..d3de2112a6 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -484,6 +484,10 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&, return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str())); } + if (rcode == CONTROL_RESULT_FATAL_ERROR) { + shutdownServer(EXIT_FAILURE); + } + return (result); } diff --git a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc index 99fcfca519..3f542ce49b 100644 --- a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc @@ -2649,8 +2649,12 @@ TEST_F(CtrlChannelDhcpv6SrvTest, interfaceAddFatal) { std::string command = "{ \"command\": \"interface-add\", \"arguments\": { \"interfaces\": [ \"eth0\" ] } }"; + EXPECT_FALSE(server_->getShutdown()); + sendUnixCommand(command, response); EXPECT_EQ(response, "{ \"result\": 5, \"text\": \"Interface configuration update triggered a fatal error: shutting down.\" }"); + + EXPECT_TRUE(server_->getShutdown()); } // This test verifies that disable DHCP service command performs sanity check on diff --git a/src/bin/dhcp6/tests/http_control_socket_unittest.cc b/src/bin/dhcp6/tests/http_control_socket_unittest.cc index ead85baec5..0e9da280f6 100644 --- a/src/bin/dhcp6/tests/http_control_socket_unittest.cc +++ b/src/bin/dhcp6/tests/http_control_socket_unittest.cc @@ -5110,6 +5110,8 @@ TEST_F(HttpCtrlChannelDhcpv6Test, handleHttpToHttpsSwitch) { << "}\n" // close dhcp6 << "}}"; + EXPECT_FALSE(server_->getShutdown()); + // Send the config-set command. sendHttpCommand(second_config_os.str(), response); @@ -5125,6 +5127,8 @@ TEST_F(HttpCtrlChannelDhcpv6Test, handleHttpToHttpsSwitch) { subnets = CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll(); EXPECT_EQ(1U, subnets->size()); + EXPECT_TRUE(server_->getShutdown()); + // Clean up after the test. CfgMgr::instance().clear(); } @@ -5265,6 +5269,8 @@ TEST_F(HttpsCtrlChannelDhcpv6Test, handleHttpsToHttpSwitch) { << "}\n" // close dhcp6 << "}}"; + EXPECT_FALSE(server_->getShutdown()); + // Send the config-set command. sendHttpCommand(second_config_os.str(), response); @@ -5281,6 +5287,8 @@ TEST_F(HttpsCtrlChannelDhcpv6Test, handleHttpsToHttpSwitch) { subnets = CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll(); EXPECT_EQ(1U, subnets->size()); + EXPECT_TRUE(server_->getShutdown()); + // Clean up after the test. CfgMgr::instance().clear(); }