]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#34] Checkpoint before rebase
authorFrancis Dupont <fdupont@isc.org>
Mon, 6 Dec 2021 16:11:24 +0000 (17:11 +0100)
committerFrancis Dupont <fdupont@isc.org>
Thu, 6 Jan 2022 12:12:40 +0000 (13:12 +0100)
configure.ac
src/lib/dhcpsrv/cql_host_data_source.cc
src/lib/dhcpsrv/cql_lease_mgr.cc
src/lib/dhcpsrv/pgsql_host_data_source.cc
src/lib/dhcpsrv/pgsql_lease_mgr.cc
src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc
src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc
src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc

index a8d628724393b7621ce150f4d33cb52c09d2ff0f..63653e34f7aeb59c25d1697307b0b6529cc29b90 100644 (file)
@@ -819,8 +819,10 @@ AM_CONDITIONAL(HAVE_PGSQL, test "$PG_CONFIG" != "")
 AC_ARG_ENABLE([pgsql-ssl],
   [AS_HELP_STRING([--enable-pgsql-ssl],
     [enable OpenSSL support in PostgreSQL [default=yes]])],
-  [pgsql_ssl=yes], [pgsql_ssl=no], [pgsql_ssl=yes])
-AC_DEFINE([HAVE_PGSQL_SSL], [1], [PostgreSQL was built with OpenSSL support])
+  [pgsql_ssl=$enableval], [pgsql_ssl=no], [pgsql_ssl=yes])
+if test "${pgsql_ssl}" = "yes"; then
+    AC_DEFINE([HAVE_PGSQL_SSL], [1], [PostgreSQL was built with OpenSSL support])
+fi
 
 # allow building kea programs with static link to cassandra cpp-driver.
 AC_ARG_ENABLE([cql-static-lib],
index d6a70b305adc230f23c88eaa184d410835948655..4dcff673ee188120cdc530f16224f37ec52b7fa9 100644 (file)
@@ -2549,7 +2549,7 @@ CqlHostDataSourceImpl::CqlHostDataSourceImpl(const DatabaseConnection::Parameter
         // No cipher list.
     }
     if (tls) {
-        LOG_ERR(dhcpsrv_logger, DHCPSRV_CQL_NO_TLS_SUPPORT)
+        LOG_ERROR(dhcpsrv_logger, DHCPSRV_CQL_NO_TLS_SUPPORT)
             .arg(DatabaseConnection::redactedAccessString(parameters));
         isc_throw(DbOpenError, "Attempt to configure TLS for CQL backend");
     }
index e1204aae97159e08340805f3f62776321497fbb8..a2ddcd55c228d395a9cdfdcd768ec362ff28b1c4 100644 (file)
@@ -2140,7 +2140,7 @@ CqlLeaseMgr::CqlLeaseMgr(const DatabaseConnection::ParameterMap &parameters)
         // No cipher list.
     }
     if (tls) {
-        LOG_ERR(dhcpsrv_logger, DHCPSRV_CQL_NO_TLS_SUPPORT)
+        LOG_ERROR(dhcpsrv_logger, DHCPSRV_CQL_NO_TLS_SUPPORT)
             .arg(DatabaseConnection::redactedAccessString(parameters));
         isc_throw(DbOpenError, "Attempt to configure TLS for CQL");
     }
