* Add support for RDS resource filtering
* Extensive testing was performed against real AWS endpoints in order to
nail down the filter behavior under various scenarios, ensuring that
`moto` returns the proper response or error.
* Full test coverage of all utility functions as well as several
filter/parameter combinations.
* Split up filter tests, per PR feedback
* Remove unused import
* Fix pytest teardown failure on Python 2.7
* Update the s3 post functionality to better support success_action_redirect
- Add the bucket/key values to the redirect url like s3 does, which
supports code that relies on the key value being there on the
redirect.
- Add support for replacing ${filename} in the key value with the actual
filename from the form upload.
See Issue #3667
* Update s3 tests for changed success_action_redirect behavior
- Adds a new test called test_s3_server_post_to_bucket_redirect that
tests both the ${filename} replacement and the key/value addition to the
redirect query args
- Updated the test_creating_presigned_post checks to handle the
key/value additions to the redirect url.
* Fix test updates to work with python2.7
- remove f-string usage
- fix urllib.parse imports to use six
Co-authored-by: Wynn Wilkes <wynn@leading2lean.com>
* Add KmsKeyId to Redshift Cluster
Add the KmsKeyId property when creating a cluster so that it is also
returned when querying the describe_clusters endpoint.
* Run black on updated files
* Add unit test for Redshift KmsKeyId
* Re-run black with correct version
In e9dc5edf7f a custom error template
was added to correct the response returned by get_endpoint_attributes
for a non-existent endpoint.
However, after some more inspection, it was found that a valid
template already existed in moto/sns/responses.py.
This commit removes the template introduced in e9dc5ed and takes
into use the existing template.
It is a marginal improvement, but helps keeping a cleaner code
base
Co-authored-by: Antillon, Alejandro <alejandro.antillon@f-secure.com>
The response returned for sns.get_endpoint_attributes was not in
sync with the actual response from boto.
Co-authored-by: Antillon, Alejandro <alejandro.antillon@f-secure.com>
These tests, when run, do not execute any `moto` code. They fail the
parameter validation check in `botocore`, which raises an exception
before ever sending a request. These tests do not cover or verify
any `moto` behavior and have been removed.
The `botocore` response parsers are forgiving when it comes to timestamps,
but a real AWS backend does return time zone details for this attribute.
Verified failure/fix using the Go repo included in the issue report.
Fixes#3516
* Address `boto` deprecation warnings
This commit eliminates the following warning:
../boto/ec2/connection.py:582:
PendingDeprecationWarning: The current get_all_instances implementation will be replaced with get_all_reservations.
`boto` isn't likely to ever make good on this warning, but doing the replacement will
declutter the `moto` test output.
* Remove `invoke_lambda` tracebacks from unit test logging
If an exception is encountered, the details are returned in the response payload.
Printing the traceback was just adding noise to the pytest output.
* Use known AMIs in unit tests
This commit eliminates the following warning in the pytest output:
`PendingDeprecationWarning: Could not find AMI with image-id:ami-123456, in the near future this will cause an error.`
Known, pre-loaded AMI image ids are used instead of random ids that don't actually
exist in the moto backend. The integrity of the tests is unaffected by this change.
A test has been added to provide explicit coverage of the PendingDeprecationWarning
raised when an invalid AMI image id is passed to moto.
The latest release of `botocore` (1.19.62) makes changes to the parameter
validation code, which for some reason was also covered by a couple of
`moto` tests.
These tests, when run, do not execute any `moto` code. They fail the
parameter validation check in `botocore`, which raises an exception
before ever sending a request. These tests do not cover or verify
any `moto` behavior and have been removed.
Ref: ff8ae76eccCloses#3627
* Trigger workflow on any push or pull request.
* Conditionally run Codecov Upload and Deploy *only* on `spulec/moto` repository.
This allows contributors to get CI results on their forked repo before
submitting PRs to `moto`. Previously, forked repos could run the actions
but would fail (rightfully) on the steps that should only be run on the
main repo (and require tokens/secrets).
Most of these were already pulled in via -r requirements.txt → -e
.[all]; add the remainder with -e .[all,server].
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
PyPI does not run setup.py separately for each Python version to
resolve requirements, so these conditional requirements need to be
properly specified in the metadata, not in code.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Moto's implementation of autoscaling:CreateLaunchConfiguration is a little too loose,
allowing the ImageId parameter to be omitted and defaulting it to None, which results
in dozens of deprecation warnings:
`PendingDeprecationWarning: Could not find AMI with image-id:ami-123456, in the near future this will cause an error.`
This commit refactors calls to CreateLaunchConfiguration to explicitly pass in a known
AMI ImageId in order to avoid these warnings.
The integrity of the tests is unaffected by this change.
This commit eliminates the following warning (of which there are currently dozens):
../boto/ec2/connection.py:582:
PendingDeprecationWarning: The current get_all_instances implementation will be replaced with get_all_reservations.
`boto` isn't likely to ever make good on this warning, but doing the replacement will
declutter the `moto` test output.
* Added redshift.get_cluster_credentials
* Marked endpoint in list
* Removed f string from tests
* Python 2.7 compat changes
* Fixed parameter retrieval
* Formatting
* Removed try/catch in favor of if
* Changed to existing random_string util
Co-authored-by: Andrea Amorosi <aamorosi@amazon.es>
* Fix ec2 filter by empty tag value
Return `None` instead of an empty string when the tag key does not exist
and replace the falsy check with a more explicit `is None`, which allows
empty string values to correctly pass through the filter comparator.
Behavior confirmed against a real AWS backend.
Closes#3603
* Make test case more explicit
Test case now pulled directly from the issue report (#3603).
Co-authored-by: Bert Blommers <bblommers@users.noreply.github.com>
When running alone as pid 1 in a container, most signals that would
cause the process to exit by default, are instead ignored by default.
The container runtime will send SIGTERM, wait 10 seconds, then send
SIGKILL, which will work, but moto.server can exit much faster if
it has an explicit SIGTERM handler.
* Initial attempt to mock AWS Media Live create_channel endpoint. Test fails.
* Completes basic implementation of Media Live create_channel endpoint
* Completes basic implementation of Media Live list_channels endpoint
* Adds skaffolds for describe_channel and delete_channel
* Adds unit test for delete_channel
* Adds unit test for describe_channel
* Reduces repetitive code by introducing a Channel model
* Implements MediaLive start_channel and stop_channel endpoints
* Fixes lack of support for the dash character in resource ARNs
* Implements MediaLive update_channel endpoint.
* Implements MediaLive create_input endpoint (and Input model).
* Implements MediaLive describe_input endpoint.
* Implements MediaLive list_inputs endpoint.
* Implements MediaLive update_input endpoint.
* Addse server tests for MediaLive
* Adds further url patterns for medialive
* Fixes url patterns
* Fixes url patterns
* Added explicit exception raise when no stack found.
Currently, any operation that uses 'get_stack' method from 'CloudFormationBackend' class
will fail with AttributeError or jinja2 exception if ran against non-existing stack(created/deleted)
To fix the issue I explicitly raised a 'ValidationError' exception.
Added tests for boto and boto3 responses.
* Moved non-existing stack tests to 'test_stack_events'
When using 'update_stack' to test raising an exception when the stack doesn't exist
test coverage dropped by 0.5%. I am using stack_events instead.
* Removed some unreachable paths
After adding the exception couple of paths in the code are unreachable as 'get_stack' doesn't return 'None' anymore.
This is the reason why coverall was reporting decreased coverage.
* Removed an unreachable path I missed
* Added couple of tests in cloudformation/models
* Added more assertions around raised exception
* Formatted document using black to fix issue with travis.
This test is flaky, but when it fails we don't get any indication as to why.
This commit ensures that the reason for failure will be part of the assertion
message.
Once we have information about why this test fails, we can troubleshoot further
and hopefully come up with a permanent fix.
Instead of modifying responses._default_mock, create our own
responses.RequestsMock object that we can modify as needed without
interfering with other users of the responses library.
Fixes#3264.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>