Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/databricks/sql/backend/thrift_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def __init__(
uri = "{host}:{port}/{path}".format(
host=server_hostname.rstrip("/"), port=port, path=http_path.lstrip("/")
)
if not uri.startswith("https://"):
if not uri.lower().startswith("https://"):
uri = "https://" + uri
else:
raise ValueError("No valid connection settings.")
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/test_thrift_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,28 @@ class ThriftBackendTestSuite(unittest.TestCase):
ttypes.TGetColumnsResp,
]

def test_server_hostname_https_scheme_is_case_insensitive(self):
for scheme in ("", "https://", "HTTPS://", "HtTpS://"):
with self.subTest(scheme=scheme):
backend = ThriftDatabricksClient(
scheme + "httpbin.invalid/",
8443,
"/sql/1.0/warehouses/test",
[],
auth_provider=AuthProvider(),
ssl_options=SSLOptions(),
http_client=MagicMock(),
)
try:
self.assertEqual(backend._transport.scheme, "https")
self.assertEqual(backend._transport.host, "httpbin.invalid")
self.assertEqual(backend._transport.port, 8443)
self.assertEqual(
backend._transport.path, "/sql/1.0/warehouses/test"
)
finally:
backend._transport.close()

def test_make_request_checks_thrift_status_code(self):
mock_response = Mock()
mock_response.status.statusCode = ttypes.TStatusCode.ERROR_STATUS
Expand Down