]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3477] Addressed comments
authorFrancis Dupont <fdupont@isc.org>
Tue, 23 Jul 2024 12:45:15 +0000 (14:45 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 1 Aug 2024 07:23:54 +0000 (09:23 +0200)
src/bin/d2/d2_process.cc
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/lib/config/http_command_config.cc
src/lib/config/http_command_config.h
src/lib/config/http_command_mgr.cc
src/lib/config/tests/http_command_config_unittests.cc

index 6efe6b4b97e9faee247fe9e048ea5b7731c0a3ba..f82b73fff474cfdc8f565136daba6b70019558f3 100644 (file)
@@ -81,7 +81,7 @@ D2Process::init() {
     HttpCommandMgr::instance().setIOService(getIOService());
 
     // Set the HTTP authentication default realm.
-    HttpCommandConfig::DefaultAuthenticationRealm = "kea-dhcp-ddns-server";
+    HttpCommandConfig::DEFAULT_AUTHENTICATION_REALM = "kea-dhcp-ddns-server";
 };
 
 void
index c25e55b359669dad76fd28393f92f5e53a869f46..27fad13f6a77126f064c9944aaefe9795ac0940a 100644 (file)
@@ -1086,7 +1086,7 @@ ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t server_port /*= DHCP4_SERVER_P
     HttpCommandMgr::instance().setIOService(getIOService());
 
     // Set the HTTP authentication default realm.
-    HttpCommandConfig::DefaultAuthenticationRealm = "kea-dhcpv4-server";
+    HttpCommandConfig::DEFAULT_AUTHENTICATION_REALM = "kea-dhcpv4-server";
 
     // DatabaseConnection uses IO service to run asynchronous timers.
     DatabaseConnection::setIOService(getIOService());
index 7cbedfb66798e93e4dea95652f907b6fb2043c93..d1e2f5101a8b6489d88595024f9cdc56fd230b2e 100644 (file)
@@ -1110,7 +1110,7 @@ ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t server_port /*= DHCP6_SERVER_P
     HttpCommandMgr::instance().setIOService(getIOService());
 
     // Set the HTTP authentication default realm.
-    HttpCommandConfig::DefaultAuthenticationRealm = "kea-dhcpv6-server";
+    HttpCommandConfig::DEFAULT_AUTHENTICATION_REALM = "kea-dhcpv6-server";
 
     // DatabaseConnection uses IO service to run asynchronous timers.
     DatabaseConnection::setIOService(getIOService());
index a39e2e8feb8b3d7bdeade6eca8eec053407ca179..ecb1f3d326d53f4ce0f104d76870a7d545e593eb 100644 (file)
@@ -22,15 +22,15 @@ using namespace std;
 namespace isc {
 namespace config {
 
-IOAddress HttpCommandConfig::DefaultSocketAddress = IOAddress("127.0.0.1");
+IOAddress HttpCommandConfig::DEFAULT_SOCKET_ADDRESS = IOAddress("127.0.0.1");
 
-uint16_t HttpCommandConfig::DefaultSocketPort = 8000;
+uint16_t HttpCommandConfig::DEFAULT_SOCKET_PORT = 8000;
 
-string HttpCommandConfig::DefaultAuthenticationRealm = "";
+string HttpCommandConfig::DEFAULT_AUTHENTICATION_REALM = "";
 
 HttpCommandConfig::HttpCommandConfig(ConstElementPtr config)
-    : socket_type_("http"), socket_address_(DefaultSocketAddress),
-      socket_port_(DefaultSocketPort), auth_config_(),
+    : socket_type_("http"), socket_address_(DEFAULT_SOCKET_ADDRESS),
+      socket_port_(DEFAULT_SOCKET_PORT), auth_config_(),
       trust_anchor_(""), cert_file_(""), key_file_(""), cert_required_(true),
       emulate_agent_response_(true) {
     if (config->getType() != Element::map) {
@@ -119,7 +119,7 @@ HttpCommandConfig::HttpCommandConfig(ConstElementPtr config)
         ConstElementPtr realm = auth_config->get("realm");
         if (!realm) {
             mutable_auth_config->set("realm",
-                Element::create(DefaultAuthenticationRealm));
+                Element::create(DEFAULT_AUTHENTICATION_REALM));
         }
 
         BasicHttpAuthConfigPtr auth(new BasicHttpAuthConfig());
index cfab1f604a11bb074fbac3d735cd60c076625638..30b9c5c5c00be3e54d5cfb914de572327afe8560 100644 (file)
@@ -166,13 +166,13 @@ public:
     virtual isc::data::ElementPtr toElement() const;
 
     /// @brief Default socket address (127.0.0.1).
-    static isc::asiolink::IOAddress DefaultSocketAddress;
+    static isc::asiolink::IOAddress DEFAULT_SOCKET_ADDRESS;
 
     /// @brief Default socket port.
-    static uint16_t DefaultSocketPort;
+    static uint16_t DEFAULT_SOCKET_PORT;
 
     /// @brief Default HTTP authentication realm.
-    static std::string DefaultAuthenticationRealm;
+    static std::string DEFAULT_AUTHENTICATION_REALM;
 
 private:
     /// @brief Check TLS configuration.
index df2b6ced907bc83a1cf23fe8d37a4787fc8e0a85..fca44b27238c733cbedded10fe5dde1c709703ac 100644 (file)
@@ -85,16 +85,16 @@ HttpCommandMgrImpl::configure(HttpCommandConfigPtr config) {
     if (config && current_config_ &&
         (config->getSocketAddress() == current_config_->getSocketAddress()) &&
         (config->getSocketPort() == current_config_->getSocketPort())) {
-        // Overwrite the authentication setup in the response creator config.
-        current_config_->setAuthConfig(config->getAuthConfig());
-        // Overwrite the emulation flag in the response creator config.
-        current_config_->setEmulateAgentResponse(config->getEmulateAgentResponse());
         // Check if TLS setup changed.
         if ((config->getTrustAnchor() != current_config_->getTrustAnchor()) ||
             (config->getCertFile() != current_config_->getCertFile()) ||
             (config->getKeyFile() != current_config_->getKeyFile()) ||
             (config->getCertRequired() != current_config_->getCertRequired())) {
             LOG_WARN(command_logger, HTTP_COMMAND_MGR_IGNORED_TLS_SETUP_CHANGES);
+            // Overwrite the authentication setup and the emulation flag
+            //in the response creator config.
+            current_config_->setAuthConfig(config->getAuthConfig());
+            current_config_->setEmulateAgentResponse(config->getEmulateAgentResponse());
         } else {
             current_config_ = config;
         }
index 86360eb5c021850e5d3356a0d5904d3376013751..afb9a755dd73ce57b23b2f6084a2dbc68256845a 100644 (file)
@@ -27,16 +27,16 @@ class HttpCommandConfigTest : public ::testing::Test {
 public:
     /// @brief Constructor.
     HttpCommandConfigTest() : http_config_() {
-        HttpCommandConfig::DefaultSocketAddress = IOAddress("127.0.0.1");
-        HttpCommandConfig::DefaultSocketPort = 8000;
-        HttpCommandConfig::DefaultAuthenticationRealm = "";
+        HttpCommandConfig::DEFAULT_SOCKET_ADDRESS = IOAddress("127.0.0.1");
+        HttpCommandConfig::DEFAULT_SOCKET_PORT = 8000;
+        HttpCommandConfig::DEFAULT_AUTHENTICATION_REALM = "";
     }
 
     /// @brief Destructor.
     ~HttpCommandConfigTest() {
-        HttpCommandConfig::DefaultSocketAddress = IOAddress("127.0.0.1");
-        HttpCommandConfig::DefaultSocketPort = 8000;
-        HttpCommandConfig::DefaultAuthenticationRealm = "";
+        HttpCommandConfig::DEFAULT_SOCKET_ADDRESS = IOAddress("127.0.0.1");
+        HttpCommandConfig::DEFAULT_SOCKET_PORT = 8000;
+        HttpCommandConfig::DEFAULT_AUTHENTICATION_REALM = "";
     }
 
     /// @brief HTTP control socket configuration.
@@ -70,8 +70,8 @@ TEST_F(HttpCommandConfigTest, default) {
     runToElementTest(expected, *http_config_);
 
     // Change class defaults.
-    HttpCommandConfig::DefaultSocketAddress = IOAddress("::1");
-    HttpCommandConfig::DefaultSocketPort = 8080;
+    HttpCommandConfig::DEFAULT_SOCKET_ADDRESS = IOAddress("::1");
+    HttpCommandConfig::DEFAULT_SOCKET_PORT = 8080;
     ASSERT_NO_THROW_LOG(http_config_.reset(new HttpCommandConfig(json)));
     EXPECT_EQ("::1", http_config_->getSocketAddress().toText());
     EXPECT_EQ(8080, http_config_->getSocketPort());
@@ -250,7 +250,7 @@ TEST_F(HttpCommandConfigTest, authentication) {
     ASSERT_TRUE(auth);
 
     // Verify that default realm is applied.
-    HttpCommandConfig::DefaultAuthenticationRealm = "FOO";
+    HttpCommandConfig::DEFAULT_AUTHENTICATION_REALM = "FOO";
     ASSERT_NO_THROW(json = Element::fromJSON(config));
     ASSERT_NO_THROW(http_config_.reset(new HttpCommandConfig(json)));
     auth_config = http_config_->getAuthConfig();