Commit Graph

5737 Commits

Author SHA1 Message Date
Brian Pandola
8557fb8439
Add support for RDS resource filtering (#3669)
* 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
2021-02-10 09:06:54 +00:00
wynnw
891118a7c7
#3667: Update the s3 post functionality to better support success_action_redirect (#3668)
* 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>
2021-02-10 09:06:03 +00:00
Bert Blommers
46679b3b02
Update README.md 2021-02-09 13:48:48 +00:00
John Flores
791bc77f3a
Add KmsKeyId to Redshift Cluster (#3666)
* 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
2021-02-08 18:52:47 +00:00
Bert Blommers
4ce936a284
CI - Run codecov on all tests, not just Py3.7 (#3654)
* CI - Run codecov on all tests, not just Py3.7

* Update build.yml

* Update build.yml
2021-02-02 18:01:00 +00:00
Bert Blommers
737636f9df
Tech debt (#3653) 2021-02-02 16:31:26 +00:00
Brandon Clodius
81859f9180
(fix) Fixes #3648 (#3649)
* (fix) Fixes #3648

* (fix) formatting

* (review) add assertion for exception thrown
2021-02-02 15:21:16 +00:00
Rahul Ranjan
7d066cea2f
Add versionid header in complete multipart if enabled (#3643)
* Add versionid header in complete multipart if enabled
- addresses https://github.com/localstack/localstack/issues/3514

* remove unnecessary code

* fix lint

* fix lint test

* add test case for boto3
2021-02-02 09:51:17 +00:00
Rahul Ranjan
78a5661093
Cloudwatch get metric data return by period (#3626)
* Cloudwatch get metric data return by period

- addresses https://github.com/localstack/localstack/issues/3493

* fix lint issues

* remove unused import

* added test cases for min max and average
2021-02-02 09:08:53 +00:00
aantillonl
d382731a14
Remove duplicate template of SNS error response (#3647)
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>
2021-02-01 14:58:48 +00:00
Brian Pandola
c9dd9cc7f9
Fix: IoT does not work in server mode (#3644)
Closes #1631
2021-02-01 13:15:57 +00:00
Anton Grübel
0211e9d78d
Add failures output to ecs.describe_services (#3641)
* Add failures output to ecs.describe_services

* Fix autoscaling tests
2021-02-01 12:19:46 +00:00
Anton Grübel
fe9f1dfe14
Add tag & untag user (#3638)
* Add iam.tag_user

* Add iam.untag_user

* Fix Python2 error
2021-02-01 11:37:54 +00:00
Philipp A
f918635ab5
Link remaining badges in README (#3636)
- Adds a link to moto’s PyPI page
- Makes the “Python Versions” badge unclickable
- Adds a link to PyPIstats for download stats
2021-01-31 13:15:04 +00:00
aantillonl
e9dc5edf7f
Update SNS get_endpoint_attributes response for Not Found endpoints (#3637)
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>
2021-01-31 12:29:10 +00:00
Brian Pandola
cd044ef00b
Remove redundant test code (#3640)
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.
2021-01-31 12:21:24 +00:00
Brian Pandola
779d18e00c
Fix: Golang aws-sdk fails to parse elbv2:CreateLoadBalancer response (#3639)
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
2021-01-31 11:39:11 +00:00
Brian Pandola
1037929bf8
Add arns to iot responses (#3634)
Closes #3623
Supersedes #2974
2021-01-31 11:02:08 +00:00
William Richard
5c4b68c5ea
Add support for the force argument for ecs.delete_service (#3631)
This argument allows you to delete a service even when its DesiredCount is non-zero.

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs.html#ECS.Client.delete_service
2021-01-31 10:09:52 +00:00
Brian Pandola
f4b81e69b8
Address pytest warnings (#3629)
* 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.
2021-01-29 11:31:56 +00:00
Brian Pandola
cd25ab7a16
Fix: broken build with release of botocore 1.19.62 (#3628)
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: ff8ae76ecc

Closes #3627
2021-01-29 09:06:25 +00:00
Brian Pandola
ef1cb2e544
Enable GitHub Actions to run successfully on forks (#3622)
* 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).
2021-01-28 15:19:30 +00:00
Anders Kaseorg
e2e107e555
requirements-dev.txt: Remove requirements copied from setup.py (#3619)
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>
2021-01-28 14:28:34 +00:00
Anders Kaseorg
6ecf050228
Use environment markers for Python 2 dependency pins (#3618)
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>
2021-01-28 14:16:20 +00:00
Anton Grübel
199da2220b
Add EventBridge Archive CRUD endpoints (#3617)
* Add events.create_archive

* Add events.describe_archive

* Add events.list_archives

* Add events.update_archive

* Add events.delete_archive

* Add actual archive functionality

* Fix test

* Fix PR issues
2021-01-28 10:47:53 +00:00
Brian Pandola
9e1fcac9d4
Use known AMI in internal tests (#3620)
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.
2021-01-27 19:49:33 +00:00
Bert Blommers
b9b793f421
#3599 - Update Implementation Coverage script (#3621) 2021-01-27 18:54:21 +00:00
Bert Blommers
e40e74d6a2
Create codecov.yml 2021-01-27 17:04:09 +00:00
Bert Blommers
5d5dfb1c6a
Update __init__.py 2021-01-27 13:40:55 +00:00
usmangani1
651998853b
Fix:SNS Create FIFO Topic (#3533)
* Fix:SNS Create FIFO Topic

* Added more tests

* change regular expression and added tests

* Handling NPE

Co-authored-by: usmanokc <usman@okcredit.in>
2021-01-26 15:04:52 +00:00
Brian Pandola
98d79dca97
Address boto deprecation warnings (#3616)
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.
2021-01-26 14:07:19 +00:00
Laurie O
ddd3c0edc4
Assume synchronous Lambda invocation by default (#3615)
* Assume synchronous Lambda invocation by default

* Support Python 2 with dict-unpacking
2021-01-26 13:28:01 +00:00
Bert Blommers
9324ca3b0c
Update README.md 2021-01-26 13:27:13 +00:00
Bert Blommers
8591eda9d6
Introduce Github Actions to replace TravisCI (#3610) 2021-01-26 12:37:03 +00:00
Andrea Amorosi
5a41866f71
Added redshift.get_cluster_credentials (#3611)
* 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>
2021-01-25 13:19:50 +00:00
Bert Blommers
d7f218bfec
Pin sshpubkeys dependency to last version to support Py2 (#3614) 2021-01-25 08:21:13 +00:00
Brian Pandola
38124ab1c9
Fix ec2 filter by empty tag value (#3605)
* 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>
2021-01-24 12:00:25 +00:00
Bert Blommers
8f4c3e4a51
Create GithubActions workflow 2021-01-23 20:46:54 +00:00
Brian Pandola
cb03223c9b
Add TagSpecification support to ec2:CreateImage (#3604)
* Bump `botocore` to minimum version that supports TagSpecifications for this action.
* Add test coverage.

Closes #3602
2021-01-23 12:57:34 +00:00
Pierce Lopez
2bdba88389
server: explicit signal handler for SIGINT and SIGTERM (#3595)
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.
2021-01-19 17:46:00 +00:00
Jordan Dimov
f11e3183bb
Implementation of core AWS Media Live endpoins (#3428)
* 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
2021-01-19 16:11:39 +00:00
Macwan Nevil
02ac5ca111
added sse support for s3 (#3592)
* added sse support for s3

* lint fixed for py37
2021-01-18 18:17:13 +00:00
Erez Freiberger
9784e1b487
adding layers support for lambda backend (#3563)
* adding layers support for lambda backend

* improving lambda layer tests

* adding lambda list_layers and fixing tests

* make format
2021-01-17 15:28:49 +00:00
Modhaffer Rahmani
8fe5a680a5
Added explicit exception raise when no stack found. (#3559)
* 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.
2021-01-16 14:42:51 +00:00
Rahul Ranjan
628c026a07
Sort s3 object versions by last_modified_on in descending order (#3588)
* Sort s3 object versions by last_modified_on in descending order

- addresses https://github.com/localstack/localstack/issues/3433

* fix for python 2

* fix lint
2021-01-15 18:28:28 +00:00
Brian Pandola
7ff60683e0
Expose contextual data when Lambda test fails (#3590)
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.
2021-01-15 14:42:35 +00:00
Matthew Davis
c1180d6e45
add mock_stepfunctions to top-level README (#3589) 2021-01-15 11:09:06 +00:00
Anders Kaseorg
8befcb6a48
Leave the global responses configuration alone (#3529)
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>
2021-01-15 09:12:41 +00:00
Szymon Zmilczak
c8151e1bb4
IoT: Added Rules implementation (#3552)
* feat(iot): Added IoT Rules implementation

* fix(iot): Split IoT Rules tests into multiple test cases

* fix(iot): Updated rule creation to work with python 2

Co-authored-by: Szymon Zmilczak <szymon.zmilczak@machiq.com>
2021-01-14 14:52:23 +00:00
Bert Blommers
d1696a37e5
#2710 - S3 - Raise specific error when GetObject is called with unknown VersionId (#3532) 2021-01-13 16:06:09 +00:00