Skip to content

Commit

Permalink
Fix/ldap password (#396)
Browse files Browse the repository at this point in the history
* Fix password is not passing for thrift + LDAP.

* Add password to tests.

* Add CHANGELOG entry.

* Fixing up changelog entry

Co-authored-by: leahwicz <60146280+leahwicz@users.noreply.github.com>
Co-authored-by: Leah Antkiewicz <leah.antkiewicz@fishtownanalytics.com>
  • Loading branch information
3 people authored Oct 11, 2022
1 parent b65e4f3 commit 37dcfe3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Fixes-20220926-112857.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Fixes
body: Password doesn't pass to server using LDAP connection via thrift (#310)
time: 2022-09-26T11:28:57.306285-04:00
custom:
Author: VShkaberda
Issue: "310"
PR: "396"
3 changes: 3 additions & 0 deletions dbt/adapters/spark/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class SparkCredentials(Credentials):
endpoint: Optional[str] = None
token: Optional[str] = None
user: Optional[str] = None
password: Optional[str] = None
port: int = 443
auth: Optional[str] = None
kerberos_service_name: Optional[str] = None
Expand Down Expand Up @@ -375,6 +376,7 @@ def open(cls, connection):
username=creds.user,
auth=creds.auth,
kerberos_service_name=creds.kerberos_service_name,
password=creds.password,
)
conn = hive.connect(thrift_transport=transport)
else:
Expand All @@ -384,6 +386,7 @@ def open(cls, connection):
username=creds.user,
auth=creds.auth,
kerberos_service_name=creds.kerberos_service_name,
password=creds.password,
) # noqa
handle = PyhiveConnectionWrapper(conn)
elif creds.method == SparkConnectionMethod.ODBC:
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,13 @@ def test_thrift_connection(self):
config = self._get_target_thrift(self.project_cfg)
adapter = SparkAdapter(config)

def hive_thrift_connect(host, port, username, auth, kerberos_service_name):
def hive_thrift_connect(host, port, username, auth, kerberos_service_name, password):
self.assertEqual(host, 'myorg.sparkhost.com')
self.assertEqual(port, 10001)
self.assertEqual(username, 'dbt')
self.assertIsNone(auth)
self.assertIsNone(kerberos_service_name)
self.assertIsNone(password)

with mock.patch.object(hive, 'connect', new=hive_thrift_connect):
connection = adapter.acquire_connection('dummy')
Expand Down Expand Up @@ -193,12 +194,13 @@ def test_thrift_connection_kerberos(self):
config = self._get_target_thrift_kerberos(self.project_cfg)
adapter = SparkAdapter(config)

def hive_thrift_connect(host, port, username, auth, kerberos_service_name):
def hive_thrift_connect(host, port, username, auth, kerberos_service_name, password):
self.assertEqual(host, 'myorg.sparkhost.com')
self.assertEqual(port, 10001)
self.assertEqual(username, 'dbt')
self.assertEqual(auth, 'KERBEROS')
self.assertEqual(kerberos_service_name, 'hive')
self.assertIsNone(password)

with mock.patch.object(hive, 'connect', new=hive_thrift_connect):
connection = adapter.acquire_connection('dummy')
Expand Down

0 comments on commit 37dcfe3

Please sign in to comment.