This is an automated email from the ASF dual-hosted git repository.

martinzink pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new 8cd8464d6 MINIFICPP-2644 Add proxy controller service support for GCP 
processors (#2112)
8cd8464d6 is described below

commit 8cd8464d6d621fb22f5c96ec459820135476b19f
Author: Gabor Gyimesi <[email protected]>
AuthorDate: Thu Apr 30 19:36:34 2026 +0200

    MINIFICPP-2644 Add proxy controller service support for GCP processors 
(#2112)
---
 PROCESSORS.md                                      |   4 +
 .../minifi_behave/containers/container_linux.py    |   4 +
 .../src/minifi_behave/steps/flow_building_steps.py |   5 +-
 extensions/gcp/processors/GCSProcessor.cpp         |  26 ++++
 extensions/gcp/processors/GCSProcessor.h           |   9 +-
 .../tests/features/google_cloud_storage.feature    | 139 ++++++++++++++++++++-
 6 files changed, 183 insertions(+), 4 deletions(-)

diff --git a/PROCESSORS.md b/PROCESSORS.md
index 10779236f..cf26f1ff8 100644
--- a/PROCESSORS.md
+++ b/PROCESSORS.md
@@ -585,6 +585,7 @@ In the list below, the names of required properties appear 
in bold. Any other pr
 | **GCP Credentials Provider Service** |               |                  | 
The Controller Service used to obtain Google Cloud Platform credentials. Should 
be the name of a GCPCredentialsControllerService.                |
 | **Number of retries**                | 6             |                  | 
How many retry attempts should be made before routing to the failure 
relationship.                                                               |
 | Endpoint Override URL                |               |                  | 
Overrides the default Google Cloud Storage endpoints<br/>**Supports Expression 
Language: true**                                                  |
+| Proxy Configuration Service          |               |                  | 
Specifies the Proxy Configuration Controller Service to proxy network requests. 
                                                                 |
 | Bucket                               | ${gcs.bucket} |                  | 
Bucket of the object.<br/>**Supports Expression Language: true**                
                                                                 |
 | Key                                  | ${filename}   |                  | 
Name of the object.<br/>**Supports Expression Language: true**                  
                                                                 |
 | Server Side Encryption Key           |               |                  | 
The AES256 Encryption Key (encoded in base64) for server-side decryption of the 
object.<br/>**Supports Expression Language: true**               |
@@ -885,6 +886,7 @@ In the list below, the names of required properties appear 
in bold. Any other pr
 | **GCP Credentials Provider Service** |               |                  | 
The Controller Service used to obtain Google Cloud Platform credentials. Should 
be the name of a GCPCredentialsControllerService.                               
    |
 | **Number of retries**                | 6             |                  | 
How many retry attempts should be made before routing to the failure 
relationship.                                                                   
               |
 | Endpoint Override URL                |               |                  | 
Overrides the default Google Cloud Storage endpoints<br/>**Supports Expression 
Language: true**                                                                
     |
+| Proxy Configuration Service          |               |                  | 
Specifies the Proxy Configuration Controller Service to proxy network requests. 
                                                                                
    |
 | Bucket                               | ${gcs.bucket} |                  | 
Bucket of the object.<br/>**Supports Expression Language: true**                
                                                                                
    |
 | Key                                  | ${filename}   |                  | 
Name of the object.<br/>**Supports Expression Language: true**                  
                                                                                
    |
 | Server Side Encryption Key           |               |                  | 
The AES256 Encryption Key (encoded in base64) for server-side decryption of the 
object.<br/>**Sensitive Property: true**<br/>**Supports Expression Language: 
true** |
@@ -1608,6 +1610,7 @@ In the list below, the names of required properties 
appear in bold. Any other pr
 | **GCP Credentials Provider Service** |               |                  | 
The Controller Service used to obtain Google Cloud Platform credentials. Should 
be the name of a GCPCredentialsControllerService. |
 | **Number of retries**                | 6             |                  | 
How many retry attempts should be made before routing to the failure 
relationship.                                                |
 | Endpoint Override URL                |               |                  | 
Overrides the default Google Cloud Storage endpoints<br/>**Supports Expression 
Language: true**                                   |
+| Proxy Configuration Service          |               |                  | 
Specifies the Proxy Configuration Controller Service to proxy network requests. 
                                                  |
 | **Bucket**                           |               |                  | 
Bucket of the object.<br/>**Supports Expression Language: true**                
                                                  |
 | List all versions                    | false         | true<br/>false   | 
Set this option to `true` to get all the previous versions separately.          
                                                  |
 
@@ -2423,6 +2426,7 @@ In the list below, the names of required properties 
appear in bold. Any other pr
 | **GCP Credentials Provider Service** |               |                       
                                                                                
                             | The Controller Service used to obtain Google 
Cloud Platform credentials. Should be the name of a 
GCPCredentialsControllerService.                                  |
 | **Number of retries**                | 6             |                       
                                                                                
                             | How many retry attempts should be made before 
routing to the failure relationship.                                            
                                     |
 | Endpoint Override URL                |               |                       
                                                                                
                             | Overrides the default Google Cloud Storage 
endpoints<br/>**Supports Expression Language: true**                            
                                        |
+| Proxy Configuration Service          |               |                       
                                                                                
                             | Specifies the Proxy Configuration Controller 
Service to proxy network requests.                                              
                                      |
 | Bucket                               | ${gcs.bucket} |                       
                                                                                
                             | Bucket of the object.<br/>**Supports Expression 
Language: true**                                                                
                                   |
 | Key                                  | ${filename}   |                       
                                                                                
                             | Name of the object.<br/>**Supports Expression 
Language: true**                                                                
                                     |
 | Content Type                         | ${mime.type}  |                       
                                                                                
                             | Content Type for the file, i.e. text/plain 
<br/>**Supports Expression Language: true**                                     
                                        |
diff --git a/behave_framework/src/minifi_behave/containers/container_linux.py 
b/behave_framework/src/minifi_behave/containers/container_linux.py
index 1144941d6..da0dcbc0a 100644
--- a/behave_framework/src/minifi_behave/containers/container_linux.py
+++ b/behave_framework/src/minifi_behave/containers/container_linux.py
@@ -56,6 +56,9 @@ class LinuxContainer(ContainerProtocol):
         self.ports: dict[str, int] | None = None
         self.environment: list[str] = []
 
+    def is_deployed(self) -> bool:
+        return self.container is not None
+
     def add_host_file(self, host_path: str, container_path: str, mode: str = 
"ro"):
         self.host_files.append(HostFile(container_path, host_path, mode))
 
@@ -109,6 +112,7 @@ class LinuxContainer(ContainerProtocol):
         if self.is_deployed():
             logging.info(f"Container '{self.container_name}' is already 
deployed.")
             return True
+
         self._temp_dir = tempfile.TemporaryDirectory()
         self._configure_volumes_of_container_files()
         self._configure_volumes_of_container_dirs()
diff --git a/behave_framework/src/minifi_behave/steps/flow_building_steps.py 
b/behave_framework/src/minifi_behave/steps/flow_building_steps.py
index 4abcec770..40414a9e9 100644
--- a/behave_framework/src/minifi_behave/steps/flow_building_steps.py
+++ b/behave_framework/src/minifi_behave/steps/flow_building_steps.py
@@ -244,10 +244,11 @@ def set_processor_properties(context: MinifiTestContext):
 @given("a ProxyConfigurationService controller service is set up with 
{proxy_type} proxy configuration in the \"{container_name}\" flow")
 def step_impl(context: MinifiTestContext, proxy_type: str, container_name: 
str):
     controller_service = 
ControllerService(class_name="ProxyConfigurationService", 
service_name="ProxyConfigurationService")
-    controller_service.add_property("Proxy Server Host", 
f"{proxy_type.lower()}://http-proxy-{context.scenario_id}")
+    prefix = proxy_type.lower() if proxy_type.lower() != "direct" else "http"
+    controller_service.add_property("Proxy Server Host", 
f"{prefix}://http-proxy-{context.scenario_id}")
     controller_service.add_property("Proxy User Name", "admin")
     controller_service.add_property("Proxy User Password", "test101")
-    controller_service.add_property("Proxy Type", "HTTP")
+    controller_service.add_property("Proxy Type", "DIRECT" if 
proxy_type.lower() == "direct" else "HTTP")
     if proxy_type.lower() == "http":
         controller_service.add_property("Proxy Server Port", "3128")
     else:
diff --git a/extensions/gcp/processors/GCSProcessor.cpp 
b/extensions/gcp/processors/GCSProcessor.cpp
index 91d48d64a..274b3f93c 100644
--- a/extensions/gcp/processors/GCSProcessor.cpp
+++ b/extensions/gcp/processors/GCSProcessor.cpp
@@ -48,6 +48,28 @@ void GCSProcessor::onSchedule(core::ProcessContext& context, 
core::ProcessSessio
   endpoint_url_ = context.getProperty(EndpointOverrideURL) | 
utils::toOptional();
   if (endpoint_url_)
     logger_->log_debug("Endpoint overwritten: {}", *endpoint_url_);
+
+  auto proxy_controller_service = 
minifi::utils::parseOptionalControllerService<minifi::controllers::ProxyConfigurationServiceInterface>(context,
 ProxyConfigurationService, getUUID());
+  if (proxy_controller_service && proxy_controller_service->getProxyType() != 
minifi::controllers::ProxyType::DIRECT) {
+    logger_->log_debug("Proxy configuration is set for GCS processor");
+
+    proxy_ = google::cloud::ProxyConfig{};
+    
proxy_->set_scheme(minifi::utils::string::startsWith(proxy_controller_service->getHost(),
 "https") ? "https" : "http");
+    auto proxy_host = proxy_controller_service->getHost();
+    constexpr std::string_view https_prefix = "https://";;
+    constexpr std::string_view http_prefix = "http://";;
+    if (minifi::utils::string::startsWith(proxy_host, https_prefix)) {
+      proxy_host = proxy_host.substr(https_prefix.size());
+    } else if (minifi::utils::string::startsWith(proxy_host, http_prefix)) {
+      proxy_host = proxy_host.substr(http_prefix.size());
+    }
+    proxy_->set_hostname(proxy_host);
+    proxy_->set_port(std::to_string(proxy_controller_service->getPort()));
+    if (auto proxy_credentials = 
proxy_controller_service->getProxyCredentials()) {
+      proxy_->set_username(proxy_credentials->username);
+      proxy_->set_password(proxy_credentials->password);
+    }
+  }
 }
 
 gcs::Client GCSProcessor::getClient() const {
@@ -55,6 +77,10 @@ gcs::Client GCSProcessor::getClient() const {
       .set<google::cloud::UnifiedCredentialsOption>(gcp_credentials_)
       .set<google::cloud::storage::RetryPolicyOption>(retry_policy_);
 
+  if (proxy_) {
+    options.set<google::cloud::ProxyOption>(*proxy_);
+  }
+
   if (endpoint_url_) {
     options.set<gcs::RestEndpointOption>(*endpoint_url_);
   }
diff --git a/extensions/gcp/processors/GCSProcessor.h 
b/extensions/gcp/processors/GCSProcessor.h
index 1ec2b6641..af6a92ace 100644
--- a/extensions/gcp/processors/GCSProcessor.h
+++ b/extensions/gcp/processors/GCSProcessor.h
@@ -30,6 +30,7 @@
 #include "google/cloud/credentials.h"
 #include "google/cloud/storage/client.h"
 #include "google/cloud/storage/retry_policy.h"
+#include "minifi-cpp/controllers/ProxyConfigurationServiceInterface.h"
 
 namespace org::apache::nifi::minifi::extensions::gcp {
 class GCSProcessor : public core::ProcessorImpl {
@@ -53,10 +54,15 @@ class GCSProcessor : public core::ProcessorImpl {
       .isRequired(false)
       .supportsExpressionLanguage(true)
       .build();
+  EXTENSIONAPI static constexpr auto ProxyConfigurationService = 
core::PropertyDefinitionBuilder<>::createProperty("Proxy Configuration Service")
+      .withDescription("Specifies the Proxy Configuration Controller Service 
to proxy network requests.")
+      
.withAllowedTypes<minifi::controllers::ProxyConfigurationServiceInterface>()
+      .build();
   EXTENSIONAPI static constexpr auto Properties = 
std::to_array<core::PropertyReference>({
       GCPCredentials,
       NumberOfRetries,
-      EndpointOverrideURL
+      EndpointOverrideURL,
+      ProxyConfigurationService
   });
 
 
@@ -68,6 +74,7 @@ class GCSProcessor : public core::ProcessorImpl {
 
   std::optional<std::string> endpoint_url_;
   std::shared_ptr<google::cloud::Credentials> gcp_credentials_;
+  std::optional<google::cloud::ProxyConfig> proxy_;
   google::cloud::storage::RetryPolicyOption::Type retry_policy_ = 
std::make_shared<google::cloud::storage::LimitedErrorCountRetryPolicy>(6);
 };
 
diff --git a/extensions/gcp/tests/features/google_cloud_storage.feature 
b/extensions/gcp/tests/features/google_cloud_storage.feature
index 433024cd4..dae15f0bf 100644
--- a/extensions/gcp/tests/features/google_cloud_storage.feature
+++ b/extensions/gcp/tests/features/google_cloud_storage.feature
@@ -35,11 +35,47 @@ Feature: Sending data to Google Cloud Storage using 
PutGCSObject
     And the "failure" relationship of the PutGCSObject processor is connected 
to the PutGCSObject
     And PutFile's success relationship is auto-terminated
 
-    When the MiNiFi instance starts up
+    When all instances start up
 
     Then a single file with the content "hello_gcs" is placed in the 
"/tmp/output" directory in less than 45 seconds
     And an object with the content "hello_gcs" is present in the Google Cloud 
storage
 
+  Scenario Outline: A MiNiFi instance can upload data to Google Cloud storage 
through a http proxy
+    Given the http proxy server is set up
+    And a GetFile processor with the "Input Directory" property set to 
"/tmp/input"
+    And the "Keep Source File" property of the GetFile processor is set to 
"true"
+    And the scheduling period of the GetFile processor is set to "60 sec"
+    And a file with the content "hello_gcs" is present in "/tmp/input"
+    And a Google Cloud storage server is set up
+    And a PutGCSObject processor
+    And the "Proxy Configuration Service" property of the PutGCSObject 
processor is set to "ProxyConfigurationService"
+    And PutGCSObject is EVENT_DRIVEN
+    And a GCPCredentialsControllerService controller service is set up
+    And the "Credentials Location" property of the 
GCPCredentialsControllerService controller service is set to "Use Anonymous 
credentials"
+    And the "GCP Credentials Provider Service" property of the PutGCSObject 
processor is set to "GCPCredentialsControllerService"
+    And the "Bucket" property of the PutGCSObject processor is set to 
"test-bucket"
+    And the "Number of retries" property of the PutGCSObject processor is set 
to "2"
+    And the "Endpoint Override URL" property of the PutGCSObject processor is 
set to "fake-gcs-server-${scenario_id}:4443"
+    And a PutFile processor with the "Directory" property set to "/tmp/output"
+    And PutFile is EVENT_DRIVEN
+    And a ProxyConfigurationService controller service is set up with <proxy 
type> proxy configuration
+    And the "success" relationship of the GetFile processor is connected to 
the PutGCSObject
+    And the "success" relationship of the PutGCSObject processor is connected 
to the PutFile
+    And the "failure" relationship of the PutGCSObject processor is connected 
to the PutGCSObject
+    And PutFile's success relationship is auto-terminated
+    And PutFile's failure relationship is auto-terminated
+
+    When all instances start up
+
+    Then a single file with the content "hello_gcs" is placed in the 
"/tmp/output" directory in less than 60 seconds
+    And an object with the content "hello_gcs" is present in the Google Cloud 
storage
+    And no errors were generated on the http-proxy regarding 
"http://fake-gcs-server-${scenario_id}:4443/";
+
+    Examples: Proxy Type
+    | proxy type |
+    | HTTP       |
+    | HTTPS      |
+
   Scenario: A MiNiFi instance can fetch the listed objects from Google Cloud 
storage bucket
     Given a Google Cloud storage server is set up and a single object with 
contents "preloaded data" is present
     And a GCPCredentialsControllerService controller service is set up
@@ -65,6 +101,42 @@ Feature: Sending data to Google Cloud Storage using 
PutGCSObject
 
     Then a single file with the content "preloaded data" is placed in the 
"/tmp/output" directory in less than 10 seconds
 
+  Scenario Outline: A MiNiFi instance can fetch the listed objects from Google 
Cloud storage bucket through a http proxy
+    Given the http proxy server is set up
+    And a Google Cloud storage server is set up and a single object with 
contents "preloaded data" is present
+    And a GCPCredentialsControllerService controller service is set up
+    And the "Credentials Location" property of the 
GCPCredentialsControllerService controller service is set to "Use Anonymous 
credentials"
+    And a ListGCSBucket processor
+    And the "Bucket" property of the ListGCSBucket processor is set to 
"test-bucket"
+    And the "Number of retries" property of the ListGCSBucket processor is set 
to "2"
+    And the "Endpoint Override URL" property of the ListGCSBucket processor is 
set to "fake-gcs-server-${scenario_id}:4443"
+    And the "GCP Credentials Provider Service" property of the ListGCSBucket 
processor is set to "GCPCredentialsControllerService"
+    And the "Proxy Configuration Service" property of the ListGCSBucket 
processor is set to "ProxyConfigurationService"
+    And a FetchGCSObject processor
+    And FetchGCSObject is EVENT_DRIVEN
+    And the "Bucket" property of the FetchGCSObject processor is set to 
"test-bucket"
+    And the "Number of retries" property of the FetchGCSObject processor is 
set to "2"
+    And the "Endpoint Override URL" property of the FetchGCSObject processor 
is set to "fake-gcs-server-${scenario_id}:4443"
+    And the "GCP Credentials Provider Service" property of the FetchGCSObject 
processor is set to "GCPCredentialsControllerService"
+    And the "Proxy Configuration Service" property of the FetchGCSObject 
processor is set to "ProxyConfigurationService"
+    And a PutFile processor with the "Directory" property set to "/tmp/output"
+    And PutFile is EVENT_DRIVEN
+    And a ProxyConfigurationService controller service is set up with <proxy 
type> proxy configuration
+    And the "success" relationship of the ListGCSBucket processor is connected 
to the FetchGCSObject
+    And the "success" relationship of the FetchGCSObject processor is 
connected to the PutFile
+    And PutFile's success relationship is auto-terminated
+    And PutFile's failure relationship is auto-terminated
+
+    When all instances start up
+
+    Then a single file with the content "preloaded data" is placed in the 
"/tmp/output" directory in less than 20 seconds
+    And no errors were generated on the http-proxy regarding 
"http://fake-gcs-server-${scenario_id}:4443/";
+
+    Examples: Proxy Type
+    | proxy type |
+    | HTTP       |
+    | HTTPS      |
+
   Scenario: A MiNiFi instance can delete the listed objects from Google Cloud 
storage bucket
     Given a Google Cloud storage server is set up with some test data
     And a GCPCredentialsControllerService controller service is set up
@@ -89,3 +161,68 @@ Feature: Sending data to Google Cloud Storage using 
PutGCSObject
 
     Then the test bucket of Google Cloud Storage is empty
     And at least one empty file is placed in the "/tmp/output" directory in 
less than 10 seconds
+
+  Scenario Outline: A MiNiFi instance can delete the listed objects from 
Google Cloud storage bucket through a http proxy
+    Given the http proxy server is set up
+    Given a Google Cloud storage server is set up with some test data
+    And a GCPCredentialsControllerService controller service is set up
+    And the "Credentials Location" property of the 
GCPCredentialsControllerService controller service is set to "Use Anonymous 
credentials"
+    And a ListGCSBucket processor
+    And the "Bucket" property of the ListGCSBucket processor is set to 
"test-bucket"
+    And the "Number of retries" property of the ListGCSBucket processor is set 
to "2"
+    And the "Endpoint Override URL" property of the ListGCSBucket processor is 
set to "fake-gcs-server-${scenario_id}:4443"
+    And the "GCP Credentials Provider Service" property of the ListGCSBucket 
processor is set to "GCPCredentialsControllerService"
+    And the "Proxy Configuration Service" property of the ListGCSBucket 
processor is set to "ProxyConfigurationService"
+    And a DeleteGCSObject processor
+    And DeleteGCSObject is EVENT_DRIVEN
+    And the "Bucket" property of the DeleteGCSObject processor is set to 
"test-bucket"
+    And the "Number of retries" property of the DeleteGCSObject processor is 
set to "2"
+    And the "Endpoint Override URL" property of the DeleteGCSObject processor 
is set to "fake-gcs-server-${scenario_id}:4443"
+    And the "GCP Credentials Provider Service" property of the DeleteGCSObject 
processor is set to "GCPCredentialsControllerService"
+    And the "Proxy Configuration Service" property of the DeleteGCSObject 
processor is set to "ProxyConfigurationService"
+    And a PutFile processor with the "Directory" property set to "/tmp/output"
+    And a ProxyConfigurationService controller service is set up with <proxy 
type> proxy configuration
+    And the "success" relationship of the ListGCSBucket processor is connected 
to the DeleteGCSObject
+    And the "success" relationship of the DeleteGCSObject processor is 
connected to the PutFile
+    And PutFile's success relationship is auto-terminated
+    And PutFile's failure relationship is auto-terminated
+
+    When all instances start up
+
+    Then the test bucket of Google Cloud Storage is empty
+    And at least one empty file is placed in the "/tmp/output" directory in 
less than 10 seconds
+    And no errors were generated on the http-proxy regarding 
"http://fake-gcs-server-${scenario_id}:4443/";
+
+    Examples: Proxy Type
+    | proxy type |
+    | HTTP       |
+    | HTTPS      |
+
+  Scenario: A MiNiFi instance can upload data to Google Cloud storage when 
http proxy is configured but the proxy configuration service indicates DIRECT 
connection
+    Given a GetFile processor with the "Input Directory" property set to 
"/tmp/input"
+    And the "Keep Source File" property of the GetFile processor is set to 
"true"
+    And the scheduling period of the GetFile processor is set to "60 sec"
+    And a file with the content "hello_gcs" is present in "/tmp/input"
+    And a Google Cloud storage server is set up
+    And a PutGCSObject processor
+    And the "Proxy Configuration Service" property of the PutGCSObject 
processor is set to "ProxyConfigurationService"
+    And PutGCSObject is EVENT_DRIVEN
+    And a GCPCredentialsControllerService controller service is set up
+    And the "Credentials Location" property of the 
GCPCredentialsControllerService controller service is set to "Use Anonymous 
credentials"
+    And the "GCP Credentials Provider Service" property of the PutGCSObject 
processor is set to "GCPCredentialsControllerService"
+    And the "Bucket" property of the PutGCSObject processor is set to 
"test-bucket"
+    And the "Number of retries" property of the PutGCSObject processor is set 
to "2"
+    And the "Endpoint Override URL" property of the PutGCSObject processor is 
set to "fake-gcs-server-${scenario_id}:4443"
+    And a PutFile processor with the "Directory" property set to "/tmp/output"
+    And PutFile is EVENT_DRIVEN
+    And a ProxyConfigurationService controller service is set up with DIRECT 
proxy configuration
+    And the "success" relationship of the GetFile processor is connected to 
the PutGCSObject
+    And the "success" relationship of the PutGCSObject processor is connected 
to the PutFile
+    And the "failure" relationship of the PutGCSObject processor is connected 
to the PutGCSObject
+    And PutFile's success relationship is auto-terminated
+    And PutFile's failure relationship is auto-terminated
+
+    When all instances start up
+
+    Then a single file with the content "hello_gcs" is placed in the 
"/tmp/output" directory in less than 60 seconds
+    And an object with the content "hello_gcs" is present in the Google Cloud 
storage

Reply via email to