lordgamez commented on code in PR #2067:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2067#discussion_r2665156132


##########
extensions/elasticsearch/tests/features/steps/elasticsearch_container.py:
##########
@@ -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.
+
+import json
+import logging
+import os
+
+from elastic_base_container import ElasticBaseContainer
+from pathlib import Path
+from OpenSSL import crypto
+from minifi_test_framework.core.ssl_utils import make_server_cert, 
make_cert_without_extended_usage
+from minifi_test_framework.containers.file import File
+from minifi_test_framework.containers.host_file import HostFile
+from minifi_test_framework.core.minifi_test_context import MinifiTestContext
+
+
+class ElasticsearchContainer(ElasticBaseContainer):
+    def __init__(self, test_context: MinifiTestContext):
+        super().__init__(test_context, "elasticsearch:9.1.5", 
f"elasticsearch-{test_context.scenario_id}")
+
+        http_cert, http_key = make_server_cert(self.container_name, 
test_context.root_ca_cert, test_context.root_ca_key)
+        transport_cert, transport_key = 
make_cert_without_extended_usage(self.container_name, 
test_context.root_ca_cert, test_context.root_ca_key)
+
+        root_ca_content = crypto.dump_certificate(type=crypto.FILETYPE_PEM, 
cert=test_context.root_ca_cert)
+        
self.files.append(File("/usr/share/elasticsearch/config/certs/root_ca.crt", 
root_ca_content, permissions=0o644))
+
+        http_cert_content = crypto.dump_certificate(type=crypto.FILETYPE_PEM, 
cert=http_cert)
+        
self.files.append(File("/usr/share/elasticsearch/config/certs/elastic_http.crt",
 http_cert_content, permissions=0o644))
+
+        http_key_content = crypto.dump_privatekey(type=crypto.FILETYPE_PEM, 
pkey=http_key)
+        
self.files.append(File("/usr/share/elasticsearch/config/certs/elastic_http.key",
 http_key_content, permissions=0o644))
+
+        transport_cert_content = 
crypto.dump_certificate(type=crypto.FILETYPE_PEM, cert=transport_cert)
+        
self.files.append(File("/usr/share/elasticsearch/config/certs/elastic_transport.crt",
 transport_cert_content, permissions=0o644))
+
+        transport_key_content = 
crypto.dump_privatekey(type=crypto.FILETYPE_PEM, pkey=transport_key)
+        
self.files.append(File("/usr/share/elasticsearch/config/certs/elastic_transport.key",
 transport_key_content, permissions=0o644))
+
+        features_dir = Path(__file__).resolve().parent.parent
+        
self.host_files.append(HostFile('/usr/share/elasticsearch/config/elasticsearch.yml',
 os.path.join(features_dir, "resources", "elasticsearch.yml")))
+
+        self.environment.append("ELASTIC_PASSWORD=password")
+
+    def deploy(self):
+        return super().deploy('"current.health":"GREEN"')
+
+    def elastic_generate_apikey(self):
+        api_url = "https://localhost:9200/_security/api_key";
+        api_user = "elastic:password"
+        api_headers = "Content-Type:application/json"
+        api_data = (
+            '{"name":"my-api-key",'
+            '"expiration":"1d",'
+            '"role_descriptors":{"role-a": {'
+            '"cluster": ["all"],'
+            '"index": [{"names": ["my_index"],"privileges": ["all"]}]'

Review Comment:
   Updated in 
https://github.com/apache/nifi-minifi-cpp/pull/2067/commits/b1ee2b97fff5dbc0587bab0523fc584b1060ddc6



##########
extensions/elasticsearch/tests/features/steps/steps.py:
##########
@@ -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.
+from behave import step, given, then
+
+from minifi_test_framework.steps import checking_steps        # noqa: F401
+from minifi_test_framework.steps import configuration_steps   # noqa: F401
+from minifi_test_framework.steps import core_steps            # noqa: F401
+from minifi_test_framework.steps import flow_building_steps   # noqa: F401
+from minifi_test_framework.core.minifi_test_context import MinifiTestContext
+from minifi_test_framework.minifi.controller_service import ControllerService
+from minifi_test_framework.core.helpers import log_due_to_failure
+from elasticsearch_container import ElasticsearchContainer
+from opensearch_container import OpensearchContainer
+
+
+@step('an Elasticsearch server is set up and running')
+@step('an Elasticsearch server is set up and a single document is present with 
"preloaded_id" in "my_index"')
+@step('an Elasticsearch server is set up and a single document is present with 
"preloaded_id" in "my_index" with "value1" in "field1"')
+def step_impl(context: MinifiTestContext):
+    context.containers["elasticsearch"] = ElasticsearchContainer(context)
+    assert context.containers["elasticsearch"].deploy()
+    assert 
context.containers["elasticsearch"].create_doc_elasticsearch("my_index", 
"preloaded_id") or context.containers["elasticsearch"].log_app_output()
+
+
+@given(u'an ElasticsearchCredentialsControllerService is set up with Basic 
Authentication')

Review Comment:
   Updated in 
https://github.com/apache/nifi-minifi-cpp/pull/2067/commits/b1ee2b97fff5dbc0587bab0523fc584b1060ddc6



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