index 2f95fb10059b5ca06537792d219d215255bdfae8..c7278333c96303cf5fb682eb1cacef394e7fef8c 100644 (file)
@@ -2242,7 +2242,7 @@ PgSqlHostDataSourceImpl::PgSqlHostDataSourceImpl(const DatabaseConnection::Param
     }
 #else
     if (tls > 0) {
-        LOG_ERR(dhcpsrv_logger, DHCPSRV_PGSQL_NO_TLS_SUPPORT)
+        LOG_ERROR(dhcpsrv_logger, DHCPSRV_PGSQL_NO_TLS_SUPPORT)
             .arg(DatabaseConnection::redactedAccessString(parameters_));
         isc_throw(DbOpenError, "Attempt to configure TLS for PostgreSQL "
                   << "backend (built with this feature disabled)");
index 1c05c4dc67aeb4b69ee48f28abc376323d62ccbc..57437ca820210a01333abcd034f3e8736706dc7a 100644 (file)
@@ -1237,7 +1237,7 @@ PgSqlLeaseMgr::PgSqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters)
     }
 #else
     if (tls > 0) {
-        LOG_ERR(dhcpsrv_logger, DHCPSRV_PGSQL_NO_TLS_SUPPORT)
+        LOG_ERROR(dhcpsrv_logger, DHCPSRV_PGSQL_NO_TLS_SUPPORT)
             .arg(DatabaseConnection::redactedAccessString(parameters_));
         isc_throw(DbOpenError, "Attempt to configure TLS for PostgreSQL "
                   << "backend (built with this feature disabled)");
index 214f7dc17c15362a48e524bcd0c21f11fddfa2f0..9da073c8984003387d4643910598f71e83c39553 100644 (file)
@@ -258,6 +258,27 @@ TEST(CqlHostDataSource, OpenDatabase) {
     EXPECT_NO_THROW(HostMgr::addBackend(connectionString(CQL_VALID_TYPE,
                     NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD)));
 
+    // Check that CQL does not support SSL/TLS.
+    EXPECT_THROW(HostMgr::addBackend(connectionString(CQL_VALID_TYPE,
+                 VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD,
+                 0, 0, VALID_CERT)),
+                 DbOpenError);
+
+    EXPECT_THROW(HostMgr::addBackend(connectionString(CQL_VALID_TYPE,
+                 VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD,
+                 0, 0, 0, VALID_KEY)),
+                 DbOpenError);
+
+    EXPECT_THROW(HostMgr::addBackend(connectionString(CQL_VALID_TYPE,
+                 VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD,
+                 0, 0, 0, 0, VALID_CA)),
+                 DbOpenError);
+
+    EXPECT_THROW(HostMgr::addBackend(connectionString(CQL_VALID_TYPE,
+                 VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD,
+                 0, 0, 0, 0, 0, VALID_CIPHER)),
+                 DbOpenError);
+
     // Tidy up after the test
     destroyCqlSchema();
 }
index 3d9b7282aca00098346f0c481be2a7c2017306fd..4a76d520dfaf2276d4a6ce97964f98a1a211adfa 100644 (file)
@@ -126,7 +126,7 @@ public:
         ASSERT_GE(leases.size(), 6u);
 
         // Use the same current time for all leases.
-        time_t current_time = time(NULL);
+        time_t current_time = time(0);
 
         // Add them to the database
         for (size_t i = 0u; i < leases.size(); ++i) {
@@ -156,7 +156,7 @@ public:
                   expired_leases.size());
 
         // Update current time for the next test.
-        current_time = time(NULL);
+        current_time = time(0);
         // Also, remove expired leases collected during the previous test.
         expired_leases.clear();
 
@@ -235,7 +235,7 @@ public:
         ASSERT_GE(leases.size(), 6u);
 
         // Use the same current time for all leases.
-        time_t current_time = time(NULL);
+        time_t current_time = time(0);
 
         // Add them to the database
         for (size_t i = 0u; i < leases.size(); ++i) {
@@ -265,7 +265,7 @@ public:
                   expired_leases.size());
 
         // Update current time for the next test.
-        current_time = time(NULL);
+        current_time = time(0);
         // Also, remove expired leases collected during the previous test.
         expired_leases.clear();
 
@@ -379,7 +379,7 @@ TEST(CqlOpenTest, OpenDatabase) {
     // (This is really a check on LeaseMgrFactory, but is convenient to
     // perform here.)
     EXPECT_THROW(LeaseMgrFactory::create(connectionString(
-        NULL, VALID_NAME, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
+        0, VALID_NAME, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
         InvalidParameter);
 
     EXPECT_THROW(LeaseMgrFactory::create(connectionString(
@@ -411,7 +411,7 @@ TEST(CqlOpenTest, OpenDatabase) {
 
     // Check for missing parameters
     EXPECT_NO_THROW(LeaseMgrFactory::create(connectionString(
-        CQL_VALID_TYPE, NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD)));
+        CQL_VALID_TYPE, 0, VALID_HOST, INVALID_USER, VALID_PASSWORD)));
 
     // Check that invalid login data does not cause an exception, CQL should use
     // default values.
@@ -439,7 +439,28 @@ TEST(CqlOpenTest, OpenDatabase) {
 
     // Check that CQL allows the hostname to not be specified.
     EXPECT_NO_THROW(LeaseMgrFactory::create(connectionString(
-        CQL_VALID_TYPE, NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD)));
+        CQL_VALID_TYPE, 0, VALID_HOST, INVALID_USER, VALID_PASSWORD)));
+
+    // Check that CQL does not support SSL/TLS.
+    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
+        CQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD,
+        0, 0, VALID_CERT)),
+        DbOpenError);
+
+    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
+        CQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD,
+        0, 0, 0, VALID_KEY)),
+        DbOpenError);
+
+    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
+        CQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD,
+        0, 0, 0, 0, VALID_CA)),
+        DbOpenError);
+
+    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
+        CQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD,
+        0, 0, 0, 0, 0, VALID_CIPHER)),
+        DbOpenError);
 
     // Tidy up after the test
     destroyCqlSchema();
