diff --git a/CHANGELOG.md b/CHANGELOG.md index 16cfa2050c1..9abb838d4c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Added schema and dbt versions to JSON artifacts ([#2670](https://github.com/fishtown-analytics/dbt/issues/2670), [#2767](https://github.com/fishtown-analytics/dbt/pull/2767)) - Added ability to snapshot hard-deleted records (opt-in with `invalidate_hard_deletes` config option). ([#249](https://github.com/fishtown-analytics/dbt/issues/249), [#2749](https://github.com/fishtown-analytics/dbt/pull/2749)) - Improved error messages for YAML selectors ([#2700](https://github.com/fishtown-analytics/dbt/issues/2700), [#2781](https://github.com/fishtown-analytics/dbt/pull/2781)) +- Added support for BigQuery connections using refresh tokens ([#2344](https://github.com/fishtown-analytics/dbt/issues/2344), [#2805](https://github.com/fishtown-analytics/dbt/pull/2805)) ### Under the hood - Added strategy-specific validation to improve the relevancy of compilation errors for the `timestamp` and `check` snapshot strategies. (([#2787](https://github.com/fishtown-analytics/dbt/issues/2787), [#2791](https://github.com/fishtown-analytics/dbt/pull/2791)) diff --git a/test/unit/test_bigquery_adapter.py b/test/unit/test_bigquery_adapter.py index ba6d091ec68..8a68ec31ce8 100644 --- a/test/unit/test_bigquery_adapter.py +++ b/test/unit/test_bigquery_adapter.py @@ -71,6 +71,20 @@ def setUp(self): 'threads': 1, 'impersonate_service_account': 'dummyaccount@dbt.iam.gserviceaccount.com' }, + 'oauth-credentials': { + 'type': 'bigquery', + 'method': 'bearer', + 'client_id': 'abc', + 'client_secret': 'def', + 'refresh_token': 'ghi', + 'token_uri': 'jkl' + 'project': 'dbt-unit-000000', + 'schema': 'dummy_schema', + 'threads': 1, + 'location': 'Luna Station', + 'priority': 'batch', + 'maximum_bytes_billed': 0, + }, }, 'target': 'oauth', } @@ -145,6 +159,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_service_account_validations(self, mock_open_connection): + adapter = self.get_adapter('oauth-credentials') + 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_impersonated_service_account_validations(self, mock_open_connection): adapter = self.get_adapter('impersonate')