Enable AWSLambda and STS mocking for AWS China regions/endpoints (#3574)

Fixes #3570
This commit is contained in:
Brian Pandola 2021-01-08 06:22:12 -08:00 committed by GitHub
parent 1a98c4f14a
commit d712a98ce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 2 deletions

View File

@ -1,7 +1,7 @@
from __future__ import unicode_literals
from .responses import LambdaResponse
url_bases = ["https?://lambda.(.+).amazonaws.com"]
url_bases = ["https?://lambda.(.+).amazonaws.com(|.cn)"]
response = LambdaResponse()

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import TokenResponse
url_bases = ["https?://sts(.*).amazonaws.com"]
url_bases = ["https?://sts(.*).amazonaws.com(|.cn)"]
url_paths = {"{0}/$": TokenResponse.dispatch}

View File

@ -86,6 +86,14 @@ def lambda_handler(event, context):
return _process_lambda(pfunc)
@pytest.mark.parametrize("region", ["us-west-2", "cn-northwest-1"])
@mock_lambda
def test_lambda_regions(region):
client = boto3.client("lambda", region_name=region)
resp = client.list_functions()
resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
@mock_lambda
def test_list_functions():
conn = boto3.client("lambda", _lambda_region)

View File

@ -741,3 +741,11 @@ def test_federation_token_with_too_long_policy():
ex.value.response["Error"]["Message"].should.contain(
str(MAX_FEDERATION_TOKEN_POLICY_LENGTH)
)
@pytest.mark.parametrize("region", ["us-west-2", "cn-northwest-1"])
@mock_sts
def test_sts_regions(region):
client = boto3.client("sts", region_name=region)
resp = client.get_caller_identity()
resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)