Skip to content

Commit

Permalink
test: BI-0 Remove SSL certificate error message matching for MySQL co…
Browse files Browse the repository at this point in the history
…nnector tests (#751)

* Simplify SSL certificate error handling in tests

* fix test parameter definition

* lint-fix
  • Loading branch information
khamitovdr authored Dec 17, 2024
1 parent 7824a9d commit 6e6624d
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import re
from typing import Callable

import pytest
Expand Down Expand Up @@ -72,12 +71,9 @@ def check_data_source_templates(
assert dsrc_tmpl.title

@pytest.mark.parametrize(
"ssl_ca_filename, error_message",
"ssl_ca_filename",
[
(
"invalid-ca.pem",
r"\[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
Expand All @@ -88,7 +84,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()
Expand All @@ -104,7 +99,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)

0 comments on commit 6e6624d

Please sign in to comment.