From 53801d588d2ab786b1bb09d7eb155a7bb8251ed3 Mon Sep 17 00:00:00 2001 From: khamitovdr Date: Tue, 17 Dec 2024 17:20:51 +0300 Subject: [PATCH 1/3] Simplify SSL certificate error handling in tests --- .../db/core/test_connection.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/dl_connector_mysql/dl_connector_mysql_tests/db/core/test_connection.py b/lib/dl_connector_mysql/dl_connector_mysql_tests/db/core/test_connection.py index e86f7bb7b..506c81fcb 100644 --- a/lib/dl_connector_mysql/dl_connector_mysql_tests/db/core/test_connection.py +++ b/lib/dl_connector_mysql/dl_connector_mysql_tests/db/core/test_connection.py @@ -1,4 +1,3 @@ -import re from typing import Callable import pytest @@ -72,11 +71,11 @@ def check_data_source_templates( assert dsrc_tmpl.title @pytest.mark.parametrize( - "ssl_ca_filename, error_message", + "ssl_ca_filename", [ ( + # [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain "invalid-ca.pem", - r"\[SSL: CERTIFICATE_VERIFY_FAILED\] certificate verify failed: self-signed certificate in certificate chain", ), # TODO: add cases for # [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: IP address mismatch, certificate is not valid for ... @@ -88,7 +87,6 @@ def test_bad_ssl_ca( saved_connection: ConnectionMySQL, sync_conn_executor_factory: Callable[[], MySQLConnExecutor], ssl_ca_filename: str, - error_message: str, ) -> None: def sync_conn_executor_factory_for_conn(connection: ConnectionBase) -> MySQLConnExecutor: return sync_conn_executor_factory() @@ -104,7 +102,5 @@ def sync_conn_executor_factory_for_conn(connection: ConnectionBase) -> MySQLConn ssl_ca = response.text saved_connection.data.ssl_ca = ssl_ca - with pytest.raises(DatabaseOperationalError) as exc_info: + with pytest.raises(DatabaseOperationalError): saved_connection.test(conn_executor_factory=sync_conn_executor_factory_for_conn) - - assert re.search(error_message, exc_info.value.db_message) From d6cc67cc6346189439e6525b51473d719dbecbaf Mon Sep 17 00:00:00 2001 From: khamitovdr Date: Tue, 17 Dec 2024 17:53:58 +0300 Subject: [PATCH 2/3] fix test parameter definition --- .../dl_connector_mysql_tests/db/core/test_connection.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/dl_connector_mysql/dl_connector_mysql_tests/db/core/test_connection.py b/lib/dl_connector_mysql/dl_connector_mysql_tests/db/core/test_connection.py index 506c81fcb..6d0e7e4c4 100644 --- a/lib/dl_connector_mysql/dl_connector_mysql_tests/db/core/test_connection.py +++ b/lib/dl_connector_mysql/dl_connector_mysql_tests/db/core/test_connection.py @@ -73,10 +73,7 @@ def check_data_source_templates( @pytest.mark.parametrize( "ssl_ca_filename", [ - ( - # [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain - "invalid-ca.pem", - ), + "invalid-ca.pem", # [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain # TODO: add cases for # [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: IP address mismatch, certificate is not valid for ... # [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: invalid CA certificate From 38cfff8b599a565f3ccab1aa35c46b9ca372f79e Mon Sep 17 00:00:00 2001 From: khamitovdr Date: Tue, 17 Dec 2024 18:03:59 +0300 Subject: [PATCH 3/3] lint-fix --- .../dl_connector_mysql_tests/db/core/test_connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dl_connector_mysql/dl_connector_mysql_tests/db/core/test_connection.py b/lib/dl_connector_mysql/dl_connector_mysql_tests/db/core/test_connection.py index 6d0e7e4c4..fdce4e10b 100644 --- a/lib/dl_connector_mysql/dl_connector_mysql_tests/db/core/test_connection.py +++ b/lib/dl_connector_mysql/dl_connector_mysql_tests/db/core/test_connection.py @@ -73,7 +73,7 @@ def check_data_source_templates( @pytest.mark.parametrize( "ssl_ca_filename", [ - "invalid-ca.pem", # [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain + "invalid-ca.pem", # [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain # TODO: add cases for # [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: IP address mismatch, certificate is not valid for ... # [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: invalid CA certificate