Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/unit/sqlalchemy/test_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,23 @@ def test_trino_connection_certificate_auth():
assert cparams['auth']._key == key


def test_trino_connection_certificate_auth_cert_and_key_required():
dialect = TrinoDialect()
cert = '/path/to/cert.pem'
key = '/path/to/key.pem'
url = make_url(f'trino://host/?cert={cert}')
_, cparams = dialect.create_connect_args(url)

assert 'http_scheme' not in cparams
assert 'auth' not in cparams

url = make_url(f'trino://host/?key={key}')
_, cparams = dialect.create_connect_args(url)

assert 'http_scheme' not in cparams
assert 'auth' not in cparams


def test_trino_connection_oauth2_auth():
dialect = TrinoDialect()
url = make_url('trino://host/?externalAuthentication=true')
Expand Down
2 changes: 1 addition & 1 deletion trino/sqlalchemy/dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def create_connect_args(self, url: URL) -> Tuple[Sequence[Any], Mapping[str, Any
kwargs["http_scheme"] = "https"
kwargs["auth"] = JWTAuthentication(unquote_plus(url.query["access_token"]))

if "cert" and "key" in url.query:
if "cert" in url.query and "key" in url.query:
kwargs["http_scheme"] = "https"
kwargs["auth"] = CertificateAuthentication(unquote_plus(url.query['cert']), unquote_plus(url.query['key']))

Expand Down