@@ -464,7 +485,7 @@ TEST_F(CqlLeaseMgrTest, getType) {
 ///
 /// This test checks that the conversion is correct.
 TEST_F(CqlLeaseMgrTest, checkTimeConversion) {
-    const time_t cltt = time(NULL);
+    const time_t cltt = time(0);
     const uint32_t valid_lft = 86400;  // 1 day
     cass_int64_t cql_expire;
 
@@ -634,7 +655,7 @@ TEST_F(CqlLeaseMgrTest, getLeases6Paged) {
 /// @brief Basic Lease4 Checks
 ///
 /// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id),
-/// updateLease4() and deleteLease can handle NULL client-id.
+/// updateLease4() and deleteLease can handle null client-id.
 /// (client-id is optional and may not be present)
 TEST_F(CqlLeaseMgrTest, lease4NullClientId) {
     testLease4NullClientId();
index 75fe15da418724ad910cd26231ac5b841ea6a9d0..7387dee3d2b0a24171dc8952432f09d34bb9c1e0 100644 (file)
@@ -234,6 +234,17 @@ TEST(PgSqlHostDataSource, OpenDatabase) {
         PGSQL_VALID_TYPE, NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
         NoDatabaseName);
 
+    // Check for SSL/TLS support.
+#ifdef HAVE_PGSQL_SSL
+    EXPECT_NO_THROW(HostMgr::addBackend(connectionString(
+        PGSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD,
+        0, 0, 0, 0, VALID_CA)));
+#else
+    EXPECT_THROW(HostMgr::addBackend(connectionString(
+        PGSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD,
+        0, 0, 0, 0, VALID_CA)), DbOpenError);
+#endif
+
     // Tidy up after the test
     destroyPgSQLSchema();
 }
index cbf5d6f77c2946cbef659d3006365a488e1a9977..baeb14515d1411ae0f3dffd06e78f08ea20fabb6 100644 (file)
@@ -197,6 +197,17 @@ TEST(PgSqlOpenTest, OpenDatabase) {
         PGSQL_VALID_TYPE, NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
         NoDatabaseName);
 
+    // Check for SSL/TLS support.
+#ifdef HAVE_PGSQL_SSL
+    EXPECT_NO_THROW(LeaseMgrFactory::create(connectionString(
+        PGSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD,
+        0, 0, 0, 0, VALID_CA)));
+#else
+    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
+        PGSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD,
+        0, 0, 0, 0, VALID_CA)), DbOpenError);
+#endif
+
     // Tidy up after the test
     destroyPgSQLSchema();
     LeaseMgrFactory::destroy();