]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3477] Handled CA dir path
authorFrancis Dupont <fdupont@isc.org>
Fri, 9 Aug 2024 14:29:37 +0000 (16:29 +0200)
committerFrancis Dupont <fdupont@isc.org>
Fri, 20 Sep 2024 11:46:27 +0000 (13:46 +0200)
src/bin/d2/tests/Makefile.am
src/bin/d2/tests/d2_http_command_unittest.cc
src/bin/dhcp4/tests/Makefile.am
src/bin/dhcp4/tests/http_control_socket_unittest.cc
src/bin/dhcp6/tests/Makefile.am
src/bin/dhcp6/tests/http_control_socket_unittest.cc

index b2eaca056e4aaf75a3bd2686d98a76c52e3b1859..544000a2a9ead1764166046ce30bdf09bb51ee79 100644 (file)
@@ -30,7 +30,7 @@ AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/bin/d2/tests\"
 AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
 AM_CPPFLAGS += -DCFG_EXAMPLES=\"$(abs_top_srcdir)/doc/examples/ddns\"
 AM_CPPFLAGS += -DSYNTAX_FILE=\"$(abs_srcdir)/../d2_parser.yy\"
-AM_CPPFLAGS += -DTEST_CA_DIR=\"$(srcdir)/../../lib/asiolink/testutils/ca\"
+AM_CPPFLAGS += -DTEST_CA_DIR=\"$(abs_top_srcdir)/src/lib/asiolink/testutils/ca\"
 
 AM_CXXFLAGS = $(KEA_CXXFLAGS)
 
