]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4415] updated unit tests
authorRazvan Becheriu <razvan@isc.org>
Tue, 16 Jun 2026 10:41:06 +0000 (13:41 +0300)
committerRazvan Becheriu <razvan@isc.org>
Wed, 1 Jul 2026 15:54:25 +0000 (18:54 +0300)
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/http_control_socket_unittest.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/http_control_socket_unittest.cc

index 4f30786ebfdb367f1e3f05dad7f1ca26bd795509..3d8014663b8793d785642f8cb730081d1b8f4e5e 100644 (file)
@@ -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);
 }
 
index e16911da9974dcca95e8448d023f1cea30678e1d..dc6ba77f193f7216411f21b21d480684ccfd3dea 100644 (file)
@@ -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
index 13ecc204ee4964410759e37de188d8ab59c76125..dca7040c04e3f92ad01745f26602b50d97b0b50e 100644 (file)
@@ -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();
 }
index d9e6d681cb4980e52c6119889bd1c83f3493cebc..d3de2112a62bd6934ee3fb23d9a9236fcc2c6cb2 100644 (file)
@@ -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);
 }
 
index 99fcfca51966812e2bcd0e2b05220b006a04aedc..3f542ce49b659e89c6eb5df757dd5947a457c87b 100644 (file)
@@ -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
index ead85baec56651424b842975586ef2e7c4b7cee2..0e9da280f68ff9430c90feb15fe455c0fad5df12 100644 (file)
@@ -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();
 }