]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3477] Addressed comments
authorFrancis Dupont <fdupont@isc.org>
Tue, 30 Jul 2024 08:39:37 +0000 (10:39 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 1 Aug 2024 07:23:54 +0000 (09:23 +0200)
src/bin/d2/tests/d2_command_unittest.cc
src/bin/d2/tests/d2_http_command_unittest.cc
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
src/lib/config/tests/cmd_http_listener_unittests.cc
src/lib/config/tests/http_command_mgr_unittests.cc
src/lib/d2srv/d2_cfg_mgr.h

index 6b3a0272b83668916fdffcd1bd5b894af731d4ea..90869db6aad75870ba46289a0ae1ff3aa596898b 100644 (file)
@@ -54,7 +54,9 @@ public:
         return (controller_ptr);
     }
 
-    virtual ~NakedD2Controller() { deregisterCommands(); }
+    virtual ~NakedD2Controller() {
+        deregisterCommands();
+    }
 
     using DControllerBase::getIOService;
     using DControllerBase::initProcess;
@@ -67,8 +69,8 @@ private:
     NakedD2Controller() { }
 };
 
-}; // namespace isc::d2
-}; // namespace isc
+} // namespace isc::d2
+} // namespace isc
 
 namespace {
 
@@ -148,7 +150,7 @@ public:
     /// @brief Returns pointer to the server's IO service.
     ///
     /// @return Pointer to the server's IO service or null pointer if the
-    /// hasn't been created server.
+    /// server hasn't been created.
     IOServicePtr getIOService() {
         return (server_ ? d2Controller()->getIOService() : IOServicePtr());
     }
@@ -288,12 +290,11 @@ public:
 
     /// @brief Check if the answer for config-write command is correct.
     ///
-    /// @param response_txt response in text form.
-    ///        (as read from the control socket)
-    /// @param exp_status expected status.
-    ///        (0 success, 1 failure)
+    /// @param response_txt response in text form (as read from
+    /// the control socket).
+    /// @param exp_status expected status (0 success, 1 failure).
     /// @param exp_txt for success cases this defines the expected filename,
-    ///        for failure cases this defines the expected error message.
+    /// for failure cases this defines the expected error message.
     void checkConfigWrite(const string& response_txt, int exp_status,
                           const string& exp_txt = "") {
 
@@ -572,7 +573,7 @@ TEST_F(CtrlChannelD2Test, shutdownExitValue) {
     EXPECT_EQ(77, server_->getExitValue());
 }
 
-// This test verifies that the DHCP server handles version-get commands.
+// This test verifies that the D2 server handles version-get commands.
 TEST_F(CtrlChannelD2Test, getversion) {
     EXPECT_NO_THROW(createUnixChannelServer());
     string response;
@@ -617,13 +618,13 @@ TEST_F(CtrlChannelD2Test, listCommands) {
     checkListCommands(rsp, "version-get");
 }
 
-// This test verifies that the D2 server handles status-get commands
+// This test verifies that the D2 server handles status-get commands.
 TEST_F(CtrlChannelD2Test, statusGet) {
     EXPECT_NO_THROW(createUnixChannelServer());
 
     std::string response_txt;
 
-    // Send the version-get command
+    // Send the status-get command.
     sendUnixCommand("{ \"command\": \"status-get\" }", response_txt);
     ConstElementPtr response;
     ASSERT_NO_THROW(response = Element::fromJSON(response_txt));
@@ -788,7 +789,7 @@ TEST_F(CtrlChannelD2Test, configTest) {
 
     ASSERT_GT(CommandMgr::instance().getControlSocketFD(), -1);
 
-    // Create a config with malformed subnet that should fail to parse.
+    // Create a config with invalid content that should fail to parse.
     os.str("");
     os << config_test_txt << ","
        << args_txt
@@ -927,7 +928,7 @@ TEST_F(CtrlChannelD2Test, configSet) {
 
     ASSERT_GT(CommandMgr::instance().getControlSocketFD(), -1);
 
-    // Create a config with malformed subnet that should fail to parse.
+    // Create a config with invalid content that should fail to parse.
     os.str("");
     os << config_set_txt << ","
        << args_txt
@@ -1013,6 +1014,7 @@ TEST_F(CtrlChannelD2Test, writeConfigFilename) {
     sendUnixCommand("{ \"command\": \"config-write\", "
                     "\"arguments\": { \"filename\": \"test2.json\" } }",
                     response);
+
     checkConfigWrite(response, CONTROL_RESULT_SUCCESS, "test2.json");
     ::remove("test2.json");
 }
@@ -1056,7 +1058,6 @@ TEST_F(CtrlChannelD2Test, configReloadBrokenFile) {
 
     // Tell the server to reload its configuration. It should attempt to load
     // testbad.json (and fail, because the file is not valid JSON).
-    // does-not-exist.json (and fail, because the file is not there).
     sendUnixCommand("{ \"command\": \"config-reload\" }", response);
 
     // Verify the reload was rejected.
@@ -1070,7 +1071,7 @@ TEST_F(CtrlChannelD2Test, configReloadBrokenFile) {
 }
 
 // Tests if config-reload attempts to reload a file and reports that the
-// file is missing.
+// file is loaded correctly.
 TEST_F(CtrlChannelD2Test, configReloadFileValid) {
     EXPECT_NO_THROW(createUnixChannelServer());
     string response;
index f1ec524f5699e075271b81c112673ffcf939879c..5736a0713f6a905f3b3fc1532e5c70d16a0ba99d 100644 (file)
@@ -54,7 +54,9 @@ public:
         return (controller_ptr);
     }
 
-    virtual ~NakedD2Controller() { deregisterCommands(); }
+    virtual ~NakedD2Controller() {
+        deregisterCommands();
+    }
 
     using DControllerBase::getIOService;
     using DControllerBase::initProcess;
@@ -67,8 +69,8 @@ private:
     NakedD2Controller() { }
 };
 
-}; // namespace isc::d2
-}; // namespace isc
+} // namespace isc::d2
+} // namespace isc
 
 namespace {
 
@@ -118,7 +120,7 @@ public:
     /// @brief Returns pointer to the server's IO service.
     ///
     /// @return Pointer to the server's IO service or null pointer if the
-    /// hasn't been created server.
+    /// server hasn't been created.
     IOServicePtr getIOService() {
         return (server_ ? d2Controller()->getIOService() : IOServicePtr());
     }
@@ -229,8 +231,7 @@ public:
     /// @param response_str a string containing the whole HTTP
     /// response received.
     ///
-    /// @return An HttpResponse constructed from by parsing the
-    /// response string.
+    /// @return An HttpResponse constructed by parsing the response string.
     HttpResponsePtr parseResponse(const std::string response_str) {
         HttpResponsePtr hr(new HttpResponse());
         HttpResponseParser parser(*hr);
@@ -286,7 +287,7 @@ public:
     /// @brief Parse list answer.
     ///
     /// Clone of parseAnswer but taking the answer as a list and
-    /// decapulating it.
+    /// decapsulating it.
     ///
     /// @param rcode Return code.
     /// @param msg_list The message to parse.
@@ -374,12 +375,11 @@ public:
 
     /// @brief Check if the answer for config-write command is correct.
     ///
-    /// @param response_txt response in text form.
-    ///        (as read from the control socket)
-    /// @param exp_status expected status.
-    ///        (0 success, 1 failure)
+    /// @param response_txt response in text form (as read from
+    /// the control socket).
+    /// @param exp_status expected status (0 success, 1 failure).
     /// @param exp_txt for success cases this defines the expected filename,
-    ///        for failure cases this defines the expected error message.
+    /// for failure cases this defines the expected error message.
     void checkConfigWrite(const string& response_txt, int exp_status,
                           const string& exp_txt = "") {
 
@@ -455,7 +455,7 @@ public:
         // let's parse expected_command back to JSON to guarantee that
         // both structures are built using the same order.
         EXPECT_EQ(Element::fromJSON(expected_command)->str(),
-                 entire_command->str());
+                  entire_command->str());
         return (createAnswer(CONTROL_RESULT_SUCCESS, "long command received ok"));
     }
 
@@ -518,7 +518,7 @@ TEST_F(HttpCtrlChannelD2Test, shutdownExitValue) {
     EXPECT_EQ(77, server_->getExitValue());
 }
 
-// This test verifies that the DHCP server handles version-get commands.
+// This test verifies that the D2 server handles version-get commands.
 TEST_F(HttpCtrlChannelD2Test, getversion) {
     EXPECT_NO_THROW(createHttpChannelServer());
     string response;
@@ -563,13 +563,13 @@ TEST_F(HttpCtrlChannelD2Test, listCommands) {
     checkListCommands(rsp, "version-get");
 }
 
-// This test verifies that the D2 server handles status-get commands
+// This test verifies that the D2 server handles status-get commands.
 TEST_F(HttpCtrlChannelD2Test, statusGet) {
     EXPECT_NO_THROW(createHttpChannelServer());
 
     std::string response_txt;
 
-    // Send the version-get command
+    // Send the status-get command.
     sendHttpCommand("{ \"command\": \"status-get\" }", response_txt);
     ConstElementPtr response_list;
     ASSERT_NO_THROW(response_list = Element::fromJSON(response_txt));
@@ -646,7 +646,7 @@ TEST_F(HttpCtrlChannelD2Test, configHashGet) {
     int status;
     ConstElementPtr args = parseListAnswer(status, rsp);
     EXPECT_EQ(CONTROL_RESULT_SUCCESS, status);
-    // the parseListAnswer is trying to be smart with ignoring hash.
+    // The parseListAnswer is trying to be smart with ignoring hash.
     // But this time we really want to see the hash, so we'll retrieve
     // the arguments manually.
     ASSERT_NO_THROW(args = rsp->get(0)->get(CONTROL_ARGUMENTS));
@@ -706,7 +706,7 @@ TEST_F(HttpCtrlChannelD2Test, configTest) {
 
     ASSERT_TRUE(HttpCommandMgr::instance().getHttpListener());
 
-    // Create a config with malformed subnet that should fail to parse.
+    // Create a config with invalid content that should fail to parse.
     string config_test_txt =
         "{ \"command\": \"config-test\", \n"
         "  \"arguments\": { \n"
@@ -824,7 +824,7 @@ TEST_F(HttpCtrlChannelD2Test, configSet) {
 
     ASSERT_TRUE(HttpCommandMgr::instance().getHttpListener());
 
-    // Create a config with malformed subnet that should fail to parse.
+    // Create a config with invalid content that should fail to parse.
     string config_test_txt =
         "{ \"command\": \"config-set\", \n"
         "  \"arguments\": { \n"
@@ -929,6 +929,7 @@ TEST_F(HttpCtrlChannelD2Test, writeConfigFilename) {
     sendHttpCommand("{ \"command\": \"config-write\", "
                     "\"arguments\": { \"filename\": \"test2.json\" } }",
                     response);
+
     checkConfigWrite(response, CONTROL_RESULT_SUCCESS, "test2.json");
     ::remove("test2.json");
 }
@@ -972,7 +973,6 @@ TEST_F(HttpCtrlChannelD2Test, configReloadBrokenFile) {
 
     // Tell the server to reload its configuration. It should attempt to load
     // testbad.json (and fail, because the file is not valid JSON).
-    // does-not-exist.json (and fail, because the file is not there).
     sendHttpCommand("{ \"command\": \"config-reload\" }", response);
 
     // Verify the reload was rejected.
@@ -986,7 +986,7 @@ TEST_F(HttpCtrlChannelD2Test, configReloadBrokenFile) {
 }
 
 // Tests if config-reload attempts to reload a file and reports that the
-// file is missing.
+// file is loaded correctly.
 TEST_F(HttpCtrlChannelD2Test, configReloadFileValid) {
     EXPECT_NO_THROW(createHttpChannelServer());
     string response;
@@ -1161,7 +1161,7 @@ TEST_F(HttpCtrlChannelD2Test, longResponse) {
 
     createHttpChannelServer();
 
-    // The entire response should be received but anayway check it.
+    // The entire response should be received but anyway check it.
     ConstElementPtr raw_response =
         longResponseHandler("foo", ConstElementPtr());
     ElementPtr json_response = Element::createList();
index 64769cc0542608c0fc278f28c31fd1d66a086a19..cab13a1758d75441a56bbedcc1573e48fe251609 100644 (file)
@@ -248,9 +248,9 @@ public:
     ///
     /// This method connects to the given server over the given socket path.
     /// If successful, it then sends the given command and retrieves the
-    /// server's response.  Note that it calls the server's receivePacket()
-    /// method where needed to cause the server to process IO events on
-    /// control channel the control channel sockets.
+    /// server's response.  Note that it polls the server's I/O service
+    /// where needed to cause the server to process IO events on
+    /// the control channel sockets.
     ///
     /// @param command the command text to execute in JSON form
     /// @param response variable into which the received response should be
@@ -575,7 +575,6 @@ TEST_F(CtrlChannelDhcpv4SrvTest, controlChannelStats) {
         "v4-lease-reuses",
     };
 
-    // preparing the schema which check if all statistics are set to zero
     std::ostringstream s;
     s << "{ \"arguments\": { ";
     bool first = true;
@@ -1396,7 +1395,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, controlLeasesReclaimRemove) {
     ASSERT_FALSE(lease1);
 }
 
-// Tests that the server properly responds to shutdown command sent
+// Tests that the server properly responds to list-commands command sent
 // via ControlChannel
 TEST_F(CtrlChannelDhcpv4SrvTest, listCommands) {
     createUnixChannelServer();
index baa4ad8cd6c605d2b02946d083eec09a3d4d302c..c60e1af1539047bcca72db59f339c629aa1652bf 100644 (file)
@@ -263,8 +263,7 @@ public:
     /// @param response_str a string containing the whole HTTP
     /// response received.
     ///
-    /// @return An HttpResponse constructed from by parsing the
-    /// response string.
+    /// @return An HttpResponse constructed from parsing the response string.
     HttpResponsePtr parseResponse(const std::string response_str) {
         HttpResponsePtr hr(new HttpResponse());
         HttpResponseParser parser(*hr);
@@ -279,13 +278,13 @@ public:
         return (hr);
     }
 
-    /// @brief Conducts a command/response exchange via HttpCommandSocket
+    /// @brief Conducts a command/response exchange via HttpCommandSocket.
     ///
     /// This method connects to the given server over the given address/port.
     /// If successful, it then sends the given command and retrieves the
-    /// server's response.  Note that it calls the server's receivePacket()
-    /// method where needed to cause the server to process IO events on
-    /// control channel the control channel sockets.
+    /// server's response.  Note that it polls the server's I/O service
+    /// where needed to cause the server to process IO events on
+    /// the control channel sockets.
     ///
     /// @param command the command text to execute in JSON form.
     /// @param response variable into which the received response should be
@@ -300,7 +299,7 @@ public:
         ASSERT_TRUE(client);
 
         // Send the command. This will trigger server's handler which receives
-        // data over the unix domain socket. The server will start sending
+        // data over the HTTP socket. The server will start sending
         // response to the client.
         ASSERT_NO_THROW(client->startRequest(buildPostStr(command)));
         runIOService();
@@ -320,7 +319,7 @@ public:
     /// @brief Parse list answer.
     ///
     /// Clone of parseAnswer but taking the answer as a list and
-    /// decapulating it.
+    /// decapsulating it.
     ///
     /// @param rcode Return code.
     /// @param msg_list The message to parse.
@@ -376,12 +375,12 @@ public:
         return (msg->get(CONTROL_TEXT));
     }
 
-    /// @brief Checks response for list-commands
+    /// @brief Checks response for list-commands.
     ///
     /// This method checks if the list-commands response is generally sane
     /// and whether specified command is mentioned in the response.
     ///
-    /// @param rsp response sent back by the server
+    /// @param rsp response sent back by the server.
     /// @param command command expected to be on the list.
     void checkListCommands(const ConstElementPtr& rsp, const std::string& command) {
         ConstElementPtr params;
@@ -395,8 +394,9 @@ public:
         for (size_t i = 0; i < params->size(); ++i) {
             string tmp = params->get(i)->stringValue();
             if (tmp == command) {
-                // Command found, but that's not enough. Need to continue working
-                // through the list to see if there are no duplicates.
+                // Command found, but that's not enough.
+                // Need to continue working through the list to see
+                // if there are no duplicates.
                 cnt++;
             }
         }
@@ -405,7 +405,7 @@ public:
         EXPECT_EQ(1, cnt) << "Command " << command << " not found";
     }
 
-    /// @brief Check if the answer for write-config command is correct
+    /// @brief Check if the answer for write-config command is correct.
     ///
     /// @param response_txt response in text form (as read from the control socket)
     /// @param exp_status expected status (0 success, 1 failure)
@@ -495,8 +495,8 @@ public:
     /// This handler generates a large response (over 4kB). It includes
     /// a list of randomly generated strings to make sure that the test
     /// can catch out of order delivery.
-    static ConstElementPtr longResponseHandler(const std::string&,
-                                               const ConstElementPtr&) {
+    static ConstElementPtr
+    longResponseHandler(const std::string&, const ConstElementPtr&) {
         ElementPtr arguments = Element::createList();
         for (unsigned i = 0; i < 800; ++i) { // was 80000 (400kB).
             std::ostringstream s;
@@ -531,6 +531,8 @@ TEST_F(HttpCtrlChannelDhcpv4Test, controlChannelShutdown) {
     sendHttpCommand("{ \"command\": \"shutdown\" }", response);
     EXPECT_EQ("[ { \"result\": 0, \"text\": \"Shutting down.\" } ]",
               response);
+
+    EXPECT_EQ(EXIT_SUCCESS, server_->getExitValue());
 }
 
 // Tests that the server properly responds to statistics commands.  Note this
@@ -577,7 +579,6 @@ TEST_F(HttpCtrlChannelDhcpv4Test, controlChannelStats) {
         "v4-lease-reuses",
     };
 
-    // preparing the schema which check if all statistics are set to zero
     std::ostringstream s;
     s << "[ { \"arguments\": { ";
     bool first = true;
@@ -861,7 +862,7 @@ TEST_F(HttpCtrlChannelDhcpv4Test, configHashGet) {
     int status;
     ConstElementPtr args = parseListAnswer(status, rsp);
     EXPECT_EQ(CONTROL_RESULT_SUCCESS, status);
-    // the parseListAnswer is trying to be smart with ignoring hash.
+    // The parseListAnswer is trying to be smart with ignoring hash.
     // But this time we really want to see the hash, so we'll retrieve
     // the arguments manually.
     args = rsp->get(0)->get(CONTROL_ARGUMENTS);
@@ -1016,6 +1017,7 @@ TEST_F(HttpCtrlChannelDhcpv4Test, configTest) {
     // Clean up after the test.
     CfgMgr::instance().clear();
 }
+
 // This test verifies that the DHCP server handles version-get commands
 TEST_F(HttpCtrlChannelDhcpv4Test, getVersion) {
     createHttpChannelServer();
@@ -1409,7 +1411,7 @@ TEST_F(HttpCtrlChannelDhcpv4Test, controlLeasesReclaimRemove) {
     ASSERT_FALSE(lease1);
 }
 
-// Tests that the server properly responds to shutdown command sent
+// Tests that the server properly responds to list-commands command sent
 // via ControlChannel
 TEST_F(HttpCtrlChannelDhcpv4Test, listCommands) {
     createHttpChannelServer();
@@ -2194,7 +2196,7 @@ TEST_F(HttpCtrlChannelDhcpv4Test, longResponse) {
 
     createHttpChannelServer();
 
-    // The entire response should be received but anayway check it.
+    // The entire response should be received but anyway check it.
     ConstElementPtr raw_response =
         longResponseHandler("foo", ConstElementPtr());
     ElementPtr json_response = Element::createList();
index 7d28a6e9a15e188d10424558fea845e0b0158459..5e87c483e5177a7336cb9c999acbca82bc11d4ec 100644 (file)
@@ -273,9 +273,9 @@ public:
     ///
     /// This method connects to the given server over the given socket path.
     /// If successful, it then sends the given command and retrieves the
-    /// server's response.  Note that it calls the server's receivePacket()
-    /// method where needed to cause the server to process IO events on
-    /// control channel the control channel sockets.
+    /// server's response.  Note that it polls the server's I/O service
+    /// where needed to cause the server to process IO events on
+    /// the control channel sockets.
     ///
     /// @param command the command text to execute in JSON form
     /// @param response variable into which the received response should be
@@ -1432,7 +1432,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, controlChannelStats) {
               response);
 }
 
-// Tests that the server properly responds to shutdown command sent
+// Tests that the server properly responds to list-commands command sent
 // via ControlChannel
 TEST_F(CtrlChannelDhcpv6SrvTest, listCommands) {
     createUnixChannelServer();
index fcd2b945f9996bd8d976995a9790b01e694fc0b9..25628f2d38d8450f574e233905e01820201b77ea 100644 (file)
@@ -112,6 +112,7 @@ public:
         // Get rid of any marker files.
         static_cast<void>(remove(LOAD_MARKER_FILE));
         static_cast<void>(remove(UNLOAD_MARKER_FILE));
+
         IfaceMgr::instance().deleteAllExternalSockets();
         CfgMgr::instance().clear();
     }
@@ -145,7 +146,7 @@ public:
             HttpCommandMgr::instance().close();
         }
         CommandMgr::instance().deregisterAll();
-        CommandMgr::instance().setConnectionTimeout(TIMEOUT_DHCP_SERVER_RECEIVE_COMMAND);
+        HttpCommandMgr::instance().setConnectionTimeout(TIMEOUT_DHCP_SERVER_RECEIVE_COMMAND);
 
         server_.reset();
         reset();
@@ -288,8 +289,7 @@ public:
     /// @param response_str a string containing the whole HTTP
     /// response received.
     ///
-    /// @return An HttpResponse constructed from by parsing the
-    /// response string.
+    /// @return An HttpResponse constructed by parsing the response string.
     HttpResponsePtr parseResponse(const std::string response_str) {
         HttpResponsePtr hr(new HttpResponse());
         HttpResponseParser parser(*hr);
@@ -304,13 +304,13 @@ public:
         return (hr);
     }
 
-    /// @brief Conducts a command/response exchange via HttpCommandSocket
+    /// @brief Conducts a command/response exchange via HttpCommandSocket.
     ///
     /// This method connects to the given server over the given address/port.
     /// If successful, it then sends the given command and retrieves the
-    /// server's response.  Note that it calls the server's receivePacket()
-    /// method where needed to cause the server to process IO events on
-    /// control channel the control channel sockets.
+    /// server's response.  Note that it polls the server's I/O service
+    /// where needed to cause the server to process IO events on
+    /// the control channel sockets.
     ///
     /// @param command the command text to execute in JSON form.
     /// @param response variable into which the received response should be
@@ -325,7 +325,7 @@ public:
         ASSERT_TRUE(client);
 
         // Send the command. This will trigger server's handler which receives
-        // data over the unix domain socket. The server will start sending
+        // data over the HTTP domain socket. The server will start sending
         // response to the client.
         ASSERT_NO_THROW(client->startRequest(buildPostStr(command)));
         runIOService();
@@ -345,7 +345,7 @@ public:
     /// @brief Parse list answer.
     ///
     /// Clone of parseAnswer but taking the answer as a list and
-    /// decapulating it.
+    /// decapsulating it.
     ///
     /// @param rcode Return code.
     /// @param msg_list The message to parse.
@@ -401,12 +401,12 @@ public:
         return (msg->get(CONTROL_TEXT));
     }
 
-    /// @brief Checks response for list-commands
+    /// @brief Checks response for list-commands.
     ///
     /// This method checks if the list-commands response is generally sane
     /// and whether specified command is mentioned in the response.
     ///
-    /// @param rsp response sent back by the server
+    /// @param rsp response sent back by the server.
     /// @param command command expected to be on the list.
     void checkListCommands(const ConstElementPtr& rsp, const std::string& command) {
         ConstElementPtr params;
@@ -420,8 +420,9 @@ public:
         for (size_t i = 0; i < params->size(); ++i) {
             string tmp = params->get(i)->stringValue();
             if (tmp == command) {
-                // Command found, but that's not enough. Need to continue working
-                // through the list to see if there are no duplicates.
+                // Command found, but that's not enough.
+                // Need to continue working through the list to see
+                // if there are no duplicates.
                 cnt++;
             }
         }
@@ -430,7 +431,7 @@ public:
         EXPECT_EQ(1, cnt) << "Command " << command << " not found";
     }
 
-    /// @brief Check if the answer for write-config command is correct
+    /// @brief Check if the answer for write-config command is correct.
     ///
     /// @param response_txt response in text form (as read from the control socket)
     /// @param exp_status expected status (0 success, 1 failure)
@@ -520,8 +521,8 @@ public:
     /// This handler generates a large response (over 4kB). It includes
     /// a list of randomly generated strings to make sure that the test
     /// can catch out of order delivery.
-    static ConstElementPtr longResponseHandler(const std::string&,
-                                               const ConstElementPtr&) {
+    static ConstElementPtr
+    longResponseHandler(const std::string&, const ConstElementPtr&) {
         ElementPtr arguments = Element::createList();
         for (unsigned i = 0; i < 800; ++i) { // was 80000 (400kB).
             std::ostringstream s;
@@ -554,7 +555,9 @@ TEST_F(HttpCtrlChannelDhcpv6Test, controlChannelShutdown) {
     std::string response;
 
     sendHttpCommand("{ \"command\": \"shutdown\" }", response);
-    EXPECT_EQ("[ { \"result\": 0, \"text\": \"Shutting down.\" } ]",response);
+    EXPECT_EQ("[ { \"result\": 0, \"text\": \"Shutting down.\" } ]", response);
+
+    EXPECT_EQ(EXIT_SUCCESS, server_->getExitValue());
 }
 
 // Check that the "config-set" command will replace current configuration
@@ -652,7 +655,6 @@ TEST_F(HttpCtrlChannelDhcpv6Test, configSet) {
     // Send the config-set command
     std::string response;
     sendHttpCommand(os.str(), response);
-
     EXPECT_EQ("[ { \"arguments\": { \"hash\": \"BCE3D0CC68CBBB49C3F5967E3FFCB4E44E55CBFB53814761B12ADB5C7CD95C1F\" }, \"result\": 0, \"text\": \"Configuration successful.\" } ]",
               response);
 
@@ -716,6 +718,7 @@ TEST_F(HttpCtrlChannelDhcpv6Test, configSet) {
     ASSERT_NO_THROW(HttpCommandMgr::instance().garbageCollectListeners());
     EXPECT_FALSE(HttpCommandMgr::instance().getHttpListener());
 
+    // With no command channel, should still receive the response.
     EXPECT_EQ("[ { \"arguments\": { \"hash\": \"48035E8F9CC25FC1F6175B78CCC6B8A673CACBA9E956C0ED3079C478BF1F2D1A\" }, \"result\": 0, \"text\": \"Configuration successful.\" } ]",
               response);
 
@@ -1443,7 +1446,7 @@ TEST_F(HttpCtrlChannelDhcpv6Test, controlChannelStats) {
               response);
 }
 
-// Tests that the server properly responds to shutdown command sent
+// Tests that the server properly responds to list-commands command sent
 // via ControlChannel
 TEST_F(HttpCtrlChannelDhcpv6Test, listCommands) {
     createHttpChannelServer();
@@ -1502,7 +1505,8 @@ TEST_F(HttpCtrlChannelDhcpv6Test, configWriteFilename) {
     std::string response;
 
     sendHttpCommand("{ \"command\": \"config-write\", "
-                    "\"arguments\": { \"filename\": \"test2.json\" } }", response);
+                    "\"arguments\": { \"filename\": \"test2.json\" } }",
+                    response);
 
     checkConfigWrite(response, CONTROL_RESULT_SUCCESS, "test2.json");
     ::remove("test2.json");
@@ -1589,8 +1593,6 @@ TEST_F(HttpCtrlChannelDhcpv6Test, configReloadValid) {
 
     EXPECT_EQ("[ { \"arguments\": { \"hash\": \"2D97C398AFE8414A818D9F04C9ADB62D493861EDD3689015D081880D6A85A3C3\" }, \"result\": 0, \"text\": \"Configuration successful.\" } ]",
               response);
-    EXPECT_NE(response.find("\"result\": 0"), std::string::npos);
-    EXPECT_NE(response.find("\"text\": \"Configuration successful.\""), std::string::npos);
 
     // Check that the config was indeed applied.
     const Subnet6Collection* subnets =
@@ -2227,7 +2229,7 @@ TEST_F(HttpCtrlChannelDhcpv6Test, longResponse) {
 
     createHttpChannelServer();
 
-    // The entire response should be received but anayway check it.
+    // The entire response should be received but anyway check it.
     ConstElementPtr raw_response =
         longResponseHandler("foo", ConstElementPtr());
     ElementPtr json_response = Element::createList();
index d878b8e9a447c2c44faf702975e51cbf57d27165..300d28617fed9594fa95ee9f755a101348db7d8b 100644 (file)
@@ -215,8 +215,7 @@ public:
     /// @param response_str a string containing the whole HTTP
     /// response received.
     ///
-    /// @return An HttpResponse constructed from by parsing the
-    /// response string.
+    /// @return An HttpResponse constructed by parsing the response string.
     HttpResponsePtr parseResponse(const std::string response_str) {
         HttpResponsePtr hr(new HttpResponse());
         HttpResponseParser parser(*hr);
index 6680d7ad26554a0752bc5dd9ae5104fbf69fb7b8..6dd0903f290857f319283f5d7416dc615b976e2d 100644 (file)
@@ -159,8 +159,7 @@ public:
     /// @param response_str a string containing the whole HTTP
     /// response received.
     ///
-    /// @return An HttpResponse constructed from by parsing the
-    /// response string.
+    /// @return An HttpResponse constructed by parsing the response string.
     HttpResponsePtr parseResponse(const std::string response_str) {
         HttpResponsePtr hr(new HttpResponse());
         HttpResponseParser parser(*hr);
index 81df26ab2ec9c9dbaaee63ff8825e95b64c65881..7757e8640e0edb235643c4b0ca3c275f856b0aba 100644 (file)
@@ -103,7 +103,7 @@ public:
 
     /// @brief Sets information about the UNIX control socket
     ///
-    /// @param ontrol_socket UNIX control socket config
+    /// @param control_socket UNIX control socket config
     void setControlSocketInfo(const isc::data::ConstElementPtr& control_socket) {
         unix_control_socket_ = control_socket;
     }