-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2677 from bbhoss/bq_impersonate
Add support for impersonating a service account with BigQuery
- Loading branch information
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,14 @@ def setUp(self): | |
'priority': 'batch', | ||
'maximum_bytes_billed': 0, | ||
}, | ||
'impersonate': { | ||
'type': 'bigquery', | ||
'method': 'oauth', | ||
'project': 'dbt-unit-000000', | ||
'schema': 'dummy_schema', | ||
'threads': 1, | ||
'impersonate_service_account': '[email protected]' | ||
}, | ||
}, | ||
'target': 'oauth', | ||
} | ||
|
@@ -134,6 +142,23 @@ def test_acquire_connection_service_account_validations(self, mock_open_connecti | |
connection.handle | ||
mock_open_connection.assert_called_once() | ||
|
||
@patch('dbt.adapters.bigquery.BigQueryConnectionManager.open', return_value=_bq_conn()) | ||
def test_acquire_connection_impersonated_service_account_validations(self, mock_open_connection): | ||
adapter = self.get_adapter('impersonate') | ||
try: | ||
connection = adapter.acquire_connection('dummy') | ||
self.assertEqual(connection.type, 'bigquery') | ||
|
||
except dbt.exceptions.ValidationException as e: | ||
self.fail('got ValidationException: {}'.format(str(e))) | ||
|
||
except BaseException as e: | ||
raise | ||
|
||
mock_open_connection.assert_not_called() | ||
connection.handle | ||
mock_open_connection.assert_called_once() | ||
|
||
@patch('dbt.adapters.bigquery.BigQueryConnectionManager.open', return_value=_bq_conn()) | ||
def test_acquire_connection_priority(self, mock_open_connection): | ||
adapter = self.get_adapter('loc') | ||
|