]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4094] Checkpoint: added server UTs
authorFrancis Dupont <fdupont@isc.org>
Fri, 12 Sep 2025 09:08:32 +0000 (11:08 +0200)
committerFrancis Dupont <fdupont@isc.org>
Mon, 15 Sep 2025 19:44:28 +0000 (21:44 +0200)
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/http_control_socket_unittest.cc
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/http_control_socket_unittest.cc

index bfd5c6b8c59ddedfe2be423a056c7787c4339738..493611ac729bd8716fa7ba95328284cae3722ae7 100644 (file)
@@ -3563,6 +3563,29 @@ TEST_F(CtrlChannelDhcpv4SrvTest, subnet4o6SelectTestIface) {
     EXPECT_EQ(expected, response);
 }
 
+/// Verify that kea-lfc-start requires a lease backend.
+TEST_F(CtrlChannelDhcpv4SrvTest, keaLfcStartNoBackend) {
+    ASSERT_NO_THROW(server_.reset(new NakedControlledDhcpv4Srv()));
+    ConstElementPtr command = createCommand("kea-lfc-start");
+    ConstElementPtr response;
+    ASSERT_NO_THROW(response = CommandMgr::instance().processCommand(command));
+    ASSERT_TRUE(response);
+    EXPECT_EQ("{ \"result\": 2, \"text\": \"no lease backend\" }",
+              response->str());
+}
+
+/// Verify that kea-lfc-start requires persist true.
+TEST_F(CtrlChannelDhcpv4SrvTest, keaLfcStartPersistFalse) {
+    createUnixChannelServer();
+    std::string response;
+
+    sendUnixCommand("{ \"command\" : \"kea-lfc-start\" }", response);
+    std::string expected = "{ \"result\": 2, \"text\": ";
+    expected += "\"'persist` parameter of `memfile` lease backend ";
+    expected += "was configured to `false`\" }";
+    EXPECT_EQ(expected, response);
+}
+
 /// Verify that concurrent connections over the control channel can be
 ///  established.
 /// @todo Future Kea 1.3 tickets will modify the behavior of the CommandMgr
index dfb92b354c4ff6c0b25a2b6520fb6928d21ce30b..1197d6ca8027c56e4104a963a5287637000b2208 100644 (file)
@@ -571,6 +571,9 @@ public:
     // the origin-id.
     void testDhcpEnableOriginId();
 
+    // This test verifies that kea-lfc-start requires persist true.
+    void testKeaLfcStartPersistFalse();
+
     // This test verifies that the server can receive and process a
     // large command.
     void testLongCommand();
@@ -3522,6 +3525,27 @@ TEST_F(HttpsCtrlChannelDhcpv4Test, dhcpEnableOriginId) {
     testDhcpEnableOriginId();
 }
 
+/// Verify that kea-lfc-start requires persist true.
+void
+BaseCtrlChannelDhcpv4Test::testKeaLfcStartPersistFalse() {
+    createHttpChannelServer();
+    std::string response;
+
+    sendHttpCommand("{ \"command\" : \"kea-lfc-start\" }", response);
+    std::string expected = "[ { \"result\": 2, \"text\": ";
+    expected += "\"'persist` parameter of `memfile` lease backend ";
+    expected += "was configured to `false`\" } ]";
+    EXPECT_EQ(expected, response);
+}
+
+TEST_F(HttpCtrlChannelDhcpv4Test, keaLfcStartPersistFalse) {
+    testKeaLfcStartPersistFalse();
+}
+
+TEST_F(HttpsCtrlChannelDhcpv4Test, keaLfcStartPersistFalse) {
+    testKeaLfcStartPersistFalse();
+}
+
 /// Verify that concurrent connections over the HTTP control channel can be
 /// established.
 TEST_F(HttpCtrlChannelDhcpv4Test, concurrentConnections) {
index 9618ff51ff89e1c1779c385d8da24eef757b5834..c3a993b43d7c5de98823ccb54bd1a077cef4f031 100644 (file)
@@ -2850,6 +2850,29 @@ TEST_F(CtrlChannelDhcpv6SrvTest, subnet6SelectTestClass) {
     EXPECT_EQ(expected, response);
 }
 
+/// Verify that kea-lfc-start requires a lease backend.
+TEST_F(CtrlChannelDhcpv6SrvTest, keaLfcStartNoBackend) {
+    ASSERT_NO_THROW(server_.reset(new NakedControlledDhcpv6Srv()));
+    ConstElementPtr command = createCommand("kea-lfc-start");
+    ConstElementPtr response;
+    ASSERT_NO_THROW(response = CommandMgr::instance().processCommand(command));
+    ASSERT_TRUE(response);
+    EXPECT_EQ("{ \"result\": 2, \"text\": \"no lease backend\" }",
+              response->str());
+}
+
+/// Verify that kea-lfc-start requires persist true.
+TEST_F(CtrlChannelDhcpv6SrvTest, keaLfcStartPersistFalse) {
+    createUnixChannelServer();
+    std::string response;
+
+    sendUnixCommand("{ \"command\" : \"kea-lfc-start\" }", response);
+    std::string expected = "{ \"result\": 2, \"text\": ";
+    expected += "\"'persist` parameter of `memfile` lease backend ";
+    expected += "was configured to `false`\" }";
+    EXPECT_EQ(expected, response);
+}
+
 /// Verify that concurrent connections over the control channel can be
 ///  established.
 /// @todo Future Kea 1.3 tickets will modify the behavior of the CommandMgr
index 8be9d533a67b396ddee531340a885080b8a00983..269a1ecc7ece264bdbc09a31baba118e2323fdb4 100644 (file)
@@ -582,6 +582,9 @@ public:
     // the origin-id.
     void testDhcpEnableOriginId();
 
+    // This test verifies that kea-lfc-start requires persist true.
+    void testKeaLfcStartPersistFalse();
+
     // This test verifies that the server can receive and process a
     // large command.
     void testLongCommand();
@@ -3518,6 +3521,27 @@ TEST_F(HttpsCtrlChannelDhcpv6Test, dhcpEnableOriginId) {
     testDhcpEnableOriginId();
 }
 
+/// Verify that kea-lfc-start requires persist true.
+void
+BaseCtrlChannelDhcpv6Test::testKeaLfcStartPersistFalse() {
+    createHttpChannelServer();
+    std::string response;
+
+    sendHttpCommand("{ \"command\" : \"kea-lfc-start\" }", response);
+    std::string expected = "[ { \"result\": 2, \"text\": ";
+    expected += "\"'persist` parameter of `memfile` lease backend ";
+    expected += "was configured to `false`\" } ]";
+    EXPECT_EQ(expected, response);
+}
+
+TEST_F(HttpCtrlChannelDhcpv6Test, keaLfcStartPersistFalse) {
+    testKeaLfcStartPersistFalse();
+}
+
+TEST_F(HttpsCtrlChannelDhcpv6Test, keaLfcStartPersistFalse) {
+    testKeaLfcStartPersistFalse();
+}
+
 /// Verify that concurrent connections over the HTTP control channel can be
 /// established.
 TEST_F(HttpCtrlChannelDhcpv6Test, concurrentConnections) {