summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRazvan Becheriu <razvan@isc.org>2022-08-04 17:54:50 +0300
committerFrancis Dupont <fdupont@isc.org>2022-08-10 16:02:22 +0200
commit1b62b3429b4f21af6461a9052deda4f2efadafb5 (patch)
tree7773b2ec01d01c48a239d1422d2ed012982390be
parentb8947eda6368e7b0237420b581e7b5f21083c23a (diff)
[#2071] addressed comments
-rw-r--r--src/bin/dhcp4/tests/dhcp4_srv_unittest.cc45
-rw-r--r--src/bin/dhcp6/tests/dhcp6_srv_unittest.cc45
2 files changed, 34 insertions, 56 deletions
diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
index 4db7d779f6..44f3128231 100644
--- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
+++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
@@ -2782,16 +2782,21 @@ Dhcpv4SrvTest::portsServerPort() {
EXPECT_EQ(srv.server_port_, offer->getLocalPort());
}
-#if defined (HAVE_MYSQL)
-/// @brief Check if SSL/TLS support is available and configured.
-bool hasMySQLTls() {
- std::string tls = getMySQLTlsEnv();
- if (tls.empty()) {
- tls = getMySQLTlsServer();
+/// @brief Remove TLS parameters from configuration element.
+void removeTlsParameters(ConstElementPtr elem) {
+ if (elem) {
+ ElementPtr mutable_elem = boost::const_pointer_cast<Element>(elem);
+ std::vector<std::string> tls_parameters= {
+ "trust-anchor",
+ "cert-file",
+ "key-file",
+ "cipher-list"
+ };
+ for (auto const& parameter : tls_parameters) {
+ mutable_elem->remove(parameter);
+ }
}
- return (tls == "YES");
}
-#endif
void
Dhcpv4SrvTest::loadConfigFile(const string& path) {
@@ -2837,31 +2842,15 @@ Dhcpv4SrvTest::loadConfigFile(const string& path) {
ASSERT_TRUE(dhcp4);
ElementPtr mutable_config = boost::const_pointer_cast<Element>(dhcp4);
mutable_config->set(string("hooks-libraries"), Element::createList());
-#if defined (HAVE_MYSQL)
- bool tls_required = false;
+ // Remove TLS parameters
ConstElementPtr hosts = dhcp4->get("hosts-database");
- if (hosts) {
- ConstElementPtr tls = hosts->get("trust-anchor");
- if (tls) {
- tls_required = true;
- }
- }
+ removeTlsParameters(hosts);
hosts = dhcp4->get("hosts-databases");
if (hosts) {
for (auto& host : hosts->listValue()) {
- ConstElementPtr tls = host->get("trust-anchor");
- if (tls) {
- tls_required = true;
- break;
- }
+ removeTlsParameters(host);
}
}
- if (tls_required && !hasMySQLTls()) {
- std::cout << "SSL/TLS support is not available or configured: "
- << "skipping this test for " << path << "\n";
- return;
- }
-#endif
ASSERT_NO_THROW(Dhcpv4SrvTest::configure(dhcp4->str(), true, true, true, true));
LeaseMgrFactory::destroy();
@@ -2913,7 +2902,7 @@ class DBInitializer {
void
Dhcpv4SrvTest::checkConfigFiles() {
- DBInitializer dbi();
+ DBInitializer dbi;
IfaceMgrTestConfig test_config(true);
string path = CFG_EXAMPLES;
vector<string> examples = {
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 02de1486ca..82f20b7dc7 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -167,16 +167,21 @@ namespace isc {
namespace dhcp {
namespace test {
-#if defined (HAVE_MYSQL)
-/// @brief Check if SSL/TLS support is available and configured.
-bool hasMySQLTls() {
- std::string tls = getMySQLTlsEnv();
- if (tls.empty()) {
- tls = getMySQLTlsServer();
+/// @brief Remove TLS parameters from configuration element.
+void removeTlsParameters(ConstElementPtr elem) {
+ if (elem) {
+ ElementPtr mutable_elem = boost::const_pointer_cast<Element>(elem);
+ std::vector<std::string> tls_parameters= {
+ "trust-anchor",
+ "cert-file",
+ "key-file",
+ "cipher-list"
+ };
+ for (auto const& parameter : tls_parameters) {
+ mutable_elem->remove(parameter);
+ }
}
- return (tls == "YES");
}
-#endif
void
Dhcpv6SrvTest::loadConfigFile(const string& path) {
@@ -222,31 +227,15 @@ Dhcpv6SrvTest::loadConfigFile(const string& path) {
ASSERT_TRUE(dhcp6);
ElementPtr mutable_config = boost::const_pointer_cast<Element>(dhcp6);
mutable_config->set(string("hooks-libraries"), Element::createList());
-#if defined (HAVE_MYSQL)
- bool tls_required = false;
+ // Remove TLS parameters
ConstElementPtr hosts = dhcp6->get("hosts-database");
- if (hosts) {
- ConstElementPtr tls = hosts->get("trust-anchor");
- if (tls) {
- tls_required = true;
- }
- }
+ removeTlsParameters(hosts);
hosts = dhcp6->get("hosts-databases");
if (hosts) {
for (auto& host : hosts->listValue()) {
- ConstElementPtr tls = host->get("trust-anchor");
- if (tls) {
- tls_required = true;
- break;
- }
+ removeTlsParameters(host);
}
}
- if (tls_required && !hasMySQLTls()) {
- std::cout << "SSL/TLS support is not available or configured: "
- << "skipping this test for " << path << "\n";
- return;
- }
-#endif
ASSERT_NO_THROW(Dhcpv6SrvTest::configure(dhcp6->str(), true, true, true, true));
LeaseMgrFactory::destroy();
@@ -298,7 +287,7 @@ class DBInitializer {
void
Dhcpv6SrvTest::checkConfigFiles() {
- DBInitializer dbi();
+ DBInitializer dbi;
IfaceMgrTestConfig test_config(true);
string path = CFG_EXAMPLES;
vector<string> examples = {