Skip to content

Commit 0040b2c

Browse files
cleanup
1 parent 0da2a4f commit 0040b2c

File tree

6 files changed

+34
-38
lines changed

6 files changed

+34
-38
lines changed

src/aws_encryption_sdk/streaming_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def _has_mpl_attrs_post_init(self):
171171
except AwsCryptographicMaterialProvidersException as mpl_exception:
172172
# Wrap MPL error into the ESDK error type
173173
# so customers only have to catch ESDK error types.
174-
raise AWSEncryptionSDKClientError(mpl_exception)
174+
raise AWSEncryptionSDKClientError(mpl_exception)
175175

176176
def _no_mpl_attrs_post_init(self):
177177
"""If the MPL is NOT present in the runtime, perform post-init logic

test/unit/test_crypto_authentication_signer.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
# ANY KIND, either express or implied. See the License for the specific
1212
# language governing permissions and limitations under the License.
1313
"""Unit test suite for ``aws_encryption_sdk.internal.crypto.authentication.Signer``."""
14-
import pytest
15-
from mock import MagicMock, sentinel, patch
1614
import cryptography.hazmat.primitives.serialization
15+
import pytest
16+
from mock import MagicMock, patch, sentinel
1717
from pytest_mock import mocker # noqa pylint: disable=unused-import
1818

1919
import aws_encryption_sdk.internal.crypto.authentication
@@ -76,7 +76,7 @@ def test_f_signer_from_key_bytes():
7676
def test_f_signer_key_bytes():
7777
test = Signer(algorithm=ALGORITHM, key=VALUES["ecc_private_key_prime"])
7878
assert test.key_bytes() == VALUES["ecc_private_key_prime_private_bytes"]
79-
79+
8080

8181
def test_GIVEN_no_encoding_WHEN_signer_from_key_bytes_THEN_load_der_private_key(
8282
patch_default_backend,
@@ -93,7 +93,10 @@ def test_GIVEN_no_encoding_WHEN_signer_from_key_bytes_THEN_load_der_private_key(
9393
# Mock the `serialization.Encoding.DER`
9494
with patch.object(cryptography.hazmat.primitives, "serialization"):
9595
# Mock the `serialization.load_der_private_key`
96-
with patch.object(aws_encryption_sdk.internal.crypto.authentication.serialization, "load_der_private_key") as mock_der:
96+
with patch.object(
97+
aws_encryption_sdk.internal.crypto.authentication.serialization,
98+
"load_der_private_key"
99+
) as mock_der:
97100
# When: from_key_bytes
98101
Signer.from_key_bytes(
99102
algorithm=_algorithm,
@@ -106,7 +109,7 @@ def test_GIVEN_no_encoding_WHEN_signer_from_key_bytes_THEN_load_der_private_key(
106109
data=sentinel.key_bytes, password=None, backend=patch_default_backend.return_value
107110
)
108111

109-
112+
110113
def test_GIVEN_PEM_encoding_WHEN_signer_from_key_bytes_THEN_load_pem_private_key(
111114
patch_default_backend,
112115
patch_serialization,
@@ -145,7 +148,7 @@ def test_GIVEN_unrecognized_encoding_WHEN_signer_from_key_bytes_THEN_raise_Value
145148
# Then: Raises ValueError
146149
with pytest.raises(ValueError):
147150
# When: from_key_bytes
148-
signer = Signer.from_key_bytes(
151+
Signer.from_key_bytes(
149152
algorithm=_algorithm,
150153
key_bytes=sentinel.key_bytes,
151154
# Given: Invalid encoding

test/unit/test_streaming_client_configs.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,10 @@
3333
# Ideally, this logic would be based on mocking imports and testing logic,
3434
# but doing that introduces errors that cause other tests to fail.
3535
try:
36-
from aws_cryptographic_materialproviders.mpl.references import (
37-
IKeyring,
38-
)
36+
from aws_cryptographic_materialproviders.mpl.references import IKeyring
3937
HAS_MPL = True
4038

41-
from aws_encryption_sdk.materials_managers.mpl.cmm import (
42-
CryptoMaterialsManagerFromMPL,
43-
)
39+
from aws_encryption_sdk.materials_managers.mpl.cmm import CryptoMaterialsManagerFromMPL
4440
except ImportError:
4541
HAS_MPL = False
4642

@@ -59,14 +55,15 @@ class FakeMasterKeyProvider(MasterKeyProvider):
5955

6056
def _new_master_key(self, key_id):
6157
return
62-
58+
59+
6360
if HAS_MPL:
6461
class FakeKeyring(IKeyring):
6562
def on_encrypt(self, param):
66-
return
67-
63+
return
64+
6865
def on_decrypt(self, param):
69-
return
66+
return
7067

7168

7269
BASE_KWARGS = dict(
@@ -234,10 +231,10 @@ def test_client_configs_with_mpl(
234231
kwargs["commitment_policy"] = CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT
235232

236233
test = _ClientConfig(**kwargs)
237-
234+
238235
# In all cases, config should have a materials manager
239236
assert test.materials_manager is not None
240-
237+
241238
# If materials manager was provided, it should be directly used
242239
if hasattr(kwargs, "materials_manager"):
243240
assert kwargs["materials_manager"] == test.materials_manager
@@ -266,10 +263,10 @@ def test_keyring_client_config_with_mpl(
266263
}
267264

268265
test = _ClientConfig(**kwargs)
269-
266+
270267
# In all cases, config should have a materials manager
271268
assert test.materials_manager is not None
272-
269+
273270
# If materials manager was provided, it should be directly used
274271
if hasattr(kwargs, "materials_manager"):
275272
assert kwargs["materials_manager"] == test.materials_manager

test/unit/test_streaming_client_stream_decryptor.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@
3737
# Ideally, this logic would be based on mocking imports and testing logic,
3838
# but doing that introduces errors that cause other tests to fail.
3939
try:
40-
from aws_encryption_sdk.materials_managers.mpl.cmm import (
41-
CryptoMaterialsManagerFromMPL,
42-
)
40+
from aws_encryption_sdk.materials_managers.mpl.cmm import CryptoMaterialsManagerFromMPL
4341
HAS_MPL = True
4442

4543
except ImportError:
@@ -55,7 +53,7 @@ def apply_fixtures(self):
5553
data_key=VALUES["data_key_obj"], verification_key=sentinel.verification_key
5654
)
5755
self.mock_materials_manager.decrypt_materials.return_value = self.mock_decrypt_materials
58-
56+
5957
if HAS_MPL:
6058
self.mock_mpl_materials_manager = MagicMock(__class__=CryptoMaterialsManagerFromMPL)
6159
self.mock_mpl_materials_manager.decrypt_materials.return_value = self.mock_decrypt_materials
@@ -258,7 +256,7 @@ def test_GIVEN_verification_key_AND_no_mpl_WHEN_read_header_THEN_calls_from_key_
258256
# When: read header
259257
test_decryptor._read_header()
260258

261-
# Then: calls from_key_bytes
259+
# Then: calls from_key_bytes
262260
mock_verifier.from_key_bytes.assert_called_once_with(
263261
algorithm=self.mock_header.algorithm, key_bytes=sentinel.verification_key
264262
)

test/unit/test_streaming_client_stream_encryptor.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
"""Unit test suite for aws_encryption_sdk.streaming_client.StreamEncryptor"""
1414
import io
1515

16-
from cryptography.hazmat.primitives import serialization
1716
import pytest
1817
import six
18+
from cryptography.hazmat.primitives import serialization
1919
from mock import MagicMock, call, patch, sentinel
2020

2121
import aws_encryption_sdk.internal.defaults
@@ -42,9 +42,7 @@
4242
# Ideally, this logic would be based on mocking imports and testing logic,
4343
# but doing that introduces errors that cause other tests to fail.
4444
try:
45-
from aws_encryption_sdk.materials_managers.mpl.cmm import (
46-
CryptoMaterialsManagerFromMPL,
47-
)
45+
from aws_encryption_sdk.materials_managers.mpl.cmm import CryptoMaterialsManagerFromMPL
4846
HAS_MPL = True
4947

5048
except ImportError:

test/unit/test_utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,25 +268,25 @@ def test_source_data_key_length_check_invalid(self):
268268

269269
def test_exactly_one_arg_is_not_none(self):
270270
# No args => no args are not None
271-
assert aws_encryption_sdk.internal.utils.exactly_one_arg_is_not_none() is False
271+
assert aws_encryption_sdk.internal.utils.exactly_one_arg_is_not_none() is False
272272
assert aws_encryption_sdk.internal.utils.exactly_one_arg_is_not_none(
273273
None
274-
) is False
274+
) is False
275275
assert aws_encryption_sdk.internal.utils.exactly_one_arg_is_not_none(
276276
"not None"
277-
) is True
277+
) is True
278278
assert aws_encryption_sdk.internal.utils.exactly_one_arg_is_not_none(
279279
"not None", "also not None"
280-
) is False
280+
) is False
281281
assert aws_encryption_sdk.internal.utils.exactly_one_arg_is_not_none(
282282
"not None", None
283-
) is True
283+
) is True
284284
assert aws_encryption_sdk.internal.utils.exactly_one_arg_is_not_none(
285285
"not None", "also not None"
286-
) is False
286+
) is False
287287
assert aws_encryption_sdk.internal.utils.exactly_one_arg_is_not_none(
288288
None, "not None"
289-
) is True
289+
) is True
290290
assert aws_encryption_sdk.internal.utils.exactly_one_arg_is_not_none(
291291
None, None
292-
) is False
292+
) is False

0 commit comments

Comments
 (0)