szaszm commented on code in PR #2170:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2170#discussion_r3318267981


##########
extension-framework/cpp-extension-lib/include/api/utils/Ssl.h:
##########
@@ -0,0 +1,55 @@
+/**
+ * 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.
+ */
+#pragma once
+
+#include <string>
+#include <memory>
+#include <optional>
+#include <filesystem>
+
+#include "utils/Enum.h"
+
+namespace org::apache::nifi::minifi::api::utils::net {
+
+enum class ClientAuthOption {
+  NONE,
+  WANT,
+  REQUIRED
+};
+
+struct SslData {
+  std::filesystem::path ca_loc;
+  std::filesystem::path cert_loc;
+  std::filesystem::path key_loc;
+  std::string key_pw;
+
+  bool isValid() const {
+    return !cert_loc.empty() && !key_loc.empty();
+  }
+};
+
+struct SslServerOptions {
+  SslData cert_data;
+  ClientAuthOption client_auth_option;
+
+  SslServerOptions(SslData cert_data, ClientAuthOption client_auth_option)
+      : cert_data(cert_data),
+      client_auth_option(client_auth_option) {}

Review Comment:
   we could remove this constructor and leave the struct to be an aggregate
   ```suggestion
   ```



##########
extension-framework/cpp-extension-lib/mocklib/include/MockProcessSession.h:
##########
@@ -0,0 +1,80 @@
+/**
+ * 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.
+ */
+
+#pragma once
+#include <map>
+#include <ranges>
+
+#include "MockUtils.h"
+#include "api/core/ProcessSession.h"
+#include "range/v3/range/conversion.hpp"
+#include "range/v3/view/transform.hpp"
+
+struct MinifiFlowFile {
+  explicit MinifiFlowFile(std::string content_str) {
+    this->content = content_str
+           | ranges::views::transform([](char c) { return 
static_cast<std::byte>(c); })
+           | ranges::to<std::vector<std::byte>>();
+  }
+
+  ~MinifiFlowFile() = default;
+
+  MinifiFlowFile() = default;
+  MinifiFlowFile(const MinifiFlowFile&) = default;
+  MinifiFlowFile(MinifiFlowFile&&) = default;
+  MinifiFlowFile& operator=(const MinifiFlowFile&) = default;
+  MinifiFlowFile& operator=(MinifiFlowFile&&) = default;
+
+  std::map<std::string, std::string> attributes;
+  std::vector<std::byte> content;
+  bool is_penalized = false;
+  std::string id;
+};
+
+namespace org::apache::nifi::minifi::mock {
+
+class MockProcessSession : public api::core::ProcessSession {
+ public:
+  MockProcessSession() = default;
+  MockProcessSession(const MockProcessSession&) = delete;
+  MockProcessSession& operator=(const MockProcessSession&) = delete;
+  MockProcessSession(MockProcessSession&&) = delete;
+  MockProcessSession& operator=(MockProcessSession&&) = delete;
+
+  api::core::FlowFile create(const api::core::FlowFile* parent) override;
+  api::core::FlowFile get() override;
+  void penalize(api::core::FlowFile& ff) override;
+  void transfer(api::core::FlowFile ff, const minifi::core::Relationship& 
relationship) override;
+  void remove(api::core::FlowFile ff) override;
+  void write(api::core::FlowFile& ff, const io::OutputStreamCallback& 
callback) override;
+  void read(api::core::FlowFile& ff, const io::InputStreamCallback& callback) 
override;
+  void setAttribute(api::core::FlowFile& ff, std::string_view key, std::string 
value) override;
+  void removeAttribute(api::core::FlowFile& ff, std::string_view key) override;
+  std::optional<std::string> getAttribute(api::core::FlowFile& ff, 
std::string_view key) override;
+  [[nodiscard]] std::map<std::string, std::string> getAttributes(const 
api::core::FlowFile& ff) const override;
+  [[nodiscard]] std::string getFlowFileId(const api::core::FlowFile& ff) const 
override;
+  [[nodiscard]] uint64_t getFlowFileSize(const api::core::FlowFile& ff) const 
override;
+
+  void addInputFlowFile(std::unique_ptr<MinifiFlowFile> flow_file);
+
+ private:
+  std::vector<std::unique_ptr<MinifiFlowFile>> input_flow_files_;
+  std::map<std::string, std::vector<std::unique_ptr<MinifiFlowFile>>> 
transferred_flow_files_;

Review Comment:
   I'm guessing relationships are the key, I would add an inline comment to 
indicate that. Optionally you could also replace it with a Relationship object, 
the same one as session transfer takes
   ```suggestion
     std::map<std::string /* relationship name */, 
std::vector<std::unique_ptr<MinifiFlowFile>>> transferred_flow_files_;
   ```



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