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/03/03 10:49:13 UTC

[GitHub] [ignite] anton-vinogradov commented on a change in pull request #8686: IGNITE-14023 Password based authentication support in ducktape tests

anton-vinogradov commented on a change in pull request #8686:
URL: https://github.com/apache/ignite/pull/8686#discussion_r586198421



##########
File path: modules/ducktests/tests/checks/utils/check_get_credentials_from_globals.py
##########
@@ -0,0 +1,59 @@
+# 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.
+
+"""
+Check that get_credentials_from_globals correctly parse Credentials from globals
+"""
+
+import pytest
+from ignitetest.services.utils.auth import get_credentials_from_globals, DEFAULT_AUTH_USERNAME, DEFAULT_AUTH_PASSWORD
+
+
+class TestParams:
+    """
+    Constant variables for test
+    """
+
+    test_globals = {
+        "use_auth": "True",
+        "client": {
+            "credentials": ["client", "qwe123"]}}
+    test_globals_default = {
+        "use_auth": "True"}
+    test_globals_no_auth = {}
+
+    expected_username = 'client'
+    expected_password = 'qwe123'
+    expected_username_default = DEFAULT_AUTH_USERNAME
+    expected_password_default = DEFAULT_AUTH_PASSWORD

Review comment:
       1) Explicitly duplicated password.
   2) Variables with single usage.
   Should be inlined.

##########
File path: modules/ducktests/tests/ignitetest/services/utils/auth/__init__.py
##########
@@ -0,0 +1,40 @@
+# 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.
+
+"""
+This module contains authentication classes and utilities.
+"""
+
+DEFAULT_AUTH_PASSWORD = "ignite"
+DEFAULT_AUTH_USERNAME = "ignite"
+
+
+def get_credentials_from_globals(_globals: dict, user: str):
+    """
+    Parse globals with structure like that.
+    {
+        "use_auth": True,
+        "admin": {
+            "credentials": ["username", "qwerty_123"]
+        }
+    }
+    """
+    username, password = None, None
+    if _globals.get('use_auth'):
+        if user in _globals and 'credentials' in _globals[user]:
+            username, password = _globals[user]['credentials']

Review comment:
       `credentials` duplicated

##########
File path: modules/ducktests/tests/ignitetest/services/utils/auth/__init__.py
##########
@@ -0,0 +1,40 @@
+# 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.
+
+"""
+This module contains authentication classes and utilities.
+"""
+
+DEFAULT_AUTH_PASSWORD = "ignite"
+DEFAULT_AUTH_USERNAME = "ignite"
+
+
+def get_credentials_from_globals(_globals: dict, user: str):
+    """
+    Parse globals with structure like that.
+    {
+        "use_auth": True,
+        "admin": {
+            "credentials": ["username", "qwerty_123"]
+        }
+    }
+    """
+    username, password = None, None
+    if _globals.get('use_auth'):
+        if user in _globals and 'credentials' in _globals[user]:
+            username, password = _globals[user]['credentials']
+        else:
+            username, password = DEFAULT_AUTH_USERNAME, DEFAULT_AUTH_PASSWORD

Review comment:
       This looks extremely weird when we ask credentials for some user and got another user and its password instead.
   The default user's password should be returned when (and when) password for default is user requested. 
   
   User not found exception, or something like this should be generated if the user was not found at the config.
   
   This method should never return the username.

##########
File path: modules/ducktests/tests/checks/utils/check_get_credentials_from_globals.py
##########
@@ -0,0 +1,59 @@
+# 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.
+
+"""
+Check that get_credentials_from_globals correctly parse Credentials from globals
+"""
+
+import pytest
+from ignitetest.services.utils.auth import get_credentials_from_globals, DEFAULT_AUTH_USERNAME, DEFAULT_AUTH_PASSWORD
+
+
+class TestParams:
+    """
+    Constant variables for test
+    """
+
+    test_globals = {
+        "use_auth": "True",
+        "client": {
+            "credentials": ["client", "qwe123"]}}

Review comment:
       As for me, this looks extremely odd to define username at credentials when we already have mapping based on usernames.
   BTW, should we have `auth` section, similarly to `ssl` here instead of credentials?
   For example, two-factor authentication may require sections like token-provider or cell, which are not `credentials`.

