Skip to content

Added a check for max_age being greater than 0 #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions decrypt_oracle/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ basepython = python3
deps =
flake8
flake8-docstrings
pydocstyle<4.0.0
# https://github.com/JBKahn/flake8-print/pull/30
flake8-print>=3.1.0
commands =
Expand Down
3 changes: 3 additions & 0 deletions src/aws_encryption_sdk/materials_managers/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ def __attrs_post_init__(self):
if self.max_bytes_encrypted > MAX_BYTES_PER_KEY:
raise ValueError("max_bytes_encrypted cannot exceed {}".format(MAX_BYTES_PER_KEY))

if self.max_age <= 0.0:
raise ValueError("max_age cannot be less than or equal to 0")

if self.backing_materials_manager is None:
if self.master_key_provider is None:
raise TypeError("Either backing_materials_manager or master_key_provider must be defined")
Expand Down
2 changes: 2 additions & 0 deletions test/unit/test_material_managers_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def test_mkp_to_default_cmm(mocker):
dict(max_bytes_encrypted=MAX_BYTES_PER_KEY + 1),
r"max_bytes_encrypted cannot exceed {}".format(MAX_BYTES_PER_KEY),
),
(dict(max_age=0.0), r"max_age cannot be less than or equal to 0"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness, let's also add a negative value test case.

(dict(max_age=-1.0), r"max_age cannot be less than or equal to 0"),
),
)
def test_invalid_values(invalid_kwargs, error_message):
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ basepython = python3
deps =
flake8
flake8-docstrings
pydocstyle<4.0.0
# https://github.com/JBKahn/flake8-print/pull/30
flake8-print>=3.1.0
flake8-bugbear
Expand Down