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

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

commit a6ef49d7ae296061161e30e972cccaf13080342a
Author: Gabor Gyimesi <[email protected]>
AuthorDate: Thu Sep 26 17:55:49 2024 +0200

    MINIFICPP-2456 Remove curl output from Elasticsearch responses
    
    Closes #1867
    
    Signed-off-by: Marton Szasz <[email protected]>
---
 .../integration/cluster/checkers/ElasticSearchChecker.py   | 14 ++++++++------
 docker/test/integration/features/utils.py                  |  2 +-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/docker/test/integration/cluster/checkers/ElasticSearchChecker.py 
b/docker/test/integration/cluster/checkers/ElasticSearchChecker.py
index 34186cc4e..e35baa25c 100644
--- a/docker/test/integration/cluster/checkers/ElasticSearchChecker.py
+++ b/docker/test/integration/cluster/checkers/ElasticSearchChecker.py
@@ -20,27 +20,29 @@ class ElasticSearchChecker:
         self.container_communicator = container_communicator
 
     def is_elasticsearch_empty(self, container_name):
-        (code, output) = 
self.container_communicator.execute_command(container_name, ["curl", "-u", 
"elastic:password", "-k", "-XGET", "https://localhost:9200/_search";])
+        (code, output) = 
self.container_communicator.execute_command(container_name, ["curl", "-s", 
"-u", "elastic:password", "-k", "-XGET", "https://localhost:9200/_search";])
         return code == 0 and '"hits":[]' in output
 
     def create_doc_elasticsearch(self, container_name, index_name, doc_id):
         (code, output) = 
self.container_communicator.execute_command(container_name, ["/bin/bash", "-c",
-                                                                               
       "curl -u elastic:password -k -XPUT https://localhost:9200/"; + index_name 
+ "/_doc/" + doc_id + " -H Content-Type:application/json 
-d'{\"field1\":\"value1\"}'"])
+                                                                               
       "curl -s -u elastic:password -k -XPUT https://localhost:9200/"; + 
index_name + "/_doc/" + doc_id + " -H Content-Type:application/json 
-d'{\"field1\":\"value1\"}'"])
         return code == 0 and ('"_id":"' + doc_id + '"') in output
 
     def check_elastic_field_value(self, container_name, index_name, doc_id, 
field_name, field_value):
         (code, output) = 
self.container_communicator.execute_command(container_name, ["/bin/bash", "-c",
-                                                                               
       "curl -u elastic:password -k -XGET https://localhost:9200/"; + index_name 
+ "/_doc/" + doc_id])
+                                                                               
       "curl -s -u elastic:password -k -XGET https://localhost:9200/"; + 
index_name + "/_doc/" + doc_id])
         return code == 0 and (field_name + '":"' + field_value) in output
 
     def elastic_generate_apikey(self, elastic_container_name):
-        (_, output) = 
self.container_communicator.execute_command(elastic_container_name, 
["/bin/bash", "-c",
-                                                                               
            "curl -u elastic:password -k -XPOST 
https://localhost:9200/_security/api_key -H Content-Type:application/json 
-d'{\"name\":\"my-api-key\",\"expiration\":\"1d\",\"role_descriptors\":{\"role-a\":
 {\"cluster\": [\"all\"],\"index\": [{\"names\": [\"my_index\"],\"privileges\": 
[\"all\"]}]}}}'"])
+        (code, output) = 
self.container_communicator.execute_command(elastic_container_name, 
["/bin/bash", "-c",
+                                                                               
               "curl -s -u elastic:password -k -XPOST 
https://localhost:9200/_security/api_key -H Content-Type:application/json 
-d'{\"name\":\"my-api-key\",\"expiration\":\"1d\",\"role_descriptors\":{\"role-a\":
 {\"cluster\": [\"all\"],\"index\": [{\"names\": [\"my_index\"],\"privileges\": 
[\"all\"]}]}}}'"])
+        if code != 0:
+            return None
         output_lines = output.splitlines()
         result = json.loads(output_lines[-1])
         return result["encoded"]
 
     def add_elastic_user_to_opensearch(self, container_name):
         (code, output) = 
self.container_communicator.execute_command(container_name, ["/bin/bash", "-c",
-                                                                               
       'curl -u admin:admin -k -XPUT 
https://{hostname}:9200/_plugins/_security/api/internalusers/elastic -H 
Content-Type:application/json 
-d\'{{"password":"password","backend_roles":["admin"]}}\''.format(hostname=container_name)])
+                                                                               
       'curl -s -u admin:admin -k -XPUT 
https://{hostname}:9200/_plugins/_security/api/internalusers/elastic -H 
Content-Type:application/json 
-d\'{{"password":"password","backend_roles":["admin"]}}\''.format(hostname=container_name)])
         return code == 0 and '"status":"CREATED"' in output
diff --git a/docker/test/integration/features/utils.py 
b/docker/test/integration/features/utils.py
index 15db614d2..bd86cbab0 100644
--- a/docker/test/integration/features/utils.py
+++ b/docker/test/integration/features/utils.py
@@ -25,7 +25,7 @@ def retry_check(max_tries=5, retry_interval=1):
     def retry_check_func(func):
         @functools.wraps(func)
         def retry_wrapper(*args, **kwargs):
-            for i in range(max_tries):
+            for _ in range(max_tries):
                 if func(*args, **kwargs):
                     return True
                 time.sleep(retry_interval)

Reply via email to