szaszm commented on code in PR #2284:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2284#discussion_r4258777279
##########
extensions/kafka/tests/PublishKafkaTests.cpp:
##########
@@ -55,4 +60,39 @@ TEST_CASE("Trigger without valid broker", "[PublishKafka]") {
CHECK_FALSE(logger->logs_.empty());
}
+namespace {
+bool hasDebugLog(const mock::MockLogger& logger, std::string_view message) {
+ const auto debug_logs = logger.logs_.find(core::logging::LOG_LEVEL::debug);
+ return debug_logs != logger.logs_.end() &&
std::ranges::any_of(debug_logs->second, [&](const auto& log) { return
log.contains(message); });
+}
+} // namespace
+
+TEST_CASE("Security properties are used for SSL connection when no SSL Context
Service is set", "[PublishKafka]") {
+ const auto logger = std::make_shared<mock::MockLogger>();
+ auto publish_kafka = PublishKafka(mock::metadataWithLogger(logger));
+ auto context = mock::MockProcessContext{};
+ const auto ca_cert_path = (std::filesystem::path(TEST_RESOURCES) /
"nifi-cert.pem").string();
+ context.properties_.emplace(PublishKafka::ClientName.name, "test_client");
+ context.properties_.emplace(PublishKafka::SeedBrokers.name,
"test_seedbroker");
+ context.properties_.emplace(PublishKafka::SecurityProtocol.name, "ssl");
+ context.properties_.emplace(PublishKafka::SecurityCA.name, ca_cert_path);
+
+ REQUIRE_NOTHROW(publish_kafka.onScheduleImpl(context));
+
+ CHECK(hasDebugLog(*logger, "Kafka ssl.ca.location [" + ca_cert_path + "]"));
Review Comment:
I'd skip this too, it doesn't really matter
##########
extensions/kafka/tests/PublishKafkaTests.cpp:
##########
@@ -55,4 +60,39 @@ TEST_CASE("Trigger without valid broker", "[PublishKafka]") {
CHECK_FALSE(logger->logs_.empty());
}
+namespace {
+bool hasDebugLog(const mock::MockLogger& logger, std::string_view message) {
+ const auto debug_logs = logger.logs_.find(core::logging::LOG_LEVEL::debug);
+ return debug_logs != logger.logs_.end() &&
std::ranges::any_of(debug_logs->second, [&](const auto& log) { return
log.contains(message); });
+}
+} // namespace
+
+TEST_CASE("Security properties are used for SSL connection when no SSL Context
Service is set", "[PublishKafka]") {
+ const auto logger = std::make_shared<mock::MockLogger>();
+ auto publish_kafka = PublishKafka(mock::metadataWithLogger(logger));
+ auto context = mock::MockProcessContext{};
+ const auto ca_cert_path = (std::filesystem::path(TEST_RESOURCES) /
"nifi-cert.pem").string();
+ context.properties_.emplace(PublishKafka::ClientName.name, "test_client");
+ context.properties_.emplace(PublishKafka::SeedBrokers.name,
"test_seedbroker");
+ context.properties_.emplace(PublishKafka::SecurityProtocol.name, "ssl");
+ context.properties_.emplace(PublishKafka::SecurityCA.name, ca_cert_path);
+
+ REQUIRE_NOTHROW(publish_kafka.onScheduleImpl(context));
+
+ CHECK(hasDebugLog(*logger, "Kafka ssl.ca.location [" + ca_cert_path + "]"));
+}
+
+TEST_CASE("System CA certificate locations are probed when no CA certificate
is set for SSL connection", "[PublishKafka]") {
+ const auto logger = std::make_shared<mock::MockLogger>();
+ auto publish_kafka = PublishKafka(mock::metadataWithLogger(logger));
+ auto context = mock::MockProcessContext{};
+ context.properties_.emplace(PublishKafka::ClientName.name, "test_client");
+ context.properties_.emplace(PublishKafka::SeedBrokers.name,
"test_seedbroker");
+ context.properties_.emplace(PublishKafka::SecurityProtocol.name, "ssl");
+
+ REQUIRE_NOTHROW(publish_kafka.onScheduleImpl(context));
+
+ CHECK(hasDebugLog(*logger, "Kafka ssl.ca.location [probe]"));
Review Comment:
I'd skip this too, it doesn't really matter
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]