Skip to content
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

Require Valid Elasticache Engine Type #8539

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

armichaud
Copy link
Contributor

@armichaud armichaud commented Jan 31, 2025

Resolves issue #8520

@armichaud armichaud marked this pull request as ready for review January 31, 2025 16:06
@armichaud
Copy link
Contributor Author

@bblommers Small contribution, ready for review

Copy link

codecov bot commented Jan 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.63%. Comparing base (024067f) to head (0ee28c3).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8539   +/-   ##
=======================================
  Coverage   92.63%   92.63%           
=======================================
  Files        1229     1229           
  Lines      106422   106433   +11     
=======================================
+ Hits        98580    98591   +11     
  Misses       7842     7842           
Flag Coverage Δ
servertests 27.92% <53.84%> (+<0.01%) ⬆️
unittests 92.60% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@bpandola bpandola left a comment

Choose a reason for hiding this comment

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

I think the heart of the issue is that regardless if the engine type parameter is Redis or redis, we want to store the value as lowercase. This changeset, as currently written, would raise an error if Redis was passed in, which doesn't match AWS behavior. Just converting the engine parameter to lowercase in responses.py:create_user would be the simplest way to address this.


class ValidAuthModeKeys(str, Enum):
TYPE = "Type"
PASSWORD = "Passwords"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I get that you were probably just following the existing convention, but I don't think we gain anything by using Enum here. An array constant, e.g. VALID_ENGINE_TYPES = ["redis", "valkey"], would be simpler, allowing you to compare directly without the separate step of converting the enum values into an array.

== 'Unknown parameter for Engine: "invalidengine", must be one of: redis, valkey'
)


Copy link
Collaborator

Choose a reason for hiding this comment

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

Checking that the returned error code is "InvalidParameterValue" should suffice. We don't want to assert on something that would break if another engine type is added in the future. If you want to be more thorough with your asserts while keeping your test future-proof, you can just check that "Unknown parameter for Engine" is in the message.

@mock_aws
def test_create_user_with_password():
client = boto3.client("elasticache", region_name="ap-southeast-1")
user_id = "user1"
resp = client.create_user(
UserId=user_id,
UserName="User1",
Engine="Redis",
Engine="redis",
Copy link
Collaborator

Choose a reason for hiding this comment

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

AWS allows for Redis or redis to be passed as the engine type, so let's leave all create_user calls as they are and just assert (as you have) that it's redis in the responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants