diff --git a/src/aws_encryption_sdk/keyring/__init__.py b/src/aws_encryption_sdk/keyrings/__init__.py similarity index 100% rename from src/aws_encryption_sdk/keyring/__init__.py rename to src/aws_encryption_sdk/keyrings/__init__.py diff --git a/src/aws_encryption_sdk/keyring/base.py b/src/aws_encryption_sdk/keyrings/base.py similarity index 93% rename from src/aws_encryption_sdk/keyring/base.py rename to src/aws_encryption_sdk/keyrings/base.py index 236037b4e..32f810e47 100644 --- a/src/aws_encryption_sdk/keyring/base.py +++ b/src/aws_encryption_sdk/keyrings/base.py @@ -11,13 +11,11 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. """Base class interface for Keyrings.""" -from aws_encryption_sdk.materials_managers import ( # only used for mypy; pylint: disable=unused-import,duplicate-code +from aws_encryption_sdk.materials_managers import ( # only used for mypy; pylint: disable=unused-import DecryptionMaterials, EncryptionMaterials, ) -from aws_encryption_sdk.structures import ( # only used for mypy; pylint: disable=unused-import,duplicate-code - EncryptedDataKey, -) +from aws_encryption_sdk.structures import EncryptedDataKey # only used for mypy; pylint: disable=unused-import try: # Python 3.5.0 and 3.5.1 have incompatible typing modules from typing import Iterable # noqa pylint: disable=unused-import diff --git a/src/aws_encryption_sdk/keyring/multi_keyring.py b/src/aws_encryption_sdk/keyrings/multi.py similarity index 93% rename from src/aws_encryption_sdk/keyring/multi_keyring.py rename to src/aws_encryption_sdk/keyrings/multi.py index cb2b5cc79..4274c1c4d 100644 --- a/src/aws_encryption_sdk/keyring/multi_keyring.py +++ b/src/aws_encryption_sdk/keyrings/multi.py @@ -17,10 +17,13 @@ from attr.validators import deep_iterable, instance_of, optional from aws_encryption_sdk.exceptions import EncryptKeyError, GenerateKeyError -from aws_encryption_sdk.keyring.base import DecryptionMaterials # only used for mypy so pylint: disable=unused-import -from aws_encryption_sdk.keyring.base import EncryptionMaterials # only used for mypy so pylint: disable=unused-import -from aws_encryption_sdk.keyring.base import Keyring -from aws_encryption_sdk.structures import EncryptedDataKey # only used for mypy so pylint: disable=unused-import +from aws_encryption_sdk.keyrings.base import Keyring + +from aws_encryption_sdk.materials_managers import ( # only used for mypy; pylint: disable=unused-import + DecryptionMaterials, + EncryptionMaterials, +) +from aws_encryption_sdk.structures import EncryptedDataKey # only used for mypy; pylint: disable=unused-import try: # Python 3.5.0 and 3.5.1 have incompatible typing modules from typing import Iterable # noqa pylint: disable=unused-import diff --git a/src/aws_encryption_sdk/keyring/raw_keyring.py b/src/aws_encryption_sdk/keyrings/raw.py similarity index 98% rename from src/aws_encryption_sdk/keyring/raw_keyring.py rename to src/aws_encryption_sdk/keyrings/raw.py index 922f6ae0c..dea924eae 100644 --- a/src/aws_encryption_sdk/keyring/raw_keyring.py +++ b/src/aws_encryption_sdk/keyrings/raw.py @@ -11,7 +11,6 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. """Resources required for Raw Keyrings.""" - import logging import os @@ -28,13 +27,18 @@ from aws_encryption_sdk.internal.formatting.deserialize import deserialize_wrapped_key from aws_encryption_sdk.internal.formatting.serialize import serialize_raw_master_key_prefix, serialize_wrapped_key from aws_encryption_sdk.key_providers.raw import RawMasterKey -from aws_encryption_sdk.keyring.base import Keyring -from aws_encryption_sdk.materials_managers import ( # only used for mypy so pylint: disable=unused-import +from aws_encryption_sdk.keyrings.base import Keyring +from aws_encryption_sdk.structures import ( # pylint: disable=unused-import + EncryptedDataKey, + KeyringTrace, + MasterKeyInfo, + RawDataKey, +) + +from aws_encryption_sdk.materials_managers import ( # only used for mypy; pylint: disable=unused-import DecryptionMaterials, EncryptionMaterials, ) -from aws_encryption_sdk.structures import EncryptedDataKey # only used for mypy so pylint: disable=unused-import -from aws_encryption_sdk.structures import KeyringTrace, MasterKeyInfo, RawDataKey try: # Python 3.5.0 and 3.5.1 have incompatible typing modules from typing import Iterable # noqa pylint: disable=unused-import diff --git a/src/pylintrc b/src/pylintrc index af00ced56..1722f208c 100644 --- a/src/pylintrc +++ b/src/pylintrc @@ -33,6 +33,9 @@ additional-builtins = raw_input [DESIGN] max-args = 10 +[SIMILARITIES] +ignore-imports = yes + [FORMAT] max-line-length = 120 diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test/functional/keyrings/__init__.py b/test/functional/keyrings/__init__.py new file mode 100644 index 000000000..ad0e71d6c --- /dev/null +++ b/test/functional/keyrings/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +"""Dummy stub to make linters work better.""" diff --git a/test/functional/keyrings/raw/__init__.py b/test/functional/keyrings/raw/__init__.py new file mode 100644 index 000000000..ad0e71d6c --- /dev/null +++ b/test/functional/keyrings/raw/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +"""Dummy stub to make linters work better.""" diff --git a/test/functional/test_f_keyring_raw_aes.py b/test/functional/keyrings/raw/test_raw_aes.py similarity index 99% rename from test/functional/test_f_keyring_raw_aes.py rename to test/functional/keyrings/raw/test_raw_aes.py index aa08b07ff..0cfad9d2c 100644 --- a/test/functional/test_f_keyring_raw_aes.py +++ b/test/functional/keyrings/raw/test_raw_aes.py @@ -24,7 +24,7 @@ from aws_encryption_sdk.internal.crypto import WrappingKey from aws_encryption_sdk.internal.formatting.serialize import serialize_raw_master_key_prefix from aws_encryption_sdk.key_providers.raw import RawMasterKey -from aws_encryption_sdk.keyring.raw_keyring import RawAESKeyring +from aws_encryption_sdk.keyrings.raw import RawAESKeyring from aws_encryption_sdk.materials_managers import DecryptionMaterials, EncryptionMaterials from aws_encryption_sdk.structures import KeyringTrace, MasterKeyInfo, RawDataKey diff --git a/test/functional/test_f_keyring_raw_rsa.py b/test/functional/keyrings/raw/test_raw_rsa.py similarity index 99% rename from test/functional/test_f_keyring_raw_rsa.py rename to test/functional/keyrings/raw/test_raw_rsa.py index bdf5bf25c..d900c5cdf 100644 --- a/test/functional/test_f_keyring_raw_rsa.py +++ b/test/functional/keyrings/raw/test_raw_rsa.py @@ -26,7 +26,7 @@ ) from aws_encryption_sdk.internal.crypto import WrappingKey from aws_encryption_sdk.key_providers.raw import RawMasterKey -from aws_encryption_sdk.keyring.raw_keyring import RawRSAKeyring +from aws_encryption_sdk.keyrings.raw import RawRSAKeyring from aws_encryption_sdk.materials_managers import DecryptionMaterials, EncryptionMaterials from aws_encryption_sdk.structures import KeyringTrace, MasterKeyInfo, RawDataKey diff --git a/test/functional/test_f_multi_keyring.py b/test/functional/keyrings/test_multi.py similarity index 97% rename from test/functional/test_f_multi_keyring.py rename to test/functional/keyrings/test_multi.py index 54d519f0b..c6de06f0e 100644 --- a/test/functional/test_f_multi_keyring.py +++ b/test/functional/keyrings/test_multi.py @@ -18,8 +18,8 @@ from aws_encryption_sdk.identifiers import KeyringTraceFlag, WrappingAlgorithm from aws_encryption_sdk.internal.defaults import ALGORITHM -from aws_encryption_sdk.keyring.multi_keyring import MultiKeyring -from aws_encryption_sdk.keyring.raw_keyring import RawAESKeyring, RawRSAKeyring +from aws_encryption_sdk.keyrings.multi import MultiKeyring +from aws_encryption_sdk.keyrings.raw import RawAESKeyring, RawRSAKeyring from aws_encryption_sdk.materials_managers import DecryptionMaterials, EncryptionMaterials from aws_encryption_sdk.structures import KeyringTrace, MasterKeyInfo, RawDataKey diff --git a/test/unit/keyrings/__init__.py b/test/unit/keyrings/__init__.py new file mode 100644 index 000000000..ad0e71d6c --- /dev/null +++ b/test/unit/keyrings/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +"""Dummy stub to make linters work better.""" diff --git a/test/unit/keyrings/raw/__init__.py b/test/unit/keyrings/raw/__init__.py new file mode 100644 index 000000000..ad0e71d6c --- /dev/null +++ b/test/unit/keyrings/raw/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +"""Dummy stub to make linters work better.""" diff --git a/test/unit/test_keyring_raw_aes.py b/test/unit/keyrings/raw/test_raw_aes.py similarity index 96% rename from test/unit/test_keyring_raw_aes.py rename to test/unit/keyrings/raw/test_raw_aes.py index b98279d04..43de2a697 100644 --- a/test/unit/test_keyring_raw_aes.py +++ b/test/unit/keyrings/raw/test_raw_aes.py @@ -19,15 +19,15 @@ from pytest_mock import mocker # noqa pylint: disable=unused-import import aws_encryption_sdk.key_providers.raw -import aws_encryption_sdk.keyring.raw_keyring +import aws_encryption_sdk.keyrings.raw from aws_encryption_sdk.identifiers import Algorithm, KeyringTraceFlag, WrappingAlgorithm from aws_encryption_sdk.internal.crypto.wrapping_keys import WrappingKey -from aws_encryption_sdk.keyring.base import Keyring -from aws_encryption_sdk.keyring.raw_keyring import GenerateKeyError, RawAESKeyring, _generate_data_key +from aws_encryption_sdk.keyrings.base import Keyring +from aws_encryption_sdk.keyrings.raw import GenerateKeyError, RawAESKeyring, _generate_data_key from aws_encryption_sdk.materials_managers import EncryptionMaterials from aws_encryption_sdk.structures import MasterKeyInfo -from .unit_test_utils import ( +from ...unit_test_utils import ( _DATA_KEY, _ENCRYPTED_DATA_KEY_AES, _ENCRYPTED_DATA_KEY_NOT_IN_KEYRING, @@ -57,8 +57,8 @@ def raw_aes_keyring(): @pytest.fixture def patch_generate_data_key(mocker): - mocker.patch.object(aws_encryption_sdk.keyring.raw_keyring, "_generate_data_key") - return aws_encryption_sdk.keyring.raw_keyring._generate_data_key + mocker.patch.object(aws_encryption_sdk.keyrings.raw, "_generate_data_key") + return aws_encryption_sdk.keyrings.raw._generate_data_key @pytest.fixture diff --git a/test/unit/test_keyring_raw_rsa.py b/test/unit/keyrings/raw/test_raw_rsa.py similarity index 96% rename from test/unit/test_keyring_raw_rsa.py rename to test/unit/keyrings/raw/test_raw_rsa.py index 1fcf23da5..e460a4221 100644 --- a/test/unit/test_keyring_raw_rsa.py +++ b/test/unit/keyrings/raw/test_raw_rsa.py @@ -17,14 +17,14 @@ from pytest_mock import mocker # noqa pylint: disable=unused-import import aws_encryption_sdk.key_providers.raw -import aws_encryption_sdk.keyring.raw_keyring +import aws_encryption_sdk.keyrings.raw from aws_encryption_sdk.identifiers import KeyringTraceFlag, WrappingAlgorithm from aws_encryption_sdk.internal.crypto.wrapping_keys import WrappingKey -from aws_encryption_sdk.keyring.base import Keyring -from aws_encryption_sdk.keyring.raw_keyring import RawRSAKeyring +from aws_encryption_sdk.keyrings.base import Keyring +from aws_encryption_sdk.keyrings.raw import RawRSAKeyring -from .test_values import VALUES -from .unit_test_utils import ( +from ...test_values import VALUES +from ...unit_test_utils import ( _BACKEND, _DATA_KEY, _ENCRYPTED_DATA_KEY_RSA, @@ -58,8 +58,8 @@ def raw_rsa_private_key(): @pytest.fixture def patch_generate_data_key(mocker): - mocker.patch.object(aws_encryption_sdk.keyring.raw_keyring, "_generate_data_key") - return aws_encryption_sdk.keyring.raw_keyring._generate_data_key + mocker.patch.object(aws_encryption_sdk.keyrings.raw, "_generate_data_key") + return aws_encryption_sdk.keyrings.raw._generate_data_key @pytest.fixture diff --git a/test/unit/test_keyring_base.py b/test/unit/keyrings/test_base.py similarity index 97% rename from test/unit/test_keyring_base.py rename to test/unit/keyrings/test_base.py index 70863de53..08522de0a 100644 --- a/test/unit/test_keyring_base.py +++ b/test/unit/keyrings/test_base.py @@ -15,7 +15,7 @@ import pytest from aws_encryption_sdk.identifiers import Algorithm -from aws_encryption_sdk.keyring.base import Keyring +from aws_encryption_sdk.keyrings.base import Keyring from aws_encryption_sdk.materials_managers import DecryptionMaterials, EncryptionMaterials pytestmark = [pytest.mark.unit, pytest.mark.local] diff --git a/test/unit/test_keyring_multi.py b/test/unit/keyrings/test_multi.py similarity index 97% rename from test/unit/test_keyring_multi.py rename to test/unit/keyrings/test_multi.py index 6b66a490f..c0bdc78d9 100644 --- a/test/unit/test_keyring_multi.py +++ b/test/unit/keyrings/test_multi.py @@ -19,11 +19,11 @@ from aws_encryption_sdk.exceptions import EncryptKeyError, GenerateKeyError from aws_encryption_sdk.identifiers import WrappingAlgorithm from aws_encryption_sdk.internal.formatting import serialize -from aws_encryption_sdk.keyring.base import Keyring -from aws_encryption_sdk.keyring.multi_keyring import MultiKeyring -from aws_encryption_sdk.keyring.raw_keyring import RawAESKeyring +from aws_encryption_sdk.keyrings.base import Keyring +from aws_encryption_sdk.keyrings.multi import MultiKeyring +from aws_encryption_sdk.keyrings.raw import RawAESKeyring -from .unit_test_utils import ( +from ..unit_test_utils import ( IdentityKeyring, OnlyGenerateKeyring, get_decryption_materials_with_data_key, @@ -139,10 +139,10 @@ def test_keyring_with_no_generator_no_children(): def test_keyring_with_invalid_parameters(generator, children): with pytest.raises(TypeError) as exc_info: MultiKeyring(generator=generator, children=children) - assert exc_info.match("('children'|'generator') must be .*") + assert exc_info.match("('children'|'generator') must be .*") -def test_decryption_keyrings(): +def test_decryption_keyring(): test_multi_keyring = get_multi_keyring_with_generator_and_children() assert test_multi_keyring.generator in test_multi_keyring._decryption_keyrings for child_keyring in test_multi_keyring.children: diff --git a/test/unit/test_utils.py b/test/unit/test_utils.py index 0dee36b41..b83e5de1d 100644 --- a/test/unit/test_utils.py +++ b/test/unit/test_utils.py @@ -21,7 +21,7 @@ import aws_encryption_sdk.internal.utils from aws_encryption_sdk.exceptions import InvalidDataKeyError, SerializationError, UnknownIdentityError from aws_encryption_sdk.internal.defaults import MAX_FRAME_SIZE, MESSAGE_ID_LENGTH -from aws_encryption_sdk.keyring.base import EncryptedDataKey +from aws_encryption_sdk.keyrings.base import EncryptedDataKey from aws_encryption_sdk.structures import DataKey, MasterKeyInfo, RawDataKey from .test_values import VALUES diff --git a/test/unit/unit_test_utils.py b/test/unit/unit_test_utils.py index 1e5d073e8..2bf1bc838 100644 --- a/test/unit/unit_test_utils.py +++ b/test/unit/unit_test_utils.py @@ -21,9 +21,9 @@ from aws_encryption_sdk.identifiers import Algorithm, KeyringTraceFlag, WrappingAlgorithm from aws_encryption_sdk.internal.utils.streams import InsistentReaderBytesIO -from aws_encryption_sdk.keyring.base import Keyring -from aws_encryption_sdk.keyring.multi_keyring import MultiKeyring -from aws_encryption_sdk.keyring.raw_keyring import RawAESKeyring, RawRSAKeyring +from aws_encryption_sdk.keyrings.base import Keyring +from aws_encryption_sdk.keyrings.multi import MultiKeyring +from aws_encryption_sdk.keyrings.raw import RawAESKeyring, RawRSAKeyring from aws_encryption_sdk.materials_managers import DecryptionMaterials, EncryptionMaterials from aws_encryption_sdk.structures import EncryptedDataKey, KeyringTrace, MasterKeyInfo, RawDataKey