##########
File path: modules/ducktests/tests/ignitetest/services/utils/ignite_aware.py
##########
@@ -416,20 +416,17 @@ def __update_node_log_file(self, node):
             self.logger.debug(f"rotating {node.log_file} to {rotated_log} on {node.name}")
             node.account.ssh(f"mv {node.log_file} {rotated_log}")
 
-    def _update_ssl_config_with_globals(self, dict_name: str, default_jks: str):
+    def _update_ssl_config_with_globals(self, dict_name: str):
         """
         Update ssl configuration.
         """
-        _dict = self.globals.get(dict_name)
-
-        if _dict is not None:
-            ssl_context_factory = SslContextFactory(self.install_root, **_dict)
-        else:
-            ssl_context_factory = SslContextFactory(self.install_root, default_jks)
-
-        self.config = self.config._replace(ssl_context_factory=ssl_context_factory)
-        self.config = self.config._replace(connector_configuration=ConnectorConfiguration(
-            ssl_enabled=True, ssl_context_factory=ssl_context_factory))
+        ssl_params = None
+        if self.config.ssl_params is None:
+            ssl_params = get_ssl_params_from_globals(self.globals, dict_name)
+        if ssl_params:
+            self.config = self.config._replace(ssl_params=ssl_params)
+            self.config = self.config._replace(connector_configuration=ConnectorConfiguration(
+                ssl_enabled=True, ssl_params=ssl_params))

Review comment:
       Why we set `ssl-params` to two places?

##########
File path: modules/ducktests/tests/ignitetest/services/ignite.py
##########
@@ -63,8 +62,7 @@ def pids(self, node):
             return []
 
     def update_config_with_globals(self):
-        if self.globals.get("use_ssl", False):
-            self._update_ssl_config_with_globals("server", DEFAULT_SERVER_KEYSTORE)
+        self._update_ssl_config_with_globals("server")

Review comment:
       IgniteService may also be client, 
   as well as IgniteApplicationService may be a server.

##########
File path: modules/ducktests/tests/checks/utils/check_get_credentials_from_globals.py
##########
@@ -0,0 +1,59 @@
+# 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.
+
+"""
+Check that get_credentials_from_globals correctly parse Credentials from globals
+"""
+
+import pytest
+from ignitetest.services.utils.auth import get_credentials_from_globals, DEFAULT_AUTH_USERNAME, DEFAULT_AUTH_PASSWORD
+
+
+class TestParams:
+    """
+    Constant variables for test
+    """
+
+    test_globals = {
+        "use_auth": "True",
+        "client": {
+            "credentials": ["client", "qwe123"]}}
+    test_globals_default = {
+        "use_auth": "True"}
+    test_globals_no_auth = {}
+
+    expected_username = 'client'
+    expected_password = 'qwe123'
+    expected_username_default = DEFAULT_AUTH_USERNAME
+    expected_password_default = DEFAULT_AUTH_PASSWORD
+
+
+class CheckCaseJks:
+    """
+    Check that get_credentials_from_globals correctly parse Credentials from globals
+    """
+
+    @staticmethod
+    @pytest.mark.parametrize('test_globals, expected_username, expected_password',
+                             [(TestParams.test_globals, TestParams.expected_username, TestParams.expected_password),
+                              (TestParams.test_globals_default, TestParams.expected_username_default,
+                               TestParams.expected_password_default),
+                              (TestParams.test_globals_no_auth, None, None)])
+    def check_parse(test_globals, expected_username, expected_password):
+        """
+        Check function for pytest
+        """
+
+        assert (expected_username, expected_password) == get_credentials_from_globals(test_globals, 'client')

Review comment:
       `expected_username` variable explicitly duplicated by 'client' string.

