-
Notifications
You must be signed in to change notification settings - Fork 433
feat(parameters): Configure max_age and decrypt parameters via environment variables #2088
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
Changes from 2 commits
149c5e5
b4c2d48
77c41a2
02d3254
2a6c90d
74f65f9
639c24f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -547,6 +547,44 @@ def test_ssm_provider_get_with_custom_client(mock_name, mock_value, mock_version | |
stubber.deactivate() | ||
|
||
|
||
def test_ssm_provider_get_with_decrypt_environment_variable(monkeypatch, mock_name, mock_value, mock_version, config): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing test for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hei @heitorlessa, yes! It was missing and refactored the code adding a specific function to resolve the max_age and testing it. I tried to use the function |
||
""" | ||
Test SSMProvider.get() with decrypt value replaced by environment variable | ||
""" | ||
|
||
# Setting environment variable to override the default value | ||
monkeypatch.setenv("POWERTOOLS_PARAMETERS_SSM_DECRYPT", "true") | ||
|
||
# Create a new provider | ||
provider = parameters.SSMProvider(config=config) | ||
|
||
# Stub the boto3 client | ||
stubber = stub.Stubber(provider.client) | ||
response = { | ||
"Parameter": { | ||
"Name": mock_name, | ||
"Type": "String", | ||
"Value": mock_value, | ||
"Version": mock_version, | ||
"Selector": f"{mock_name}:{mock_version}", | ||
"SourceResult": "string", | ||
"LastModifiedDate": datetime(2015, 1, 1), | ||
"ARN": f"arn:aws:ssm:us-east-2:111122223333:parameter/{mock_name}", | ||
} | ||
} | ||
expected_params = {"Name": mock_name, "WithDecryption": True} | ||
stubber.add_response("get_parameter", response, expected_params) | ||
stubber.activate() | ||
|
||
try: | ||
value = provider.get(mock_name) | ||
|
||
assert value == mock_value | ||
stubber.assert_no_pending_responses() | ||
finally: | ||
stubber.deactivate() | ||
|
||
|
||
def test_ssm_provider_get_default_config(monkeypatch, mock_name, mock_value, mock_version): | ||
""" | ||
Test SSMProvider.get() without specifying the config | ||
|
Uh oh!
There was an error while loading. Please reload this page.