Commit Graph

3252 Commits

Author SHA1 Message Date
Franck Ndame
808f3c748f
Implementation of core AWS Mediapackage endpoints (#3762)
* write boilerplate code

* generate boilerplate code with scaffold script

* create mediapackage channel

* remove duplicate mediapackage reference

* remove Channel key from mediapackage response

* describe_channel endpoint added

* create_origin_endpoint-added

* keys changed to camel case to fix issue

* minor changes to clean up

* minor clean up again

* implement & test delete_channel

* delete origin endpoint created; WIP-tests failing

* fix delete_origin_endpoint issue

* refactor function call

* delete origin endpoint completed; test_server tests added

* implement and test describe_origin_endpoint

* update origin endpoint added

* remove print statements

* implement test_list_origin_endpoint_succeeds

* create test name changed

* create test name changed

* changes after flake8 and black run

* url assertion added to decribe origin endpoint test

* region dependent url enabled

Co-authored-by: Anya <anya.champaneria@capablue.com>
Co-authored-by: AnyaChamp <71766808+AnyaChamp@users.noreply.github.com>
2021-03-12 14:56:25 +00:00
George Vince
4da11da2bf
Secrets manager untag resource (#3767)
* added: untag_resource + test

* formatting

* formatting

* formatting

* added: formatting fix
2021-03-12 10:35:38 +00:00
Brian Pandola
f96ac40fca
Fix: ApproximateArrivalTimestamp should be epoch with millisecond precision (#3764)
The Record class was already capturing a unix timestamp, but it was incorrectly
converting it to ISO format when sending back to the client.

Updating the model to return the correct timestamp necessitated a minor change
to one of the tests because `botocore` converts non-timezone aware timestamps
to local time.
2021-03-11 08:54:21 +00:00
Jon Michaelchuck
a4009e7bd1
MaxSessionDuration should be included in the list_roles response (#3750) 2021-03-10 08:49:50 +00:00
usmangani1
433e4c0733
Fix:Add functionality authorize-cluster-security-group-ingress (#3742)
* Fix:Add functionality  authorize-cluster-security-group-ingress

* Added tests

* Added more test cases
2021-03-10 08:46:13 +00:00
Anton Grübel
6da4905da9
Fix AttributeNames for sqs.receive_message (#3736)
* Fix AttributeNames for sqs.receive_message

* Fix Lambda issue

* Change to parametrized tests

* Simplify attribute logic
2021-03-05 10:42:07 +00:00
usmangani1
5c04a4d8cc
Fix:update rule (#3734)
* Fix:SQS-message retention period consideration

* Fix:SQS-message retention period consideration

* Fix:SQS-message retention period consideration

* Added comments &linting

* Fixed tests

* Fix:update rule

* Linting and comments
2021-03-02 09:01:09 +00:00
Joakim Saario
457402fbe2
Support SSM Parameter tags (#3739) 2021-03-02 09:00:26 +00:00
Anton Grübel
3c810ad152
Add eventbridge replay (#3735)
* Add events.start_replay

* Add events.describe_replay

* Add events.list_replays

* Add events.cancel_replay

* implement actual replay functionality

* Fix Python 2.7 issues
2021-03-01 13:20:36 +00:00
Jordan Dimov
869b3c45c1
Implements core MediaConnect endpoints (#3718)
* Adds initial models and implements create_flow endpoint.

* Updates README with a Releases section

* Removes unused import

* Adds __init__.py files to MediaLive and MediaConnect test directories.

* Adds list_flows endpoint and tests.

* Adds describe_flow endpoint and tests.

* Adds delete_flow endpoint and tests.

* Adds URLs

* Adds start_flow and stop_flow endpoints and tests.

* Adds tag_resource and list_tags_for_resource endpoints and tests.

* Uses unquote for ARNs
2021-02-25 16:07:26 +00:00
rajinder
4b1c7225b6
added feature update_usage_plan and fixed some lint errors (#3727)
Co-authored-by: rajinder saini <rajinder.saini@c02vt5k2htd6.corp.climate.com>
2021-02-25 07:46:11 +00:00
Jon Michaelchuck
0625bbfa11
Fixes for IAM Role Description field in responses from list_roles and create_roles (#3724)
* Add IAM Role Description field to list_roles responses

The IAM ListRoles IAM API call will return the Description key/value
for each role if it exists.  If it does not exist the Description
key is not included.

* fix handling in create_role resp

* blackg

* Combine two tests using pytest.mark.parametrize

* consistency
2021-02-24 19:14:11 +00:00
William Richard
0f4f01bb7b
Add the status field to ECS task definitions (#3723)
Also I found extra tests for describe_task_definition and deregister_task_definition that were not being run,
so I changed their names so they are found by pytest and made them pass.  I also added checks to them for the new
status field.
2021-02-24 13:26:26 +00:00
Bert Blommers
67c1dbc164
Changelog 2.0.0 (#3721)
* Changelog for upcoming release (..-27/01)

* Changelog for upcoming release (..-21-02)

* Update Implementation Coverage

* Update AWS Managed Policies
2021-02-23 15:16:07 +00:00
Luigi Tagliamonte
442fcd4e51
add tags support to ECS tasks (#3715)
* add tags support to ECS tasks

* lint

* lint

* fmt

* fmt with same version

Co-authored-by: ltagliamonte <ltagliamonte@users.noreply.github.com>
2021-02-21 10:11:34 +00:00
Jakub Musko
c8c6b0bf58
Fix stackset describe/delete. Fix stackset update. (#3713)
* Fix stack set fetching and deleting.

* Also fix stackset update operation to accept previous values.

* Fix linting.

* Rename aliased test.
2021-02-21 09:47:10 +00:00
Ilya Konstantinov
0912abe5f6
dynamodb: fix deleting last set element (w/attr name) (#3708)
* dynamodb: deleting last set element

* add user-facing test
2021-02-19 07:47:51 +00:00
Connor
e61d794cbc
feature/refresh_trusted_advisor_check (#3705)
* Support - added refresh_trusted_advisor_check
- Returns a random check status
- Returns the check id in the response
- Testing for these two functionalities

* test_support - addressed PR comments, to cycle through a faked number of
check status responses
2021-02-18 19:32:06 +00:00
Jakub Musko
b6d7704b23
Update stackset create operation to correctly return the resource's ID. (#3709)
* Update stackset create operation to correctly return the resource's ID.

* Add test confirming create_stack_set response.
2021-02-18 18:04:12 +00:00
Gordon Forsythe
d07e287b37
pool domain should always return a domain (#3707)
* pool domain should always return a domain

Refs https://github.com/spulec/moto/issues/3706

* set character encoding

* test CloudFrontDomain exists on pool domain

* describe pool domain does not return cloudfront domain
2021-02-18 17:10:52 +00:00
Chih-Hsuan Yen
2000f6654f
Support Podman for mocking Lambda (#3702)
* Support Podman for mocking Lambda

Podman supports all Docker APIs used in moto since version 3.0. Note
that Podman requires pulling the image before creating a container
using a fully-qualified image name (e.g., "docker.io/library/busybox"
instead of "busybox").

Test plan:
$ podman system service -t 0
$ DOCKER_HOST="unix://$XDG_RUNTIME_DIR/podman/podman.sock" pytest

Fixes https://github.com/spulec/moto/issues/3276

* Run black

* Python 2 compatibility

* Address review comments and improve parse_image_ref
2021-02-18 08:58:20 +00:00
Bert Blommers
d3ad9d6686
Update integration test to use Pytest (#3703)
* Refactor int test to use pytest

* Add comments to int test script
2021-02-17 15:06:31 +00:00
Brian Pandola
613b1395b8
Fix: DynamoDB:GetItem throws wrong error when table doesn't exist (#3700)
* Fix: DynamoDB:GetItem throws wrong error when table doesn't exist

* Use unique exception for table not found, per PR feedback

* Just fix the reported issue, without touching anything else...
2021-02-17 11:22:00 +00:00
Brian Pandola
6f1eae6f02
Refactor ARNs to remove hardcoded account id (#3701) 2021-02-17 09:06:22 +00:00
Emilio López
5fd20626b3
events: fix archive event pattern match check (#3671)
* events: fix archive event pattern match check

There is a missing `return True` for the positive match case in
matches_pattern, causing all valid patterns to fail.

* events: add test for valid, non-empty pattern match
2021-02-16 08:54:28 +00:00
tony-dot-sh
9feabf5479
Enhancement: implement EC2 instance filtering by subnet-id (#3694)
Co-authored-by: Tony Greising-Murschel <tony@platform.sh>
2021-02-15 16:38:40 +00:00
chrisw-dev
def46b5130
adding list_create_account_status to organization #3691 (#3692)
* adding list_create_account_status to organization #3691

* removing todo comment

Co-authored-by: Chris Walters <chriskwalters@hotmail.com>
2021-02-15 11:39:23 +00:00
Bert Blommers
f64532ed40
Cloudformation - Create ApiGateway resources (#3659)
* Cloudformation - Create ApiGateway resources

* Cleanup

* Linting
2021-02-15 10:31:33 +00:00
Bert Blommers
2f50f9cb24
Add validation to API Key min length value (#3652)
* api gateway - add api key minimum length validation

* api gateway - support includeValue query parameter on api key apis

* [apigateway] code refactoring

* Cleanup - remove duplicate utility methods

* APIGateway - Dont send headers with error messsage

Co-authored-by: Jovan Zivanov <j.zivanov@levi9.com>
2021-02-15 09:39:35 +00:00
Bert Blommers
d7b8419791
Fix Mock 4.0.3 compatibility - Unpatch only once during teardown (#3541)
* #3535 - Unpatch only once during teardown

* EnvVar patching - Fix Python2 bug

* Allow latest version of mock-library
2021-02-15 08:42:16 +00:00
usmangani1
d8097b24dc
Fix:SQS-message retention period consideration (#3642)
* Fix:SQS-message retention period consideration

* Fix:SQS-message retention period consideration

* Fix:SQS-message retention period consideration

* Added comments &linting

* Fixed tests
2021-02-14 13:04:55 +00:00
Connor
4d0ee82f98
support - intial commit to kick off trusted advisor checks (#3685)
* support - intial commit to kick off trusted advisor checks

* edit - expanded testing to include checking for expected check ids and
check names.

Added server testing

added support resource json to manifest file and simplified
support response return from reviewed comments

* Streamline loading of resource files

* edit - ensured regions are assigned in models

Co-authored-by: Bert Blommers <info@bertblommers.nl>
2021-02-14 12:22:16 +00:00
Brian Pandola
e8f1522d1a
Improve autoscaling:CreateLaunchConfiguration request validation (#3687)
AWS requires certain parameters to be mutually inclusive.

Moto wasn't doing anything with the InstanceId parameter, which is now made
clear with a TODO.
2021-02-14 11:38:03 +00:00
Brian Pandola
ae2865d559
Minor RDS Clean up (#3682)
* Fix `DBInstanceNotFound` error message

Changed from `Database` to `DBInstance`, which is actually what comes back from AWS.

* Remove duplicate test

The removed test actually fails if run in isolation because `rds2` is not a
valid boto3 client service.  The reason this test never caused CI to fail is
because it is redefined later in the test suite, effectively making it dead
code that will never run.

Duplicate test has been removed and the remaining test has been improved
with more explicit asserts.
2021-02-13 11:12:02 +00:00
Jonathan Bergknoff
676d61bf5b
Add CRC32 to DynamoDB responses (#3677)
* Add CRC32 to DynamoDB responses

* Change test assertion

* CRC32 - Align Py2/Py3 behaviour

Co-authored-by: Bert Blommers <info@bertblommers.nl>
2021-02-12 14:26:06 +00:00
redparham
b60de10c79
Fix heartbeatTimeout of NONE and polling responses when there are no tasks (#3680)
* fix heartbeatTimeout of NONE resulting in ValueError and polling returning empty string taskToken when it shouldn't be returned

* fix expected taskToken in impacted tests

Co-authored-by: Clint Parham <cparham@aligntech.com>
2021-02-12 13:01:42 +00:00
Cristopher Pinzón
c72670d536
Functionality added to SES service (#3670)
* correct exceptions when mising parameters

* test_render_template function

* update ses template function

* fix import

* except fixed

* tests and py2 fix
2021-02-11 18:31:17 +00:00
Brian Pandola
4a01360d88
Add ResourceGroupsTaggingAPI Support for RDS Resources (#3674)
- AWS::RDS::DBInstance
- AWS::RDS::DBSnapshot
2021-02-11 15:15:24 +00:00
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
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
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
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
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
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
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
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
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
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
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
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
Bert Blommers
0f32f3c50c
#3542 - CloudFormation - Fix SecurityGroup ingress rules (#3553) 2021-01-13 13:36:56 +00:00
Bert Blommers
df8bd43a45
#2965 - S3 - GetObject - Treat empty Range-argument as a regular GET (#3531) 2021-01-13 10:00:18 +00:00
Bert Blommers
77dd35e3b8
Use known ImageID in internal tests (#3555) 2021-01-13 09:02:11 +00:00
aaronfowles-emis
a2246df1a4
Implement full Database object for Glue get_database() - fix for #3571. (#3572)
* implement potential fix for #3571.

* freeze_time decorator not used in TEST_SERVER_MODE
2021-01-11 13:10:18 +00:00
Anton Grübel
17d94f9e09
Add validation to put_events (#3579)
* Add validation to put_events

* Add extra test for put_events

* Fix Python 2.7 error
2021-01-11 09:41:31 +00:00
Erez Freiberger
f749f583ee
Add get_function_configuration support for Lambda (#3562)
* Add get_function_configuration support for Lambda

* remove unnesecary code from test and use _lambda_region when asserting

* rename function and skip coping configuration

* run black formatting
2021-01-10 15:24:04 +00:00
Brian Pandola
640df04840
Implement Add to List for dynamodb:UpdateItem (#3585)
This handles the add-to-list case using the legacy `AttributeUpdates` parameter.

* Added test coverage.
* Verified against real AWS backend.

Closes #3561
2021-01-10 14:20:41 +00:00
Miltos
13252cc4e3
Fix ResourceNotFoundError exception message (#3582)
* Fix ResourceNotFoundError message

* Fix and update unit test for invalid `describe_identity_pool`.
2021-01-10 13:26:40 +00:00
Jordan Sanders
6dfd64ff3c
More accurately mock ECS RegisterTaskDefinition (#3584)
The mocked response for ECS RegisterTaskDefinition has drifted from what
actually returns when run against a real ECS endpoint. I created a
minimal task definition for both EC2:

```
>>> ecs.register_task_definition(
      family="moto",
      containerDefinitions=[
          {
              "name": "hello_world",
              "image": "hello-world:latest",
              "memory": 400
           }
       ]
  )["taskDefinition"]

{'taskDefinitionArn': 'arn:aws:ecs:us-east-1:************:task-definition/moto:1',
 'containerDefinitions': [{'name': 'hello_world',
   'image': 'hello-world:latest',
   'cpu': 0,
   'memory': 400,
   'portMappings': [],
   'essential': True,
   'environment': [],
   'mountPoints': [],
   'volumesFrom': []}],
 'family': 'moto',
 'revision': 1,
 'volumes': [],
 'status': 'ACTIVE',
 'placementConstraints': [],
 'compatibilities': ['EC2']}
```

and FARGATE:
```
>>> ecs.register_task_definition(
      family="moto",
      containerDefinitions=[
          {
              "name": "hello_world",
              "image": "hello-world:latest",
              "memory": 400
           }
       ],
       requiresCompatibilities=["FARGATE"],
       networkMode="awsvpc",
       cpu="256",
       memory="512"
  )["taskDefinition"]

{'taskDefinitionArn': 'arn:aws:ecs:us-east-1:************:task-definition/moto:2',
 'containerDefinitions': [{'name': 'hello_world',
   'image': 'hello-world:latest',
   'cpu': 0,
   'memory': 400,
   'portMappings': [],
   'essential': True,
   'environment': [],
   'mountPoints': [],
   'volumesFrom': []}],
 'family': 'moto',
 'networkMode': 'awsvpc',
 'revision': 2,
 'volumes': [],
 'status': 'ACTIVE',
 'requiresAttributes': [{'name': 'com.amazonaws.ecs.capability.docker-remote-api.1.18'},
  {'name': 'ecs.capability.task-eni'}],
 'placementConstraints': [],
 'compatibilities': ['EC2', 'FARGATE'],
 'requiresCompatibilities': ['FARGATE'],
 'cpu': '256',
 'memory': '512'}
```

This change adds several default keys to the task based on those two
real responses and the AWS documentation:
https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RegisterTaskDefinition.html

The mock still doesn't match the real response exactly but it's much
closer than it was before.
2021-01-09 14:07:35 +00:00
Anton Grübel
f4418185d1
Add launchType parameter to ECS (#3578) 2021-01-08 17:14:40 +00:00
Brian Pandola
d712a98ce1
Enable AWSLambda and STS mocking for AWS China regions/endpoints (#3574)
Fixes #3570
2021-01-08 14:22:12 +00:00
Brian Pandola
1a98c4f14a
Fix: handling of boolean value privateDnsEnabled in ec2:VpcEndpoint (#3566)
* Properly coerce `privateDnsEnabled` to boolean value when parsing requests.
* Per AWS spec, default `privateDnsEnabled` request value to `True`.
* Properly serialize `privateDnsEnabled` as boolean value in responses.
* Add test coverage.

Ref: #3540
2021-01-08 08:05:44 +00:00
usmangani1
bce682a867
Fix:Added nat-gateway tags (#3560)
* Fix:Added nat-gateway tags

* Removed changes
2021-01-07 17:59:46 +00:00
Robin Wilkins
a31599d000
Support cognito admin user password auth flow (#3547)
Applies the user credentials pattern from the ADMIN_NO_SRP_AUTH flow
to the ADMIN_USER_PASSWORD_AUTH auth flow for Cognito admin_initiate_auth
requests.

Co-authored-by: Robin Wilkins <r.wilkins@waracle.com>
2020-12-15 07:48:52 +00:00
Pavel
c9c30b8286
Enabled SNS endpoint attr must be lowercased (#3543)
As per sample response:
https://docs.aws.amazon.com/sns/latest/api/API_GetEndpointAttributes.html
2020-12-14 15:08:33 +00:00
irahulranjan
54bd336457
Fix: FIFO DLQ locks message group id (#3537)
* fix https://github.com/localstack/localstack/issues/3319

* fix review comments
2020-12-14 09:19:22 +00:00
irahulranjan
7b97141184
fix Fifo queue delivers duplicate message(s) (#3538)
* fix https://github.com/localstack/localstack/issues/3339

* fixe lint issues

* Fix review comments
- move deduplication time to constants
- make tests parameterized
- update tests as per review comments

* change variable name expectedCount => expected_count

* fix tests for python 2.7
increase deduplication mock config to account for delays

* ignore time mocking test in server mode
2020-12-13 14:39:10 +00:00
irahulranjan
dffc0e449c
Fix: ListObjectsV2 behaving differently than AWS API (#3545)
* fix : localstack issue https://github.com/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22+language%3Ago

* add assertion for error message as well
2020-12-13 13:38:25 +00:00
Don Kuntz
effb075b62
Add glue.batch_update_partition (#3534)
* Add glue.batch_update_partition

* Fix error output for glue.batch_update_partition and add test case for non-existent partition in the batch update
2020-12-10 20:03:37 +00:00
Anders Kaseorg
4aff7147b5
test_stepfunctions: Fix failures under non-UTC timezone (#3528)
These tests were passing with TZ=UTC, but under a non-UTC timezone
they were failing:

E       AssertionError: given
E       X = [{'timestamp': datetime.datetime(2020, 1, 1, 0, 0, tzinfo=tzutc()), …}, …]
E           and
E       Y = [{'timestamp': datetime.datetime(2020, 1, 1, 0, 0, tzinfo=tzlocal()), …}, …]
E       X[0]['timestamp'] != Y[0]['timestamp']

With this fix, they pass either way.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2020-12-09 12:25:11 +00:00
Jordan Sanders
b4e961148f
Pass the default ECS cluster and raise accurate exceptions (#3522)
* Pass the "default" cluster

* Mock ECS exceptions more accurately

Moto's mock ECS has drifted fairly far from the actual ECS API in terms
of which exceptions it throws. This change begins to bring mock ECS's
exceptions in line with actual ECS exceptions. Most notably:

- Several custom exceptions have been replaced with their real ECS
exception. For example, "{0} is not a cluster" has been replaced with
ClusterNotFoundException
- Tests have been added to verify (most of) these exceptions work
correctly. The test coverage was a little spotty to begin with.
- The new exceptions plus the change to pass the "default" cluster
exposed a lot of places where mock ECS was behaving incorrectly. For
example, the ListTasks action is always scoped to a single cluster in
ECS but it listed tasks for all clusters in the mock. I've minimally
updated the tests to make them pass, but there's lots of opportunity to
refactor both this method's test and its implementation.

This does not provide full coverage of exceptions. In general, I ran
these operations against actual ECS resources and cross-referenced the
documentation to figure out what actual exceptions should be thrown and
what the messages should be. Consequently, I didn't update any
exceptions that took more than trivial amount of time to reproduce with
real resources.
2020-12-08 12:55:49 +00:00
Benjamin Brabant
7c7a1222d2
Fix saml-assertion parsing in assume-role-with-saml (#3523)
* Retrieve SAML Attribute by Name instead of relying on order which is too fragile

* Handle case when SAML Attribute SessionDuration is not provided, as it is not a required attribute from SAML response

When session duration not provided, AWS consider by default a duration of one hour as cited in the following documentation:
"If this attribute is not present, then the credential last for one hour (the default value of the DurationSeconds parameter of the AssumeRoleWithSAML API)."
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_saml_assertions.html#saml_role-session-duration

Traceback was:
[...]
  File "/Users/benjamin.brabant/Projects/PERSO/moto/moto/sts/responses.py", line 79, in assume_role_with_saml
    role = sts_backend.assume_role_with_saml(
  File "/Users/benjamin.brabant/Projects/PERSO/moto/moto/sts/models.py", line 99, in assume_role_with_saml
    role = AssumedRole(**kwargs)
TypeError: __init__() missing 1 required positional argument: 'duration'

* Process saml xml namespaces properly instead of relying on textual prefix that can vary between identity providers

* Handle when SAML response AttributeValue xml tag contains attributes that force xmltodict to build a dictionary as for complex types instead of directly returning string value

Leverage force_cdata option of xmltodict parser that always return a complex dictionary even if xml tag contains only text and no attributes.

* Improve existing test_assume_role_with_saml to be coherent with other assume_role_with_saml tests and remove dead code at the same time
2020-12-08 09:08:40 +00:00
usmangani1
af60306371
Fix:Ec2-VPC:Added functionality describe-vpc-endpoint (#3524)
* Fix:Ec2:Added fucntionality describe-vpc-endpoint

* Refactor

* Added test cases for errors
2020-12-07 21:39:57 +00:00
Bert Blommers
e1fc3a9596
#3506 - DynamoDB - Allow StringSets to be passed to update_item() (#3519) 2020-12-07 09:31:53 +00:00
usmangani1
d44beb0c9d
Fix:Cloudformation descibe stacks special chars (#3514)
* Fix:descibe stacks special chars

* removed debug statements

* Linting

Co-authored-by: usmanokc <usman@okcredit.in>
2020-12-06 08:11:52 +00:00
usmangani1
cfaaa70ea9
FIX:Ec2:Added:Tags for EIP (#3505)
* FIX:Ec2:Added:Tags for EIP

* removed files

* Fix tests
2020-12-06 00:04:46 +00:00
Brian Pandola
8f83f51897
Refactor tests marked xfail to use proper assertions (#3515) 2020-12-04 16:00:48 +00:00