##########
File path: modules/ducktests/tests/ignitetest/services/utils/ssl/ssl_params.py
##########
@@ -0,0 +1,87 @@
+# 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
+
+"""
+This module contains classes and utilities for Ignite SslContextFactory.
+
+This file contains three user presets:
+1. server for Ignite(clientMode=False)
+2. client for Ignte(clientMode=True) node and ThinClient
+3. admin for GridClient and console utils (control.sh)
+
+Keystores for this presets are generated automaticaly on creating envoriment
+If you like to specify different certificate for preset you can pass them throw globals
+If you specyfy ssl_params in test, you override globals
+"""
+import os
+
+
+DEFAULT_KEYSTORE = 'server.jks'
+DEFAULT_CLIENT_KEYSTORE = 'client.jks'
+DEFAULT_ADMIN_KEYSTORE = 'admin.jks'
+DEFAULT_PASSWORD = "123456"
+DEFAULT_TRUSTSTORE = "truststore.jks"
+DEFAULT_ROOT = "/opt/"
+
+default_keystore = {
+    'server': DEFAULT_KEYSTORE,
+    'client': DEFAULT_CLIENT_KEYSTORE,
+    'admin': DEFAULT_ADMIN_KEYSTORE
+}

Review comment:
       We agreed that comments will be provided here, but nothing changed.

##########
File path: modules/ducktests/tests/ignitetest/services/utils/ssl/ssl_params.py
##########
@@ -0,0 +1,87 @@
+# 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
+
+"""
+This module contains classes and utilities for Ignite SslContextFactory.
+
+This file contains three user presets:
+1. server for Ignite(clientMode=False)
+2. client for Ignte(clientMode=True) node and ThinClient
+3. admin for GridClient and console utils (control.sh)
+
+Keystores for this presets are generated automaticaly on creating envoriment
+If you like to specify different certificate for preset you can pass them throw globals
+If you specyfy ssl_params in test, you override globals
+"""
+import os
+
+
+DEFAULT_KEYSTORE = 'server.jks'
+DEFAULT_CLIENT_KEYSTORE = 'client.jks'
+DEFAULT_ADMIN_KEYSTORE = 'admin.jks'
+DEFAULT_PASSWORD = "123456"

Review comment:
       Should be used only for default keystores.

##########
File path: modules/ducktests/tests/ignitetest/services/utils/ssl/ssl_params.py
##########
@@ -0,0 +1,87 @@
+# 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
+
+"""
+This module contains classes and utilities for Ignite SslContextFactory.
+
+This file contains three user presets:
+1. server for Ignite(clientMode=False)
+2. client for Ignte(clientMode=True) node and ThinClient
+3. admin for GridClient and console utils (control.sh)
+
+Keystores for this presets are generated automaticaly on creating envoriment
+If you like to specify different certificate for preset you can pass them throw globals
+If you specyfy ssl_params in test, you override globals
+"""
+import os
+
+
+DEFAULT_KEYSTORE = 'server.jks'
+DEFAULT_CLIENT_KEYSTORE = 'client.jks'
+DEFAULT_ADMIN_KEYSTORE = 'admin.jks'
+DEFAULT_PASSWORD = "123456"
+DEFAULT_TRUSTSTORE = "truststore.jks"
+DEFAULT_ROOT = "/opt/"
+
+default_keystore = {
+    'server': DEFAULT_KEYSTORE,
+    'client': DEFAULT_CLIENT_KEYSTORE,
+    'admin': DEFAULT_ADMIN_KEYSTORE
+}
+
+
+class SslParams:
+    """
+    Params for Ignite SslContextFactory.
+    """
+
+    # pylint: disable=R0913
+    def __init__(self, root_dir: str = DEFAULT_ROOT,
+                 key_store_jks: str = DEFAULT_KEYSTORE, key_store_password: str = DEFAULT_PASSWORD,
+                 trust_store_jks: str = DEFAULT_TRUSTSTORE, trust_store_password: str = DEFAULT_PASSWORD,
+                 key_store_path: str = None, trust_store_path: str = None):
+        certificate_dir = os.path.join(root_dir, "ignite-dev", "modules", "ducktests", "tests", "certs")
+
+        self.key_store_path = key_store_path if key_store_path is not None \
+            else os.path.join(certificate_dir, key_store_jks)
+        self.key_store_password = key_store_password
+        self.trust_store_path = trust_store_path if trust_store_path is not None \
+            else os.path.join(certificate_dir, trust_store_jks)
+        self.trust_store_password = trust_store_password
+
+
+def get_ssl_params_from_globals(_globals: dict, user: str):
+    """
+    Parse globals with structure like that.
+    {
+        "use_ssl": True,
+        "admin": {
+            "credentials": ["username", "qwerty_123"],
+            "ssl": {
+                "key_store_jks": ....
+            }
+        }
+
+    }
+    """
+    root_dir = _globals.get("install_root", DEFAULT_ROOT)
+    ssl_param = None
+    if _globals.get('use_ssl'):
+        if user in _globals and 'ssl' in _globals[user]:
+            ssl_param = _globals[user]['ssl']
+        else:
+            ssl_param = {'key_store_jks': default_keystore[user]}

