Commit Graph

5635 Commits

Author SHA1 Message Date
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
Dave Randall
d2b751e22d
Bump cryptography library (#3580)
From Python Safety:

Cryptography 3.3 no longer allows loading of finite field Diffie-Hellman parameters of less than 512 bits in length. This change is to conform with an upcoming OpenSSL release that no longer supports smaller sizes. These keys were already wildly insecure and should not have been used in any application outside of testing.
2021-01-09 10:46:09 +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
Bert Blommers
9ecea2012a
Fix Blockchain to work with new API (#3575)
* Fix Blockchain to work with new API

* Improve Lambda->SQS error handling
2021-01-07 11:18:50 +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
Steven Swor
e6be3265ca
Fix owner ID in describe-vpc-endpoints- response. Refs #3524 (#3539) 2020-12-13 10:39:24 +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
Brian Pandola
dcd034045b
Fix: ClusterType, NumberOfNodes not validated when modifying Redshift cluster (#3513)
By definition, `single-node` clusters can only consist of 1 node. Likewise,
`multi-node` clusters must have 2 or more nodes.

* Ensure `ClusterType` parameter is either `multi-node` or `single-node`.
* Ensure proper validation of `NumberOfNodes` parameter based on `ClusterType`
  parameter.
* Fix existing test case that incorrectly allowed a `multi-node` cluster to
  consist of 1 node.
* Add dedicated test for resizing a cluster from `single-node` to `multi-node`
  and back again.

Behavior and error messages have been verified against a real AWS backend.
2020-12-04 13:22:19 +00:00
Brian Pandola
5e21e50424
Fix: elasticbeanstalk ApplicationArn does not contain ApplicationName (#3511)
Fixes #3510
2020-12-04 10:31:28 +00:00
Steve Pulec
b6369d6250
Merge pull request #3512 from xnegativx/fix-auth-params
Fix challenge parameters for cognito-idp/initiate_auth flow
2020-12-03 18:07:32 -06:00
Steve Pulec
51928f2410
Merge pull request #3508 from bblommers/feature/ec2-describe-instance-type-offerings
EC2: describe instance type offerings
2020-12-03 18:06:06 -06:00
Ciaran Evans
48df5bd5af
Add basic get_execution_history implementation for Step Functions (#3507)
* Add format command to makefile

* Refactor executions to be a attribute of StateMachine

* Begin to add tests for execution history

* Add tests for failed and successful event histories, with implementations

* Add failure case to environment var check

* Skip test if in server mode and update implementation coverage

* Add conditional import for mock to cover python 2

* Refactor stop execution logic into StateMachine

* Refactor event history environment variable into settings.py

* Remove typing and os import
2020-12-03 18:32:06 +00:00
Antonin
c5d0aa0c10 fix SALT and SRP_B params 2020-12-03 11:42:10 +01:00
xnegativx
ac0ffab4d0
Merge pull request #1 from spulec/master
Align
2020-12-03 10:38:30 +01:00
usmangani1
ffa7f2e41a
Fix:SES:Get Template Html part (#3504)
* SES:Get Template Html part

* Linting

* Linting

Co-authored-by: Bert Blommers <info@bertblommers.nl>
2020-12-03 07:42:19 +00:00
Bert Blommers
bc67a01e08 Add all InstanceTypeOffering-jsons to Manifest 2020-12-02 14:45:54 +00:00
Bert Blommers
936fb19539 DescribeInstanceTypeOfferings - script that hardcodes all offerings 2020-12-02 14:41:24 +00:00
Bert Blommers
5d208bfd04 Merge branch 'master' into add_instance_type_offerings 2020-12-02 10:57:07 +00:00
usmangani1
b2adcdf518
Fix:RDS:add DBParameterGroupArn in describe-db-parameter-groups & cre… (#3462)
* Fix:RDS:add DBParameterGroupArn in describe-db-parameter-groups & create-db-parameter-group

* Test change

* Fixed tests

* tests change acconutID

* linting

Co-authored-by: usmankb <usman@krazybee.com>
2020-12-01 19:53:01 +00:00
Steve Pulec
72e616cb48 Add tagging to docker image build. 2020-11-28 17:10:38 -06:00
Steve Pulec
d688aba637
Merge pull request #3445 from bblommers/upgrade-travis-linux_distribution
Travis: Use Focal-distribution, so we no longer have to downgrade Docker
2020-11-28 16:19:16 -06:00
Steve Pulec
e8e419a0cd
Merge pull request #3503 from bpandola/remove-boto-dependency
Remove `boto` package dependency
2020-11-28 16:15:14 -06:00
Brian Pandola
ae85c539fd Remove boto package dependency
The `boto` library (long ago superseded by `boto3`) has not had an official
release in over two years or even a commit in the last 18 months.  Importing
the package (or indirectly importing it by via `moto`) generates a deprecation
warning.  Additionally, an ever-increasing number of `moto` users who have
left `boto` behind for `boto3` are still being forced to install `boto`.

This commit vendors a very small subset of the `boto` library--only the code
required by `moto` to run--into the /packages subdirectory.  A README file
is included explaining the origin of the files and a recommendation for how
they can be removed entirely in a future release.

NOTE: Users of `boto` will still be able to use `moto` after this is merged.

closes #2978
closes #3013
closes #3170
closes #3418

relates to #2950
2020-11-26 23:59:15 -08:00
Szymon Zmilczak
bd4aa65635
Mark sts.get_caller_identity as implemented (#3501) 2020-11-26 11:12:09 +00:00
Christian Bandowski
f58e6e1038
#3494 fix using EventBridge via Go SDK (#3495) 2020-11-26 08:52:58 +00:00
Garrett
9e3b23758a
[dynamodb2] Support include projection on indexes (#3498)
* [dynamodb2] Support include projection on indexes

* linter
2020-11-25 20:28:05 +00:00
Brian Pandola
d58d3e2c2e
Fix: yield tests ignored by pytest runner (#3500)
Closes #3499
2020-11-25 10:48:05 +00:00
Brian Pandola
5a2cbf1eca Fix: Duplicate test name causing loss of coverage
A test added in #2401 copied the name of an existing test, preventing it
from being run.  This commit renames the second test, allowing both to
be picked up by the test runner.
2020-11-24 03:29:52 -08:00
Brian Pandola
cf7869d0e2 Add check for UnknownSnapshotCopyRegionFault error 2020-11-24 03:29:52 -08:00