Skip to content

Commit

Permalink
hotfix: this was overriding params even when it was set
Browse files Browse the repository at this point in the history
+ add assert checks on theirs contents
  • Loading branch information
Sanix-Darker committed Sep 21, 2023
1 parent 83b8b32 commit 2eb5654
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion tests/google_big_query/test_google_big_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,9 +798,29 @@ def test_optional_fields_validator_for_google_creds():
}

# Can create the connector without all fields on GoogleCredentials
_ = GoogleBigQueryConnector(
connector1 = GoogleBigQueryConnector(
name='something', credentials=incomplete_credentials_with_project_id
)
# default values setted when not valids
assert connector1.credentials.private_key == '__not_set__'
assert connector1.credentials.private_key_id == '__not_set__'

# with valid values set
valid_credentials = {
'type': 'service_account',
'project_id': 'your-project-id',
'private_key_id': 'my_private_key_id',
'private_key': 'my_private_key',
'client_email': '[email protected]',
'client_id': 'my_client_id',
'auth_uri': 'https://accounts.google.com/o/oauth2/auth',
'token_uri': 'https://oauth2.googleapis.com/token',
'auth_provider_x509_cert_url': 'https://www.googleapis.com/oauth2/v1/certs',
'client_x509_cert_url': 'https://www.googleapis.com/robot/v1/metadata/x509/pika.com',
}
connector2 = GoogleBigQueryConnector(name='something', credentials=valid_credentials)
assert connector2.credentials.private_key == 'my_private_key'
assert connector2.credentials.private_key_id == 'my_private_key_id'

incomplete_credentials_with_no_project_id = {
'type': 'service_account',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def validate_google_credentials(cls, value):
'auth_uri',
]:
value[field_name] = 'https://valid-scheme.com'
else:
elif not value.get(field_name):
value[field_name] = '__not_set__'

return value
Expand Down

0 comments on commit 2eb5654

Please sign in to comment.