Skip to content

Commit

Permalink
Merge pull request #312 from SUSE-Enceladus/az-region
Browse files Browse the repository at this point in the history
Raise if no region is provided for Azure CSP
  • Loading branch information
smarlowucf authored Sep 28, 2021
2 parents 9f39af6 + 328471e commit 4c641fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions img_proof/ipa_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def post_init(self):
' are all required to use an existing subnet.'
)

if not self.region:
raise AzureCloudException(
'Region is required to connect to Azure.'
)

self.service_account_file = (
self.custom_args.get('service_account_file')
or self.ipa_config['service_account_file']
Expand Down
9 changes: 7 additions & 2 deletions tests/test_ipa_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,15 @@ def test_azure_exception_required_args(self):
msg = 'SSH private key file is required to connect to instance.'

# Test ssh private key file required
with pytest.raises(AzureCloudException) as error:
with pytest.raises(AzureCloudException, match=msg):
AzureCloud(**self.kwargs)

assert str(error.value) == msg
# Test region required
self.kwargs['config'] = 'tests/data/config.noregion'
msg = 'Region is required to connect to Azure.'

with pytest.raises(AzureCloudException, match=msg):
AzureCloud(**self.kwargs)

@patch.object(AzureCloud, '_get_client_from_json')
def test_get_management_client(self, mock_get_client):
Expand Down

0 comments on commit 4c641fe

Please sign in to comment.