]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2264] test IPv6 URL in HA
authorAndrei Pavel <andrei@isc.org>
Tue, 18 Jan 2022 14:49:08 +0000 (16:49 +0200)
committerRazvan Becheriu <razvan@isc.org>
Wed, 23 Feb 2022 07:10:50 +0000 (09:10 +0200)
src/hooks/dhcp/high_availability/tests/ha_config_unittest.cc

index a1fc75bf432e8b0e603bcb5276419150f9bfe10c..4e06db426aef3df80b3887c14576f4e360849a83 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2021 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2022 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -1854,4 +1854,35 @@ TEST_F(HAConfigTest, multiThreadingPermutations) {
     }
 }
 
+// Check that an IPv6 address can be used as part of a value for "url".
+TEST_F(HAConfigTest, ipv6Url) {
+    std::string const ha_config(R"(
+        [
+            {
+                "mode": "load-balancing",
+                "peers": [
+                    {
+                        "name": "server1",
+                        "role": "primary",
+                        "url": "http://[2001:db8::1]:8080/"
+                    },
+                    {
+                        "name": "server2",
+                        "role": "secondary",
+                        "url": "http://[2001:db8::2]:8080/"
+                    }
+                ],
+                "this-server-name": "server1"
+            }
+        ]
+    )");
+
+    // Configure HA.
+    HAImplPtr impl(new HAImpl());
+    ASSERT_NO_THROW_LOG(impl->configure(Element::fromJSON(ha_config)));
+
+    // Check the URL.
+    EXPECT_EQ(impl->getConfig()->getThisServerConfig()->getUrl().toText(), "http://[2001:db8::1]:8080/");
+};
+
 } // end of anonymous namespace