diff --git a/ingestion/src/metadata/utils/source_connections.py b/ingestion/src/metadata/utils/source_connections.py index 2ddc0027d08..f2b32a59918 100644 --- a/ingestion/src/metadata/utils/source_connections.py +++ b/ingestion/src/metadata/utils/source_connections.py @@ -278,11 +278,8 @@ def _(connection: HiveConnection): url += f"{connection.username}" if not connection.password: connection.password = SecretStr("") - url += ( - f":{quote_plus(connection.password.get_secret_value())}" - if connection - else "" - ) + url += f":{quote_plus(connection.password.get_secret_value())}" + url += "@" url += connection.hostPort diff --git a/ingestion/tests/unit/test_source_connection.py b/ingestion/tests/unit/test_source_connection.py index d6e5374bf4b..5131ccd6726 100644 --- a/ingestion/tests/unit/test_source_connection.py +++ b/ingestion/tests/unit/test_source_connection.py @@ -97,20 +97,48 @@ class SouceConnectionTest(TestCase): def test_hive_url(self): expected_result = "hive://localhost:10000/default" - databricks_conn_obj = HiveConnection( + hive_conn_obj = HiveConnection( scheme=HiveScheme.hive, hostPort="localhost:10000", database="default" ) - assert expected_result == get_connection_url(databricks_conn_obj) + assert expected_result == get_connection_url(hive_conn_obj) - def test_hive_url_auth(self): - expected_result = "hive://localhost:10000/default;auth=CUSTOM" - databricks_conn_obj = HiveConnection( - scheme=HiveScheme.hive, + def test_hive_url_custom_auth(self): + expected_result = "hive://username:password@localhost:10000/default" + hive_conn_obj = HiveConnection( + scheme=HiveScheme.hive.value, + username="username", + password="password", hostPort="localhost:10000", database="default", - authOptions="auth=CUSTOM", + connectionArguments={"auth": "CUSTOM"}, ) - assert expected_result == get_connection_url(databricks_conn_obj) + assert expected_result == get_connection_url(hive_conn_obj) + + def test_hive_url_with_kerberos_auth(self): + expected_result = "hive://localhost:10000/default" + hive_conn_obj = HiveConnection( + scheme=HiveScheme.hive.value, + hostPort="localhost:10000", + database="default", + connectionArguments={ + "auth": "KERBEROS", + "kerberos_service_name": "hive", + }, + ) + + assert expected_result == get_connection_url(hive_conn_obj) + + def test_hive_url_with_ldap_auth(self): + expected_result = "hive://username:password@localhost:10000/default" + hive_conn_obj = HiveConnection( + scheme=HiveScheme.hive.value, + username="username", + password="password", + hostPort="localhost:10000", + database="default", + connectionArguments={"auth": "LDAP"}, + ) + assert expected_result == get_connection_url(hive_conn_obj) def test_trino_url_without_params(self): expected_url = "trino://username:pass@localhost:443/catalog"