Review comment:
       Case, when the user was not found at default Keystore, should be also handled.

##########
File path: modules/ducktests/tests/ignitetest/services/utils/ssl/ssl_params.py
##########
@@ -0,0 +1,87 @@
+# 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
+
+"""
+This module contains classes and utilities for Ignite SslContextFactory.
+
+This file contains three user presets:
+1. server for Ignite(clientMode=False)
+2. client for Ignte(clientMode=True) node and ThinClient
+3. admin for GridClient and console utils (control.sh)
+
+Keystores for this presets are generated automaticaly on creating envoriment
+If you like to specify different certificate for preset you can pass them throw globals
+If you specyfy ssl_params in test, you override globals
+"""
+import os
+
+
+DEFAULT_KEYSTORE = 'server.jks'
+DEFAULT_CLIENT_KEYSTORE = 'client.jks'
+DEFAULT_ADMIN_KEYSTORE = 'admin.jks'
+DEFAULT_PASSWORD = "123456"
+DEFAULT_TRUSTSTORE = "truststore.jks"
+DEFAULT_ROOT = "/opt/"
+
+default_keystore = {
+    'server': DEFAULT_KEYSTORE,
+    'client': DEFAULT_CLIENT_KEYSTORE,
+    'admin': DEFAULT_ADMIN_KEYSTORE
+}
+
+
+class SslParams:
+    """
+    Params for Ignite SslContextFactory.
+    """
+
+    # pylint: disable=R0913
+    def __init__(self, root_dir: str = DEFAULT_ROOT,
+                 key_store_jks: str = DEFAULT_KEYSTORE, key_store_password: str = DEFAULT_PASSWORD,
+                 trust_store_jks: str = DEFAULT_TRUSTSTORE, trust_store_password: str = DEFAULT_PASSWORD,
+                 key_store_path: str = None, trust_store_path: str = None):
+        certificate_dir = os.path.join(root_dir, "ignite-dev", "modules", "ducktests", "tests", "certs")
+
+        self.key_store_path = key_store_path if key_store_path is not None \
+            else os.path.join(certificate_dir, key_store_jks)
+        self.key_store_password = key_store_password
+        self.trust_store_path = trust_store_path if trust_store_path is not None \
+            else os.path.join(certificate_dir, trust_store_jks)
+        self.trust_store_password = trust_store_password
+
+
+def get_ssl_params_from_globals(_globals: dict, user: str):
+    """
+    Parse globals with structure like that.
+    {
+        "use_ssl": True,
+        "admin": {
+            "credentials": ["username", "qwerty_123"],
+            "ssl": {
+                "key_store_jks": ....
+            }
+        }
+
+    }
+    """
+    root_dir = _globals.get("install_root", DEFAULT_ROOT)
+    ssl_param = None
+    if _globals.get('use_ssl'):
+        if user in _globals and 'ssl' in _globals[user]:
+            ssl_param = _globals[user]['ssl']

Review comment:
       `ssl` duplicated

