-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add test for SSM GetParameterHistory API #11841
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -159,6 +159,25 @@ def test_get_parameter_by_arn(self, create_parameter, aws_client, snapshot, clea | |
snapshot.match("Parameter", parameter_by_arn) | ||
snapshot.add_transformer(snapshot.transform.key_value("Name")) | ||
|
||
@markers.aws.validated | ||
@markers.snapshot.skip_snapshot_verify(paths=["$..Tier", "$..Policies"]) | ||
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. I believe that LocalStack does not support the $ awslocal ssm put-parameter --name sandbox --type String --value value1
{
"Version": 1
}
$ awslocal ssm put-parameter --name sandbox --type String --value value2 --overwrite
{
"Version": 2
}
$ awslocal ssm put-parameter --name sandbox --type String --value value3 --overwrite
{
"Version": 3
}
$ awslocal ssm get-parameter --name sandbox
{
"Parameter": {
"Name": "sandbox",
"Type": "String",
"Value": "value3",
"Version": 3,
"LastModifiedDate": "2025-01-28T21:51:59.532000+09:00",
"ARN": "arn:aws:ssm:ap-northeast-1:000000000000:parameter/sandbox",
"DataType": "text"
}
} |
||
def test_get_parameter_history(self, create_parameter, aws_client, snapshot): | ||
param_name = f"param-{short_uid()}" | ||
create_parameter(Name=param_name, Value="test", Type="String") | ||
create_parameter(Name=param_name, Value="test2", Type="String", Overwrite=True) | ||
create_parameter(Name=param_name, Value="test3", Type="String", Overwrite=True) | ||
|
||
response = aws_client.ssm.get_parameter_history(Name=param_name) | ||
assert len(response["Parameters"]) == 3 | ||
assert response["Parameters"][0]["Value"] == "test" | ||
assert response["Parameters"][0]["Version"] == 1 | ||
assert response["Parameters"][2]["Value"] == "test3" | ||
assert response["Parameters"][2]["Version"] == 3 | ||
Comment on lines
+171
to
+175
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. Typically we'd use our snapshot library in these cases, which will also catch changes to the API if we re-validate the case in the future. You can find more information on this in our contribution guidelines. Please let me know if you'd like to tackle this yourself, otherwise I can also generate this for you! 👍 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. Thanks! I will add snapshot test soon :) 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. Question: When using snapshots test, are regular assertions like this unnecessary? Or is it better to have both? Looking at the existing tests in the same file, it seems there are tests using assertions. If it’s not needed, I’ll remove it 😀 |
||
|
||
snapshot.match("get-parameter-history-response", response) | ||
snapshot.add_transformer(snapshot.transform.key_value("Name")) | ||
snapshot.add_transformer(snapshot.transform.key_value("LastModifiedUser")) | ||
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. Thank you for your kind support. I captured the snapshot in my personal AWS account 👍 $ export SNAPSHOT_UPDATE=1
$ export TEST_TARGET=AWS_CLOUD
$ make test TEST_PATH=tests/aws/services/ssm |
||
|
||
@markers.aws.validated | ||
def test_get_inexistent_maintenance_window(self, aws_client): | ||
invalid_name = "mw-00000000000000000" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,38 @@ | ||
{ | ||
"tests/aws/services/ssm/test_ssm.py::TestSSM::test_describe_parameters": { | ||
"last_validated_date": "2025-01-28T12:43:49+00:00" | ||
}, | ||
"tests/aws/services/ssm/test_ssm.py::TestSSM::test_get_inexistent_maintenance_window": { | ||
"last_validated_date": "2025-01-28T12:43:53+00:00" | ||
}, | ||
"tests/aws/services/ssm/test_ssm.py::TestSSM::test_get_inexistent_secret": { | ||
"last_validated_date": "2025-01-28T12:43:51+00:00" | ||
}, | ||
"tests/aws/services/ssm/test_ssm.py::TestSSM::test_get_parameter_by_arn": { | ||
"last_validated_date": "2024-07-16T17:17:40+00:00" | ||
"last_validated_date": "2025-01-28T12:43:53+00:00" | ||
}, | ||
"tests/aws/services/ssm/test_ssm.py::TestSSM::test_get_parameter_history": { | ||
"last_validated_date": "2025-01-28T12:43:53+00:00" | ||
}, | ||
"tests/aws/services/ssm/test_ssm.py::TestSSM::test_get_parameters_and_secrets": { | ||
"last_validated_date": "2025-01-28T12:43:51+00:00" | ||
}, | ||
"tests/aws/services/ssm/test_ssm.py::TestSSM::test_get_parameters_by_path_and_filter_by_labels": { | ||
"last_validated_date": "2025-01-28T12:43:52+00:00" | ||
}, | ||
"tests/aws/services/ssm/test_ssm.py::TestSSM::test_get_secret_parameter": { | ||
"last_validated_date": "2025-01-28T12:43:51+00:00" | ||
}, | ||
"tests/aws/services/ssm/test_ssm.py::TestSSM::test_hierarchical_parameter[/<param>//b//c]": { | ||
"last_validated_date": "2025-01-28T12:43:50+00:00" | ||
}, | ||
"tests/aws/services/ssm/test_ssm.py::TestSSM::test_hierarchical_parameter[<param>/b/c]": { | ||
"last_validated_date": "2025-01-28T12:43:50+00:00" | ||
}, | ||
"tests/aws/services/ssm/test_ssm.py::TestSSM::test_parameters_with_path": { | ||
"last_validated_date": "2025-01-08T17:04:53+00:00" | ||
"last_validated_date": "2025-01-28T12:43:55+00:00" | ||
}, | ||
"tests/aws/services/ssm/test_ssm.py::TestSSM::test_put_parameters": { | ||
"last_validated_date": "2025-01-28T12:43:50+00:00" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I used the existing
create_parameter
method, I got the following error. Because the test calling create_parameter three times with the Overwrite=True parameter.Since the parameter only needs to be deleted once, I added exception handling, referencing the existing implementation😀
https://github.com/localstack/localstack/blob/master/localstack-core/localstack/testing/pytest/fixtures.py#L163-L164