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
15 changes: 13 additions & 2 deletions sqlmesh/core/config/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,17 @@ def _static_connection_kwargs(self) -> t.Dict[str, t.Any]:
OAuth2Authentication,
)

auth: t.Optional[
t.Union[
BasicAuthentication,
KerberosAuthentication,
OAuth2Authentication,
JWTAuthentication,
CertificateAuthentication,
]
] = None
if self.method.is_basic or self.method.is_ldap:
assert self.password is not None # for mypy since validator already checks this
auth = BasicAuthentication(self.user, self.password)
elif self.method.is_kerberos:
if self.keytab:
Expand All @@ -2032,11 +2042,12 @@ def _static_connection_kwargs(self) -> t.Dict[str, t.Any]:
elif self.method.is_oauth:
auth = OAuth2Authentication()
elif self.method.is_jwt:
assert self.jwt_token is not None
auth = JWTAuthentication(self.jwt_token)
elif self.method.is_certificate:
assert self.client_certificate is not None
assert self.client_private_key is not None
auth = CertificateAuthentication(self.client_certificate, self.client_private_key)
else:
auth = None

return {
"auth": auth,
Expand Down
8 changes: 4 additions & 4 deletions tests/core/integration/test_aux_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,20 @@ def test_destroy(copy_to_temp_path):

# Validate tables have been deleted as well
with pytest.raises(
Exception, match=r"Catalog Error: Table with name model_two does not exist!"
Exception, match=r"Catalog Error: Table with name.*model_two.*does not exist"
):
context.fetchdf("SELECT * FROM db_1.first_schema.model_two")
with pytest.raises(
Exception, match=r"Catalog Error: Table with name model_one does not exist!"
Exception, match=r"Catalog Error: Table with name.*model_one.*does not exist"
):
context.fetchdf("SELECT * FROM db_1.first_schema.model_one")

with pytest.raises(
Exception, match=r"Catalog Error: Table with name model_two does not exist!"
Exception, match=r"Catalog Error: Table with name.*model_two.*does not exist"
):
context.engine_adapters["second"].fetchdf("SELECT * FROM db_2.second_schema.model_two")
with pytest.raises(
Exception, match=r"Catalog Error: Table with name model_one does not exist!"
Exception, match=r"Catalog Error: Table with name.*model_one.*does not exist"
):
context.engine_adapters["second"].fetchdf("SELECT * FROM db_2.second_schema.model_one")

Expand Down