Skip to content

Commit

Permalink
Merge pull request #84 from mattsb42-aws/dev-83
Browse files Browse the repository at this point in the history
fix KMSMasterKeyProvider to determine the default region before trying to create the requested master keys
  • Loading branch information
mattsb42-aws committed Sep 14, 2018
2 parents ff499ad + a691a3c commit 1dedaca
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
Changelog
*********

1.3.7 -- 2018-09-17
===================

Bugfixes
--------

* Fix KMSMasterKeyProvider to determine the default region before trying to create the requested master keys.
`#83 <https://github.com/aws/aws-encryption-sdk-python/issues/83>`_


1.3.6 -- 2018-09-04
===================

Expand Down
2 changes: 1 addition & 1 deletion src/aws_encryption_sdk/identifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from aws_encryption_sdk.exceptions import InvalidAlgorithmError

__version__ = "1.3.6"
__version__ = "1.3.7"
USER_AGENT_SUFFIX = "AwsEncryptionSdkPython/{}".format(__version__)


Expand Down
6 changes: 4 additions & 2 deletions src/aws_encryption_sdk/key_providers/kms.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ def __init__(self, **kwargs): # pylint: disable=unused-argument
def _process_config(self):
"""Traverses the config and adds master keys and regional clients as needed."""
self._user_agent_adding_config = botocore.config.Config(user_agent_extra=USER_AGENT_SUFFIX)
if self.config.key_ids:
self.add_master_keys_from_list(self.config.key_ids)

if self.config.region_names:
self.add_regional_clients_from_list(self.config.region_names)
self.default_region = self.config.region_names[0]
Expand All @@ -126,6 +125,9 @@ def _process_config(self):
if self.default_region is not None:
self.add_regional_client(self.default_region)

if self.config.key_ids:
self.add_master_keys_from_list(self.config.key_ids)

def add_regional_client(self, region_name):
"""Adds a regional client for the specified region if it does not already exist.
Expand Down
7 changes: 7 additions & 0 deletions test/unit/test_providers_kms_master_key_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
pytestmark = [pytest.mark.unit, pytest.mark.local]


def test_init_with_regionless_key_ids_and_region_names():
key_ids = ("alias/key_1",)
region_names = ("test-region-1",)
provider = KMSMasterKeyProvider(region_names=region_names, key_ids=key_ids)
assert provider.master_key("alias/key_1").config.client.meta.region_name == region_names[0]


class TestKMSMasterKeyProvider(unittest.TestCase):
def setUp(self):
self.mock_botocore_session_patcher = patch("aws_encryption_sdk.key_providers.kms.botocore.session.Session")
Expand Down

0 comments on commit 1dedaca

Please sign in to comment.