You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/02/08 12:46:43 UTC

[GitHub] [ignite] timoninmaxim commented on a change in pull request #8686: Password based authentication support in ducktape tests

timoninmaxim commented on a change in pull request #8686:
URL: https://github.com/apache/ignite/pull/8686#discussion_r572009018



##########
File path: modules/ducktests/tests/ignitetest/services/utils/control_utility.py
##########
@@ -313,6 +303,39 @@ def __parse_output(raw_output):
     def __alives(self):
         return [node for node in self._cluster.nodes if self._cluster.alive(node)]
 
+    def _get_creds_from_globals(self, user, globals_dict, **kwargs):
+
+        creds = dict()
+
+        if globals_dict.get("use_ssl", False):
+            admin_dict = globals_dict.get(user, {})
+            creds = self._get_ssl_from_dict(admin_dict.get('ssl', {}))
+        elif kwargs.get('key_store_jks') is not None or kwargs.get('key_store_path') is not None:
+            creds = self._get_ssl_from_dict(kwargs)
+
+        if globals_dict.get("use_auth", False):
+            admin_dict = globals_dict.get(user, {})

Review comment:
       admin_dict -> user_dict?

##########
File path: modules/ducktests/tests/ignitetest/services/utils/control_utility.py
##########
@@ -313,6 +303,39 @@ def __parse_output(raw_output):
     def __alives(self):
         return [node for node in self._cluster.nodes if self._cluster.alive(node)]
 
+    def _get_creds_from_globals(self, user, globals_dict, **kwargs):
+
+        creds = dict()

Review comment:
       this line, `creds = dict()`, on 328 line: `creds = {}`. Let's make it the same

##########
File path: modules/ducktests/tests/ignitetest/services/utils/control_utility.py
##########
@@ -313,6 +303,39 @@ def __parse_output(raw_output):
     def __alives(self):
         return [node for node in self._cluster.nodes if self._cluster.alive(node)]
 
+    def _get_creds_from_globals(self, user, globals_dict, **kwargs):
+
+        creds = dict()
+
+        if globals_dict.get("use_ssl", False):
+            admin_dict = globals_dict.get(user, {})

Review comment:
       admin_dict -> user_dict?

##########
File path: modules/ducktests/tests/ignitetest/services/utils/control_utility.py
##########
@@ -313,6 +303,39 @@ def __parse_output(raw_output):
     def __alives(self):
         return [node for node in self._cluster.nodes if self._cluster.alive(node)]
 
+    def _get_creds_from_globals(self, user, globals_dict, **kwargs):
+
+        creds = dict()
+
+        if globals_dict.get("use_ssl", False):
+            admin_dict = globals_dict.get(user, {})
+            creds = self._get_ssl_from_dict(admin_dict.get('ssl', {}))
+        elif kwargs.get('key_store_jks') is not None or kwargs.get('key_store_path') is not None:
+            creds = self._get_ssl_from_dict(kwargs)
+
+        if globals_dict.get("use_auth", False):
+            admin_dict = globals_dict.get(user, {})
+            creds['login'] = admin_dict.get("login", DEFAULT_AUTH_LOGIN)
+            creds['password'] = admin_dict.get("password", DEFAULT_AUTH_PASSWORD)
+        elif kwargs.get('login') is not None:
+            creds['login'] = kwargs.get("login", DEFAULT_AUTH_LOGIN)
+            creds['password'] = kwargs.get("password", DEFAULT_AUTH_PASSWORD)
+
+        return creds
+
+    def _get_ssl_from_dict(self, ssl_dict):
+
+        creds = {}
+
+        creds['key_store_path'] = ssl_dict.get("key_store_path",

Review comment:
       WDYT if creds will be not a dict, but a class with well defined structure?

##########
File path: modules/ducktests/tests/checks/utils/check_controls_util_parameters.py
##########
@@ -0,0 +1,148 @@
+# 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.
+
+"""
+Checks Control Utility params pasrsing
+"""
+
+import pytest
+from ignitetest.services.utils.control_utility import ControlUtility
+
+
+class Cluster:
+    """
+    Need this to initialise ControlUtility
+    """
+    def __init__(self, globals_dict):
+        self.context = Context(globals_dict)
+        self.certificate_dir = ''
+
+
+class Context:
+    """
+    Need this to initialise ControlUtility
+    """
+    def __init__(self, globals_dict):
+        self.logger = ''
+        self.globals = globals_dict
+
+
+class CheckControlUtility:
+    """
+    Check that control_utulity.py correctly parse globals
+    """
+
+    test_admin_data_full = {"login": "admin1", "password": "qwe123",
+                            "ssl": {"key_store_jks": "admin1.jks", "key_store_password": "qwe123",
+                                    "trust_store_jks": "truststore.jks", "trust_store_password": "qwe123"}}
+
+    test_admin_data_ssl = {
+        "ssl": {"key_store_jks": "admin1.jks", "key_store_password": "qwe123", "trust_store_jks": "truststore.jks",
+                "trust_store_password": "qwe123"}}
+    test_admin_data_auth = {"login": "admin1", "password": "qwe123"}
+
+    globals_full = {
+        'use_ssl': True,
+        'use_auth': True,
+        'admin': test_admin_data_full
+    }
+
+    globals_auth = {
+        'use_ssl': True,
+        'use_auth': True,
+        'admin': test_admin_data_auth
+    }
+
+    globals_ssl = {
+        'use_ssl': True,
+        'use_auth': True,
+        'admin': test_admin_data_ssl
+    }
+
+    globals_no_ssl = {
+        'use_auth': True,
+        'admin': test_admin_data_full
+    }
+
+    globals_no_auth = {
+        'use_ssl': True,
+        'admin': test_admin_data_full
+    }
+
+    globals_no_ssl_no_auth = {
+        'admin': test_admin_data_full
+    }
+
+    globals_ssl_auth = {
+        'use_ssl': True,
+        'use_auth': True
+    }
+
+    globals_nil = {}
+
+    @staticmethod
+    @pytest.mark.parametrize("test_globals, test_kwargs, expected",
+                             [(globals_full, {}, {'key_store_path': 'admin1.jks', 'key_store_password': 'qwe123',

Review comment:
       I'd suggest you create a variable that contains expected structure the same way as you create variable for every globals case.

##########
File path: modules/ducktests/tests/ignitetest/services/utils/control_utility.py
##########
@@ -374,6 +397,7 @@ class ControlUtilityError(RemoteCommandError):
     """
     Error is raised when control utility failed.
     """
+

Review comment:
       Why do you make this change? Do we have a check for that?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org