adamdebreceni commented on a change in pull request #1218:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1218#discussion_r759338022



##########
File path: libminifi/test/unit/tls/TLSStreamTests.cpp
##########
@@ -0,0 +1,82 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#undef LOAD_EXTENSIONS
+#undef NDEBUG
+
+#include <cassert>
+
+#include "io/tls/TLSServerSocket.h"
+#include "io/tls/TLSSocket.h"
+#include "../../TestBase.h"
+#include "../../SimpleSSLTestServer.h"
+#include "../utils/IntegrationTestUtils.h"
+
+using namespace std::chrono_literals;
+
+static std::shared_ptr<minifi::io::TLSContext> createContext(const 
std::filesystem::path& key_dir) {
+  auto configuration = std::make_shared<minifi::Configure>();
+  configuration->set(minifi::Configure::nifi_remote_input_secure, "true");
+  configuration->set(minifi::Configure::nifi_security_client_certificate, 
(key_dir / "cn.crt.pem").string());
+  configuration->set(minifi::Configure::nifi_security_client_private_key, 
(key_dir / "cn.ckey.pem").string());
+  configuration->set(minifi::Configure::nifi_security_client_pass_phrase, 
(key_dir / "cn.pass").string());
+  configuration->set(minifi::Configure::nifi_security_client_ca_certificate, 
(key_dir / "nifi-cert.pem").string());
+  configuration->set(minifi::Configure::nifi_default_directory, 
key_dir.string());
+
+  return std::make_shared<minifi::io::TLSContext>(configuration);
+}
+
+int main(int argc, char** argv) {
+  if (argc < 2) {
+    throw std::logic_error("Specify the key directory");
+  }
+  std::filesystem::path key_dir(argv[1]);
+
+  LogTestController::getInstance().setTrace<minifi::io::Socket>();
+  LogTestController::getInstance().setTrace<minifi::io::TLSSocket>();
+  LogTestController::getInstance().setTrace<minifi::io::TLSServerSocket>();
+  LogTestController::getInstance().setTrace<minifi::io::TLSContext>();
+
+  auto server = std::make_unique<SimpleSSLTestServer>(TLSv1_2_server_method(), 
0, key_dir);

Review comment:
       I tried to use the `TSLServerSocket` but couldn't trigger the observed 
behavior to verify the fix, so I factored out the `SimpleSSLTestServer` and 
used that one instead, now the test should fail when the fix is reverted but 
pass otherwise




-- 
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]


Reply via email to