Skip to content

Commit ee1b4cc

Browse files
caitlin-tibbettsmattsb42-aws
authored andcommitted
Added a check for max_age being greater than 0 (#172)
* Added a check for max_age being greater than 0 * Fixed flake8 by adding missing pydocstyle dependency * Added the dependency to decrypt_oracle as well * Added test for max_age<=0 ValueError * Updated test for max_age<=0.0 ValueError * Added negative test case
1 parent 1031f6e commit ee1b4cc

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

decrypt_oracle/tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ basepython = python3
156156
deps =
157157
flake8
158158
flake8-docstrings
159+
pydocstyle<4.0.0
159160
# https://github.com/JBKahn/flake8-print/pull/30
160161
flake8-print>=3.1.0
161162
commands =

src/aws_encryption_sdk/materials_managers/caching.py

+3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ def __attrs_post_init__(self):
108108
if self.max_bytes_encrypted > MAX_BYTES_PER_KEY:
109109
raise ValueError("max_bytes_encrypted cannot exceed {}".format(MAX_BYTES_PER_KEY))
110110

111+
if self.max_age <= 0.0:
112+
raise ValueError("max_age cannot be less than or equal to 0")
113+
111114
if self.backing_materials_manager is None:
112115
if self.master_key_provider is None:
113116
raise TypeError("Either backing_materials_manager or master_key_provider must be defined")

test/unit/test_material_managers_caching.py

+2
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ def test_mkp_to_default_cmm(mocker):
117117
dict(max_bytes_encrypted=MAX_BYTES_PER_KEY + 1),
118118
r"max_bytes_encrypted cannot exceed {}".format(MAX_BYTES_PER_KEY),
119119
),
120+
(dict(max_age=0.0), r"max_age cannot be less than or equal to 0"),
121+
(dict(max_age=-1.0), r"max_age cannot be less than or equal to 0"),
120122
),
121123
)
122124
def test_invalid_values(invalid_kwargs, error_message):

tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ basepython = python3
117117
deps =
118118
flake8
119119
flake8-docstrings
120+
pydocstyle<4.0.0
120121
# https://github.com/JBKahn/flake8-print/pull/30
121122
flake8-print>=3.1.0
122123
flake8-bugbear

0 commit comments

Comments
 (0)