]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3848] Fix element position reporting
authorThomas Markwalder <tmark@isc.org>
Wed, 18 Jun 2025 16:04:24 +0000 (12:04 -0400)
committerThomas Markwalder <tmark@isc.org>
Mon, 30 Jun 2025 11:49:59 +0000 (11:49 +0000)
modified:   src/lib/cc/data.cc
    altered data::copy() to also copy the source element's position

modified:   src/bin/dhcp4/json_config_parser.cc
modified:   src/hooks/dhcp/lease_query/tests/lease_query_impl4_unittest.cc
modified:   src/lib/http/tests/basic_auth_config_unittests.cc

src/bin/dhcp4/json_config_parser.cc
src/hooks/dhcp/lease_query/tests/lease_query_impl4_unittest.cc
src/lib/cc/data.cc
src/lib/http/tests/basic_auth_config_unittests.cc

index 38258e2f18a9bece68fb568f0bb391be1faabc35..ebab5530e52c82d1c16f446a2532c65f7e1cb290 100644 (file)
@@ -412,7 +412,7 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) {
         ConstElementPtr control_socket = mutable_cfg->get("control-socket");
         if (control_socket) {
             mutable_cfg->remove("control-socket");
-            ElementPtr l = Element::createList();
+            ElementPtr l = Element::createList(control_socket->getPosition());
             l->add(UserContext::toElement(control_socket));
             mutable_cfg->set("control-sockets", l);
         }
index 3c67d878145275eae35a0caf15b01b70fbdfa052..ab5645ac5999e5f971b58ed6ee8783df9586fece 100644 (file)
@@ -1224,7 +1224,7 @@ TEST_F(LeaseQueryImpl4ProcessTest, addRelayAgentInfo) {
     // Pass lease and response into addRelayAgentInfo().
     ASSERT_THROW_MSG(LeaseQueryImpl4::addRelayAgentInfo(response, lease),
                      Unexpected, "Error creating relay-agent-info option:"
-                     " stringValue() called on non-string Element");
+                     " stringValue() called on non-string Element in (<string>:1:32)");
 
     // Verify relay-agent-info is not in the response
     checkRelayAgentInfo(response, "");
index f48bed5e8181bded7839bd9911bc22775f34a6cc..66f39869b7b53f91b664d8bef53d1d79ed38dde1 100644 (file)
@@ -1421,19 +1421,21 @@ copy(ConstElementPtr from, int level) {
     if (!from) {
         isc_throw(BadValue, "copy got a null pointer");
     }
+
+    auto pos = from->getPosition();
     int from_type = from->getType();
     if (from_type == Element::integer) {
-        return (ElementPtr(new IntElement(from->intValue())));
+        return (ElementPtr(new IntElement(from->intValue(), pos)));
     } else if (from_type == Element::real) {
-        return (ElementPtr(new DoubleElement(from->doubleValue())));
+        return (ElementPtr(new DoubleElement(from->doubleValue(), pos)));
     } else if (from_type == Element::boolean) {
-        return (ElementPtr(new BoolElement(from->boolValue())));
+        return (ElementPtr(new BoolElement(from->boolValue(), pos)));
     } else if (from_type == Element::null) {
         return (ElementPtr(new NullElement()));
     } else if (from_type == Element::string) {
-        return (ElementPtr(new StringElement(from->stringValue())));
+        return (ElementPtr(new StringElement(from->stringValue(), pos)));
     } else if (from_type == Element::list) {
-        ElementPtr result = ElementPtr(new ListElement());
+        ElementPtr result = ElementPtr(new ListElement(pos));
         for (auto const& elem : from->listValue()) {
             if (level == 0) {
                 result->add(elem);
@@ -1443,7 +1445,7 @@ copy(ConstElementPtr from, int level) {
         }
         return (result);
     } else if (from_type == Element::map) {
-        ElementPtr result = ElementPtr(new MapElement());
+        ElementPtr result = ElementPtr(new MapElement(pos));
         for (auto const& kv : from->mapValue()) {
             auto key = kv.first;
             auto value = kv.second;
index 0b32999c72bdc4d48723d1bdd0d146e142340cc8..ab41aa8ff9460c0fa76b25cb447a1f8f5473eb7e 100644 (file)
@@ -556,7 +556,6 @@ TEST_F(BasicHttpAuthConfigTest, parse) {
     cfg->set("clients", clients_cfg);
     EXPECT_NO_THROW(config.parse(cfg));
     runToElementTest<BasicHttpAuthConfig>(cfg, config);
-    std::cout << "TKM config: " << prettyPrint(config.toElement()) << std::endl;
 
     // Check a working not empty config with files.
     config.clear();