-
Notifications
You must be signed in to change notification settings - Fork 7
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 #106 from SUSE-Enceladus/gce-sa-error
Raise useful exception msg if file invalid.
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"type": "service_account", | ||
"project_id": "test", | ||
"private_key_id": "1111", | ||
"private_key": "", | ||
"client_id": "1111", | ||
"auth_uri": "https://accounts.google.com/o/oauth2/auth", | ||
"token_uri": "https://accounts.google.com/o/oauth2/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/test%40test.iam.gserviceaccount.com" | ||
} |
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 |
---|---|---|
|
@@ -85,6 +85,29 @@ def test_gce_get_service_account_info(self, | |
'[email protected]' | ||
assert provider.service_account_project == 'test' | ||
|
||
@patch.object(GCEProvider, '_get_ssh_public_key') | ||
@patch.object(GCEProvider, '_get_driver') | ||
def test_gce_get_service_account_info_invalid( | ||
self, | ||
mock_get_driver, | ||
mock_get_ssh_key | ||
): | ||
"""Test get service account info method.""" | ||
mock_get_driver.return_value = None | ||
mock_get_ssh_key.return_value = None | ||
provider = GCEProvider(**self.kwargs) | ||
|
||
provider.service_account_file = \ | ||
'tests/gce/invalid-service-account.json' | ||
|
||
with pytest.raises(GCEProviderException) as error: | ||
provider._get_service_account_info() | ||
|
||
msg = 'Service account JSON file is invalid for GCE. ' \ | ||
'client_email key is expected. See getting started ' \ | ||
'docs for information on GCE configuration.' | ||
assert str(error.value) == msg | ||
|
||
@patch.object(GCEProvider, '_get_ssh_public_key') | ||
@patch('libcloud.compute.drivers.gce.GCENodeDriver') | ||
def test_gce_get_driver(self, | ||
|