##########
File path: modules/ducktests/tests/checks/utils/check_get_ssl_params_from_globals.py
##########
@@ -0,0 +1,100 @@
+# 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.
+
+"""
+Check that SslParams correctly parse SSL params from globals
+"""
+
+import pytest
+from ignitetest.services.utils.ssl.ssl_params import get_ssl_params_from_globals, SslParams, DEFAULT_TRUSTSTORE, \
+    DEFAULT_CLIENT_KEYSTORE, DEFAULT_PASSWORD
+
+INSTALL_ROOT = '/opt'
+CERTIFICATE_DIR = '/opt/ignite-dev/modules/ducktests/tests/certs/'
+
+
+def _compare(expected, actual):
+    """
+    Compare SslParams object with dictionary
+    """
+
+    if expected is None and actual is None:
+        return True
+    if isinstance(expected, dict) and isinstance(actual, SslParams):
+        return expected == actual.__dict__
+    return False
+
+
+class TestParams:
+    """
+    Globals for tests
+    """
+
+    test_globals_jks = {
+        "install_root": INSTALL_ROOT,
+        "use_ssl": "True",
+        "client": {
+            "ssl": {
+                "key_store_jks": "client1.jks",
+                "key_store_password": "qwe123",
+                "trust_store_jks": "truststore.jks",
+                "trust_store_password": "qwe123"}}}
+    test_globals_path = {
+        "install_root": INSTALL_ROOT,
+        "use_ssl": "True",
+        "client": {
+            "ssl": {
+                "key_store_path": "/opt/certs/client1.jks",
+                "key_store_password": "qwe123",
+                "trust_store_path": "/opt/certs/truststore.jks",
+                "trust_store_password": "qwe123"}}}
+    test_globals_default = {
+        "install_root": INSTALL_ROOT,
+        "use_ssl": "True"}
+    test_globals_no_ssl = {
+        "install_root": INSTALL_ROOT}
+
+    expected_ssl_params_jks = {'key_store_path': CERTIFICATE_DIR + 'client1.jks',
+                               'key_store_password': 'qwe123',
+                               'trust_store_path': CERTIFICATE_DIR + 'truststore.jks',
+                               'trust_store_password': 'qwe123'}
+    expected_ssl_params_path = {'key_store_path': '/opt/certs/client1.jks',
+                                'key_store_password': 'qwe123',
+                                'trust_store_path': '/opt/certs/truststore.jks',
+                                'trust_store_password': 'qwe123'}
+    expected_ssl_params_default = {'key_store_path': CERTIFICATE_DIR + DEFAULT_CLIENT_KEYSTORE,
+                                   'key_store_password': DEFAULT_PASSWORD,
+                                   'trust_store_path': CERTIFICATE_DIR + DEFAULT_TRUSTSTORE,
+                                   'trust_store_password': DEFAULT_PASSWORD}

Review comment:
       1) Explicitly duplicated password.
   2) Variables with single usage.
   Should be inlined.

##########
File path: modules/ducktests/tests/ignitetest/services/utils/ignite_configuration/__init__.py
##########
@@ -43,8 +43,10 @@ class IgniteConfiguration(NamedTuple):
     data_storage: DataStorageConfiguration = None
     caches: list = []
     local_host: str = None
-    ssl_context_factory: SslContextFactory = None
+    ssl_params: SslParams = None
     connector_configuration: ConnectorConfiguration = None
+    auth: bool = False

Review comment:
       auth_enabled?

##########
File path: modules/ducktests/tests/ignitetest/services/utils/control_utility.py
##########
@@ -37,33 +37,19 @@ class ControlUtility:
     BASE_COMMAND = "control.sh"
 
     # pylint: disable=R0913
-    def __init__(self, cluster,
-                 key_store_jks: str = None, key_store_password: str = DEFAULT_PASSWORD,
-                 trust_store_jks: str = DEFAULT_TRUSTSTORE, trust_store_password: str = DEFAULT_PASSWORD):
+    def __init__(self, cluster, ssl_params=None, username=None, password=DEFAULT_AUTH_PASSWORD):
         self._cluster = cluster
         self.logger = cluster.context.logger
 
-        if cluster.context.globals.get("use_ssl", False):
-            admin_dict = cluster.globals.get("admin", dict())
-
-            self.key_store_path = admin_dict.get("key_store_path",
-                                                 self.jks_path(admin_dict.get('key_store_jks', DEFAULT_ADMIN_KEYSTORE)))
-            self.key_store_password = admin_dict.get('key_store_password', DEFAULT_PASSWORD)
-            self.trust_store_path = admin_dict.get("trust_store_path",
-                                                   self.jks_path(admin_dict.get('trust_store_jks', DEFAULT_TRUSTSTORE)))
-            self.trust_store_password = admin_dict.get('trust_store_password', DEFAULT_PASSWORD)
-
-        elif key_store_jks is not None:
-            self.key_store_path = self.jks_path(key_store_jks)
-            self.key_store_password = key_store_password
-            self.trust_store_path = self.jks_path(trust_store_jks)
-            self.trust_store_password = trust_store_password
+        if not ssl_params:
+            self.ssl_params = get_ssl_params_from_globals(cluster.context.globals, 'admin')
+        else:
+            self.ssl_params = ssl_params
 