index a7a2078f096c7710a3229da21034d72196979a2b..9629a24c5a133ef325e5e8af42806853458814d7 100644 (file)
@@ -1055,8 +1055,15 @@ TEST_F(HttpsCtrlChannelD2Test, configTest) {
     ASSERT_TRUE(proc);
     ConstElementPtr answer = proc->configure(config, false);
     ASSERT_TRUE(answer);
-    EXPECT_EQ("{ \"arguments\": { \"hash\": \"A6E28D3F41B4502EC72F3599E34D2785442D60C6F4FABAC3D1C4A4C49FE3D3C2\" }, \"result\": 0, \"text\": \"Configuration applied successfully.\" }",
-              answer->str());
+    // Verify the configuration was successful. The config contains random
+    // file paths (CA directory), so the hash will be different each time.
+    // As such, we can do simplified checks:
+    // - verify the "result": 0 is there
+    // - verify the "text": "Configuration applied successfully." is there
+    string answer_txt = answer->str();
+    EXPECT_NE(answer_txt.find("\"result\": 0"), std::string::npos);
+    EXPECT_NE(answer_txt.find("\"text\": \"Configuration applied successfully.\""),
+              std::string::npos);
     ASSERT_NO_THROW(d2Controller()->registerCommands());
 
     // Check that the config was indeed applied.
@@ -1303,8 +1310,15 @@ TEST_F(HttpsCtrlChannelD2Test, configSet) {
     ASSERT_TRUE(proc);
     ConstElementPtr answer = proc->configure(config, false);
     ASSERT_TRUE(answer);
-    EXPECT_EQ("{ \"arguments\": { \"hash\": \"A6E28D3F41B4502EC72F3599E34D2785442D60C6F4FABAC3D1C4A4C49FE3D3C2\" }, \"result\": 0, \"text\": \"Configuration applied successfully.\" }",
-              answer->str());
+    // Verify the configuration was successful. The config contains random
+    // file paths (CA directory), so the hash will be different each time.
+    // As such, we can do simplified checks:
+    // - verify the "result": 0 is there
+    // - verify the "text": "Configuration applied successfully." is there
+    string answer_txt = answer->str();
+    EXPECT_NE(answer_txt.find("\"result\": 0"), std::string::npos);
+    EXPECT_NE(answer_txt.find("\"text\": \"Configuration applied successfully.\""),
+              std::string::npos);
     ASSERT_NO_THROW(d2Controller()->registerCommands());
 
     // Check that the config was indeed applied.
index efef18f447febcaf41a3b65df216b67a8f97a594..952b26b9132e8ad559b5d4f74cac7a37ff3d988e 100644 (file)
@@ -25,7 +25,7 @@ AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
 AM_CPPFLAGS += -DCFG_EXAMPLES=\"$(abs_top_srcdir)/doc/examples/kea4\"
 AM_CPPFLAGS += -DSYNTAX_FILE=\"$(abs_srcdir)/../dhcp4_parser.yy\"
 AM_CPPFLAGS += -DKEA_LFC_EXECUTABLE=\"$(abs_top_builddir)/src/bin/lfc/kea-lfc\"
-AM_CPPFLAGS += -DTEST_CA_DIR=\"$(srcdir)/../../lib/asiolink/testutils/ca\"
+AM_CPPFLAGS += -DTEST_CA_DIR=\"$(abs_top_srcdir)/src/lib/asiolink/testutils/ca\"
 
 AM_CXXFLAGS = $(KEA_CXXFLAGS)
 
index e8f6e66c66600b7ee6db9993fb7e5ada977a3272..085b8c30c6ee24cadf40649cebc8d82e2cbb3961 100644 (file)
@@ -1206,8 +1206,14 @@ TEST_F(HttpsCtrlChannelDhcpv4Test, configSet) {
     // Send the config-set command
     std::string response;
     sendHttpCommand(os.str(), response);
-    EXPECT_EQ("[ { \"arguments\": { \"hash\": \"B95F3C56211CF07A9A5D8C173568CEC1DE74C6B6E3DAF3EDD4381841CED4A255\" }, \"result\": 0, \"text\": \"Configuration successful.\" } ]",
-              response);
+    // Verify the configuration was successful. The config contains random
+    // file paths (CA directory), so the hash will be different each time.
+    // As such, we can do simplified checks:
+    // - verify the "result": 0 is there
+    // - verify the "text": "Configuration successful." is there
+    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 Subnet4Collection* subnets =
@@ -1579,8 +1585,14 @@ TEST_F(HttpsCtrlChannelDhcpv4Test, configTest) {
     std::string response;
     sendHttpCommand(os.str(), response);
 
-    EXPECT_EQ("[ { \"arguments\": { \"hash\": \"E3369C069976A5EB4CD70B625752E709E855107D49527DEDED8636FCD0F78451\" }, \"result\": 0, \"text\": \"Configuration successful.\" } ]",
-              response);
+    // Verify the configuration was successful. The config contains random
+    // file paths (CA directory), so the hash will be different each time.
+    // As such, we can do simplified checks:
+    // - verify the "result": 0 is there
+    // - verify the "text": "Configuration successful." is there
+    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 Subnet4Collection* subnets =
index 54632a2c010e654e5f476cb38707a73329bcccbd..a63a88fcfac33f30895527f4fff28913ceb8970b 100644 (file)
@@ -25,7 +25,7 @@ AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
 AM_CPPFLAGS += -DCFG_EXAMPLES=\"$(abs_top_srcdir)/doc/examples/kea6\"
 AM_CPPFLAGS += -DSYNTAX_FILE=\"$(abs_srcdir)/../dhcp6_parser.yy\"
 AM_CPPFLAGS += -DKEA_LFC_EXECUTABLE=\"$(abs_top_builddir)/src/bin/lfc/kea-lfc\"
-AM_CPPFLAGS += -DTEST_CA_DIR=\"$(srcdir)/../../lib/asiolink/testutils/ca\"
+AM_CPPFLAGS += -DTEST_CA_DIR=\"$(abs_top_srcdir)/src/lib/asiolink/testutils/ca\"
 
 AM_CXXFLAGS = $(KEA_CXXFLAGS)
 
index 8d35675153d7bbcd0cb967250495699627ad3f54..8f3ce2f13cb76fb9de6fa251fa967aa98293e026 100644 (file)
@@ -1107,8 +1107,14 @@ TEST_F(HttpsCtrlChannelDhcpv6Test, configSet) {
     // Send the config-set command
     std::string response;
     sendHttpCommand(os.str(), response);
-    EXPECT_EQ("[ { \"arguments\": { \"hash\": \"19DC7B91AB2806C11494FA4AB3D2ACF144E1F6CDDD24859F5E8F277D06B06454\" }, \"result\": 0, \"text\": \"Configuration successful.\" } ]",
-              response);
+    // Verify the configuration was successful. The config contains random
+    // file paths (CA directory), so the hash will be different each time.
+    // As such, we can do simplified checks:
+    // - verify the "result": 0 is there
+    // - verify the "text": "Configuration successful." is there
+    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 =
@@ -1481,8 +1487,14 @@ TEST_F(HttpsCtrlChannelDhcpv6Test, configTest) {
     std::string response;
     sendHttpCommand(os.str(), response);
 
-    EXPECT_EQ("[ { \"arguments\": { \"hash\": \"F985ED10D250FDF13F10DF7E409EA4F467D46BC77F8FACE95AF7CB5208E6B6B2\" }, \"result\": 0, \"text\": \"Configuration successful.\" } ]",
-              response);
+    // Verify the configuration was successful. The config contains random
+    // file paths (CA directory), so the hash will be different each time.
+    // As such, we can do simplified checks:
+    // - verify the "result": 0 is there
+    // - verify the "text": "Configuration successful." is there
+    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 =