Skip to content

Commit

Permalink
Allow users to suppress urllib3 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-rogers-dbt committed Dec 11, 2024
1 parent ca86392 commit 9dd7789
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dbt/adapters/trino/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class TrinoNoneCredentials(TrinoCredentials):
prepared_statements_enabled: bool = PREPARED_STATEMENTS_ENABLED_DEFAULT
retries: Optional[int] = trino.constants.DEFAULT_MAX_ATTEMPTS
timezone: Optional[str] = None
suppress_cert_warning: Optional[bool] = None

@property
def method(self):
Expand All @@ -130,6 +131,7 @@ class TrinoCertificateCredentials(TrinoCredentials):
prepared_statements_enabled: bool = PREPARED_STATEMENTS_ENABLED_DEFAULT
retries: Optional[int] = trino.constants.DEFAULT_MAX_ATTEMPTS
timezone: Optional[str] = None
suppress_cert_warning: Optional[bool] = None

@property
def http_scheme(self):
Expand Down Expand Up @@ -160,6 +162,7 @@ class TrinoLdapCredentials(TrinoCredentials):
prepared_statements_enabled: bool = PREPARED_STATEMENTS_ENABLED_DEFAULT
retries: Optional[int] = trino.constants.DEFAULT_MAX_ATTEMPTS
timezone: Optional[str] = None
suppress_cert_warning: Optional[bool] = None

@property
def http_scheme(self):
Expand Down Expand Up @@ -195,6 +198,7 @@ class TrinoKerberosCredentials(TrinoCredentials):
prepared_statements_enabled: bool = PREPARED_STATEMENTS_ENABLED_DEFAULT
retries: Optional[int] = trino.constants.DEFAULT_MAX_ATTEMPTS
timezone: Optional[str] = None
suppress_cert_warning: Optional[bool] = None

@property
def http_scheme(self):
Expand Down Expand Up @@ -233,6 +237,7 @@ class TrinoJwtCredentials(TrinoCredentials):
prepared_statements_enabled: bool = PREPARED_STATEMENTS_ENABLED_DEFAULT
retries: Optional[int] = trino.constants.DEFAULT_MAX_ATTEMPTS
timezone: Optional[str] = None
suppress_cert_warning: Optional[bool] = None

@property
def http_scheme(self):
Expand Down Expand Up @@ -262,6 +267,7 @@ class TrinoOauthCredentials(TrinoCredentials):
OAUTH = trino.auth.OAuth2Authentication(
redirect_auth_url_handler=trino.auth.WebBrowserRedirectHandler()
)
suppress_cert_warning: Optional[bool] = None

@property
def http_scheme(self):
Expand Down Expand Up @@ -291,6 +297,7 @@ class TrinoOauthConsoleCredentials(TrinoCredentials):
OAUTH = trino.auth.OAuth2Authentication(
redirect_auth_url_handler=trino.auth.ConsoleRedirectHandler()
)
suppress_cert_warning: Optional[bool] = None

@property
def http_scheme(self):
Expand Down Expand Up @@ -478,6 +485,10 @@ def open(cls, connection):
if req_cert_val_flag:
credentials.cert = True

if credentials.suppress_cert_warning:
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# it's impossible for trino to fail here as 'connections' are actually
# just cursor factories.
trino_conn = trino.dbapi.connect(
Expand Down

0 comments on commit 9dd7789

Please sign in to comment.