-    def jks_path(self, jks_name: str):
-        """
-        :return Path to jks file.
-        """
-        return os.path.join(self._cluster.certificate_dir, jks_name)
+        if not username:
+            self.username, self.password = get_credentials_from_globals(cluster.context.globals, 'admin')

Review comment:
       Why credentials for `admin` requested? Do we have such user by default?

##########
File path: modules/ducktests/tests/ignitetest/services/utils/auth/__init__.py
##########
@@ -0,0 +1,40 @@
+# 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.
+
+"""
+This module contains authentication classes and utilities.
+"""
+
+DEFAULT_AUTH_PASSWORD = "ignite"
+DEFAULT_AUTH_USERNAME = "ignite"
+
+
+def get_credentials_from_globals(_globals: dict, user: str):
+    """
+    Parse globals with structure like that.
+    {
+        "use_auth": True,
+        "admin": {
+            "credentials": ["username", "qwerty_123"]
+        }
+    }
+    """
+    username, password = None, None
+    if _globals.get('use_auth'):

Review comment:
       Should be constant to be used from other files.

##########
File path: modules/ducktests/tests/ignitetest/services/utils/ssl/ssl_params.py
##########
@@ -0,0 +1,87 @@
+# 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
+
+"""
+This module contains classes and utilities for Ignite SslContextFactory.
+
+This file contains three user presets:
+1. server for Ignite(clientMode=False)
+2. client for Ignte(clientMode=True) node and ThinClient
+3. admin for GridClient and console utils (control.sh)
+
+Keystores for this presets are generated automaticaly on creating envoriment
+If you like to specify different certificate for preset you can pass them throw globals
+If you specyfy ssl_params in test, you override globals
+"""
+import os
+
+
+DEFAULT_KEYSTORE = 'server.jks'
+DEFAULT_CLIENT_KEYSTORE = 'client.jks'
+DEFAULT_ADMIN_KEYSTORE = 'admin.jks'
+DEFAULT_PASSWORD = "123456"
+DEFAULT_TRUSTSTORE = "truststore.jks"
+DEFAULT_ROOT = "/opt/"
+
+default_keystore = {

Review comment:
       Default names must be constants to be used from other files without duplication.

##########
File path: modules/ducktests/tests/ignitetest/services/utils/auth/__init__.py
##########
@@ -0,0 +1,40 @@
+# 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.
+
+"""
+This module contains authentication classes and utilities.
+"""
+
+DEFAULT_AUTH_PASSWORD = "ignite"
+DEFAULT_AUTH_USERNAME = "ignite"
+
+
+def get_credentials_from_globals(_globals: dict, user: str):
+    """
+    Parse globals with structure like that.
+    {
+        "use_auth": True,
+        "admin": {
+            "credentials": ["username", "qwerty_123"]
+        }
+    }
+    """
+    username, password = None, None
+    if _globals.get('use_auth'):
+        if user in _globals and 'credentials' in _globals[user]:
+            username, password = _globals[user]['credentials']
+        else:
+            username, password = DEFAULT_AUTH_USERNAME, DEFAULT_AUTH_PASSWORD
+    return username, password

Review comment:
       Should we got an exception instead?

##########
File path: modules/ducktests/tests/ignitetest/services/utils/auth/__init__.py
##########
@@ -0,0 +1,40 @@
+# 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.
+
+"""
+This module contains authentication classes and utilities.
+"""
+
+DEFAULT_AUTH_PASSWORD = "ignite"
+DEFAULT_AUTH_USERNAME = "ignite"
+
+
+def get_credentials_from_globals(_globals: dict, user: str):

Review comment:
       Should be refactored to *_auth_data() or something like this.

##########
File path: modules/ducktests/tests/ignitetest/services/utils/ssl/ssl_params.py
##########
@@ -0,0 +1,87 @@
+# 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
+
+"""
+This module contains classes and utilities for Ignite SslContextFactory.
+
+This file contains three user presets:
+1. server for Ignite(clientMode=False)
+2. client for Ignte(clientMode=True) node and ThinClient
+3. admin for GridClient and console utils (control.sh)
+
+Keystores for this presets are generated automaticaly on creating envoriment
+If you like to specify different certificate for preset you can pass them throw globals
+If you specyfy ssl_params in test, you override globals
+"""
+import os
+
+
+DEFAULT_KEYSTORE = 'server.jks'
+DEFAULT_CLIENT_KEYSTORE = 'client.jks'
+DEFAULT_ADMIN_KEYSTORE = 'admin.jks'

Review comment:
       Should this be generated from names?
   See no rear reason to have this as consts.

##########
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:
       The question is about this change!

##########
File path: modules/ducktests/tests/ignitetest/tests/auth_test.py
##########
@@ -0,0 +1,92 @@
+# 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.
+
+"""
+This module contains password based authentication tests
+"""
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.utils.control_utility import ControlUtility, ControlUtilityError
+from ignitetest.services.utils.ignite_configuration import IgniteConfiguration, DataStorageConfiguration
+from ignitetest.services.utils.ignite_configuration.data_storage import DataRegionConfiguration
+from ignitetest.utils import ignite_versions, cluster, ignore_if
+from ignitetest.utils.ignite_test import IgniteTest
+from ignitetest.utils.version import DEV_BRANCH, LATEST, IgniteVersion
+from ignitetest.services.utils.auth import DEFAULT_AUTH_PASSWORD, DEFAULT_AUTH_USERNAME
+
+
+# pylint: disable=W0223
+class AuthenticationTests(IgniteTest):
+    """
+    Tests Ignite Authentication
+    """
+    NUM_NODES = 3
+
+    @cluster(num_nodes=NUM_NODES)
+    @ignite_versions(str(DEV_BRANCH), str(LATEST))
+    def test_activate_correct_password(self, ignite_version):
+        """
+        Test activate cluster.
+        Authentication enabled
+        Positive case
+        """
+
+        config = IgniteConfiguration(
+            cluster_state="INACTIVE",
+            auth=True,
+            version=IgniteVersion(ignite_version),
+            data_storage=DataStorageConfiguration(
+                default=DataRegionConfiguration(name='persistent', persistent=True),
+            )
+        )
+
+        servers = IgniteService(self.test_context, config=config, num_nodes=self.NUM_NODES)
+
+        servers.start()
+
+        control_utility = ControlUtility(cluster=servers,
+                                         username=DEFAULT_AUTH_USERNAME, password=DEFAULT_AUTH_PASSWORD)
+        control_utility.activate()
+
+    @cluster(num_nodes=NUM_NODES)
+    @ignore_if(lambda version, globals_dict: globals_dict.get("use_auth", False))  # Globals overrides test params
+    @ignite_versions(str(DEV_BRANCH), str(LATEST))
+    def test_activate_wrong_password(self, ignite_version):

Review comment:
       This method code duplicates `test_activate_correct_password` for 80%.
   We should avoid such duplications.

##########
File path: modules/ducktests/tests/ignitetest/services/utils/ssl/ssl_params.py
##########
@@ -0,0 +1,87 @@
+# 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
+
+"""
+This module contains classes and utilities for Ignite SslContextFactory.
+
+This file contains three user presets:
+1. server for Ignite(clientMode=False)
+2. client for Ignte(clientMode=True) node and ThinClient
+3. admin for GridClient and console utils (control.sh)
+
+Keystores for this presets are generated automaticaly on creating envoriment
+If you like to specify different certificate for preset you can pass them throw globals
+If you specyfy ssl_params in test, you override globals
+"""
+import os
+
+
+DEFAULT_KEYSTORE = 'server.jks'
+DEFAULT_CLIENT_KEYSTORE = 'client.jks'
+DEFAULT_ADMIN_KEYSTORE = 'admin.jks'
+DEFAULT_PASSWORD = "123456"
+DEFAULT_TRUSTSTORE = "truststore.jks"
+DEFAULT_ROOT = "/opt/"
+
+default_keystore = {
+    'server': DEFAULT_KEYSTORE,
+    'client': DEFAULT_CLIENT_KEYSTORE,
+    'admin': DEFAULT_ADMIN_KEYSTORE
+}
+
+
+class SslParams:
+    """
+    Params for Ignite SslContextFactory.
+    """
+
+    # pylint: disable=R0913
+    def __init__(self, root_dir: str = DEFAULT_ROOT,
+                 key_store_jks: str = DEFAULT_KEYSTORE, key_store_password: str = DEFAULT_PASSWORD,
+                 trust_store_jks: str = DEFAULT_TRUSTSTORE, trust_store_password: str = DEFAULT_PASSWORD,
+                 key_store_path: str = None, trust_store_path: str = None):
+        certificate_dir = os.path.join(root_dir, "ignite-dev", "modules", "ducktests", "tests", "certs")
+
+        self.key_store_path = key_store_path if key_store_path is not None \
+            else os.path.join(certificate_dir, key_store_jks)
+        self.key_store_password = key_store_password
+        self.trust_store_path = trust_store_path if trust_store_path is not None \
+            else os.path.join(certificate_dir, trust_store_jks)
+        self.trust_store_password = trust_store_password
+
+
+def get_ssl_params_from_globals(_globals: dict, user: str):
+    """
+    Parse globals with structure like that.
+    {
+        "use_ssl": True,
+        "admin": {
+            "credentials": ["username", "qwerty_123"],
+            "ssl": {
+                "key_store_jks": ....
+            }
+        }
+
+    }
+    """
+    root_dir = _globals.get("install_root", DEFAULT_ROOT)
+    ssl_param = None
+    if _globals.get('use_ssl'):

Review comment:
       Should be constant to be used at other files.

##########
File path: modules/ducktests/tests/ignitetest/services/ignite_app.py
##########
@@ -109,5 +108,4 @@ def extract_results(self, name):
         return res
 
     def update_config_with_globals(self):
-        if self.globals.get("use_ssl", False):
-            self._update_ssl_config_with_globals("client", DEFAULT_CLIENT_KEYSTORE)
+        self._update_ssl_config_with_globals("client")

Review comment:
       Why "client"?

##########
File path: modules/ducktests/tests/ignitetest/tests/auth_test.py
##########
@@ -0,0 +1,92 @@
+# 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.
+
+"""
+This module contains password based authentication tests
+"""
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.utils.control_utility import ControlUtility, ControlUtilityError
+from ignitetest.services.utils.ignite_configuration import IgniteConfiguration, DataStorageConfiguration
+from ignitetest.services.utils.ignite_configuration.data_storage import DataRegionConfiguration
+from ignitetest.utils import ignite_versions, cluster, ignore_if
+from ignitetest.utils.ignite_test import IgniteTest
+from ignitetest.utils.version import DEV_BRANCH, LATEST, IgniteVersion
+from ignitetest.services.utils.auth import DEFAULT_AUTH_PASSWORD, DEFAULT_AUTH_USERNAME
+
+
+# pylint: disable=W0223
+class AuthenticationTests(IgniteTest):
+    """
+    Tests Ignite Authentication
+    """
+    NUM_NODES = 3
+
+    @cluster(num_nodes=NUM_NODES)
+    @ignite_versions(str(DEV_BRANCH), str(LATEST))
+    def test_activate_correct_password(self, ignite_version):
+        """
+        Test activate cluster.
+        Authentication enabled
+        Positive case
+        """
+
+        config = IgniteConfiguration(
+            cluster_state="INACTIVE",
+            auth=True,
+            version=IgniteVersion(ignite_version),
+            data_storage=DataStorageConfiguration(
+                default=DataRegionConfiguration(name='persistent', persistent=True),
+            )
+        )
+
+        servers = IgniteService(self.test_context, config=config, num_nodes=self.NUM_NODES)
+
+        servers.start()
+
+        control_utility = ControlUtility(cluster=servers,
+                                         username=DEFAULT_AUTH_USERNAME, password=DEFAULT_AUTH_PASSWORD)
+        control_utility.activate()
+
+    @cluster(num_nodes=NUM_NODES)
+    @ignore_if(lambda version, globals_dict: globals_dict.get("use_auth", False))  # Globals overrides test params

Review comment:
       It's a good case to ignore some versions where some feature not supported, but this seems to be illegal usage.
   Do you expect that someone will explicitly set "`use_auth`: False" at globals, while this should be false by default?
   Sound odd to expect such config.




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