source-connection-unitest-added (#4916)

This commit is contained in:
codingwithabhi 2022-05-13 13:48:04 +05:30 committed by GitHub
parent 364f185e63
commit da92d07c78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 13 deletions

View File

@ -278,11 +278,8 @@ def _(connection: HiveConnection):
url += f"{connection.username}" url += f"{connection.username}"
if not connection.password: if not connection.password:
connection.password = SecretStr("") connection.password = SecretStr("")
url += ( url += f":{quote_plus(connection.password.get_secret_value())}"
f":{quote_plus(connection.password.get_secret_value())}"
if connection
else ""
)
url += "@" url += "@"
url += connection.hostPort url += connection.hostPort

View File

@ -97,20 +97,48 @@ class SouceConnectionTest(TestCase):
def test_hive_url(self): def test_hive_url(self):
expected_result = "hive://localhost:10000/default" expected_result = "hive://localhost:10000/default"
databricks_conn_obj = HiveConnection( hive_conn_obj = HiveConnection(
scheme=HiveScheme.hive, hostPort="localhost:10000", database="default" 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): def test_hive_url_custom_auth(self):
expected_result = "hive://localhost:10000/default;auth=CUSTOM" expected_result = "hive://username:password@localhost:10000/default"
databricks_conn_obj = HiveConnection( hive_conn_obj = HiveConnection(
scheme=HiveScheme.hive, scheme=HiveScheme.hive.value,
username="username",
password="password",
hostPort="localhost:10000", hostPort="localhost:10000",
database="default", 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): def test_trino_url_without_params(self):
expected_url = "trino://username:pass@localhost:443/catalog" expected_url = "trino://username:pass@localhost:443/catalog"