diff --git a/src/test_workflow/integ_test/service_opensearch.py b/src/test_workflow/integ_test/service_opensearch.py index 0f9cef9413..86e7d4b7b7 100644 --- a/src/test_workflow/integ_test/service_opensearch.py +++ b/src/test_workflow/integ_test/service_opensearch.py @@ -16,6 +16,7 @@ from test_workflow.integ_test.distribution import Distribution from test_workflow.integ_test.distributions import Distributions from test_workflow.integ_test.service import Service +from test_workflow.integ_test.utils import get_password class ServiceOpenSearch(Service): @@ -40,7 +41,6 @@ def __init__( self.dist = Distributions.get_distribution("opensearch", distribution, version, work_dir) self.dependency_installer = dependency_installer self.install_dir = self.dist.install_dir - self.password = 'myStrongPassword123!' if float('.'.join(self.version.split('.')[:2])) >= 2.12 else 'admin' def start(self) -> None: self.dist.install(self.download()) @@ -66,7 +66,7 @@ def url(self, path: str = "") -> str: def get_service_response(self) -> Response: url = self.url("/_cluster/health") logging.info(f"Pinging {url}") - return requests.get(url, verify=False, auth=("admin", self.password)) + return requests.get(url, verify=False, auth=("admin", get_password(self.version))) def __add_plugin_specific_config(self, additional_config: dict) -> None: with open(self.opensearch_yml_path, "a") as yamlfile: diff --git a/src/test_workflow/integ_test/service_opensearch_dashboards.py b/src/test_workflow/integ_test/service_opensearch_dashboards.py index 0180b0ae54..4acf116ee9 100644 --- a/src/test_workflow/integ_test/service_opensearch_dashboards.py +++ b/src/test_workflow/integ_test/service_opensearch_dashboards.py @@ -18,6 +18,7 @@ from test_workflow.integ_test.distribution import Distribution from test_workflow.integ_test.distributions import Distributions from test_workflow.integ_test.service import Service +from test_workflow.integ_test.utils import get_password class ServiceOpenSearchDashboards(Service): @@ -86,7 +87,7 @@ def url(self, path: str = "") -> str: def get_service_response(self) -> Response: url = self.url("/api/status") logging.info(f"Pinging {url}") - return requests.get(url, verify=False, auth=("admin", "admin") if self.security_enabled else None) + return requests.get(url, verify=False, auth=("admin", get_password(self.version)) if self.security_enabled else None) def __add_plugin_specific_config(self, additional_config: dict) -> None: with open(self.opensearch_dashboards_yml_path, "a") as yamlfile: diff --git a/src/test_workflow/integ_test/utils.py b/src/test_workflow/integ_test/utils.py new file mode 100644 index 0000000000..737e0abb51 --- /dev/null +++ b/src/test_workflow/integ_test/utils.py @@ -0,0 +1,16 @@ +# Copyright OpenSearch Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +import semver + + +def get_password(version: str) -> str: + # Starting in 2.12.0, demo configuration setup script requires a strong password + if semver.compare(version, '2.12.0') != -1: + return "myStrongPassword123!" + else: + return "admin" diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_utils.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_utils.py new file mode 100644 index 0000000000..907e7306b3 --- /dev/null +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_utils.py @@ -0,0 +1,16 @@ +# Copyright OpenSearch Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +import unittest + +from test_workflow.integ_test.utils import get_password + + +class TestUtils(unittest.TestCase): + def test_strong_password(self) -> None: + self.assertEqual("admin", get_password("2.11.1")) + self.assertEqual("myStrongPassword123!", get_password("3.0.0"))