Fix regex URLs so that a dot is actually interpreted as a dot (#4110)

This commit is contained in:
Bert Blommers 2021-08-28 13:42:45 +01:00 committed by GitHub
parent 8f79edba38
commit 07bb843214
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 81 additions and 42 deletions

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import AWSCertificateManagerResponse
url_bases = ["https?://acm.(.+).amazonaws.com"]
url_bases = ["https?://acm\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": AWSCertificateManagerResponse.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import AthenaResponse
url_bases = ["https?://athena.(.+).amazonaws.com"]
url_bases = ["https?://athena\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": AthenaResponse.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import AutoScalingResponse
url_bases = ["https?://autoscaling.(.+).amazonaws.com"]
url_bases = [r"https?://autoscaling\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": AutoScalingResponse.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import CloudFormationResponse
url_bases = ["https?://cloudformation.(.+).amazonaws.com"]
url_bases = [r"https?://cloudformation\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": CloudFormationResponse.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import CodeCommitResponse
url_bases = ["https?://codecommit.(.+).amazonaws.com"]
url_bases = [r"https?://codecommit\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": CodeCommitResponse.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import CodePipelineResponse
url_bases = ["https?://codepipeline.(.+).amazonaws.com"]
url_bases = [r"https?://codepipeline\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": CodePipelineResponse.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import ConfigResponse
url_bases = ["https?://config.(.+).amazonaws.com"]
url_bases = [r"https?://config\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": ConfigResponse.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import DataPipelineResponse
url_bases = ["https?://datapipeline.(.+).amazonaws.com"]
url_bases = [r"https?://datapipeline\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": DataPipelineResponse.dispatch}

View File

@ -2,6 +2,6 @@ from __future__ import unicode_literals
from .responses import DataSyncResponse
url_bases = ["https?://(.*?)(datasync)(.*?).amazonaws.com"]
url_bases = [r"https?://(.*\.)?(datasync)\.(.+).amazonaws.com"]
url_paths = {"{0}/$": DataSyncResponse.dispatch}

View File

@ -1,9 +1,7 @@
from __future__ import unicode_literals
from .responses import DatabaseMigrationServiceResponse
url_bases = [
"https?://dms.(.+).amazonaws.com",
]
url_bases = [r"https?://dms\.(.+)\.amazonaws\.com"]
url_paths = {

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import DynamoHandler
url_bases = ["https?://dynamodb.(.+).amazonaws.com"]
url_bases = [r"https?://dynamodb\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/": DynamoHandler.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import DynamoHandler
url_bases = ["https?://dynamodb.(.+).amazonaws.com"]
url_bases = [r"https?://dynamodb\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/": DynamoHandler.dispatch}

View File

@ -1,6 +1,9 @@
from __future__ import unicode_literals
from .responses import ECRResponse
url_bases = ["https?://ecr.(.+).amazonaws.com", "https?://api.ecr.(.+).amazonaws.com"]
url_bases = [
r"https?://ecr\.(.+)\.amazonaws\.com",
r"https?://api\.ecr\.(.+)\.amazonaws\.com",
]
url_paths = {"{0}/$": ECRResponse.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import EC2ContainerServiceResponse
url_bases = ["https?://ecs.(.+).amazonaws.com"]
url_bases = [r"https?://ecs\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": EC2ContainerServiceResponse.dispatch}

View File

@ -2,6 +2,6 @@ from __future__ import unicode_literals
from .responses import EventsHandler
url_bases = ["https?://events.(.+).amazonaws.com"]
url_bases = [r"https?://events\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/": EventsHandler.dispatch}

View File

@ -2,6 +2,6 @@ from __future__ import unicode_literals
from .responses import ForecastResponse
url_bases = ["https?://forecast.(.+).amazonaws.com"]
url_bases = [r"https?://forecast\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": ForecastResponse.dispatch}

View File

@ -2,6 +2,6 @@ from __future__ import unicode_literals
from .responses import GlueResponse
url_bases = ["https?://glue(.*).amazonaws.com"]
url_bases = [r"https?://glue\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": GlueResponse.dispatch}

View File

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

View File

@ -1,7 +1,7 @@
from __future__ import unicode_literals
from .responses import IoTResponse
url_bases = ["https?://iot.(.+).amazonaws.com"]
url_bases = [r"https?://iot\.(.+)\.amazonaws\.com"]
response = IoTResponse()

View File

@ -3,8 +3,8 @@ from .responses import KinesisResponse
url_bases = [
# Need to avoid conflicting with kinesisvideo
r"https?://kinesis\.(.+).amazonaws.com",
"https?://firehose.(.+).amazonaws.com",
r"https?://kinesis\.(.+)\.amazonaws\.com",
r"https?://firehose\.(.+)\.amazonaws\.com",
]
url_paths = {"{0}/$": KinesisResponse.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import KmsResponse
url_bases = ["https?://kms.(.+).amazonaws.com"]
url_bases = [r"https?://kms\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": KmsResponse.dispatch}

View File

@ -1,5 +1,5 @@
from .responses import LogsResponse
url_bases = ["https?://logs.(.+).amazonaws.com"]
url_bases = [r"https?://logs\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": LogsResponse.dispatch}

View File

@ -2,9 +2,7 @@ from __future__ import unicode_literals
from .responses import MediaStoreResponse
url_bases = [
"https?://mediastore.(.+).amazonaws.com",
]
url_bases = [r"https?://mediastore\.(.+)\.amazonaws\.com"]
response = MediaStoreResponse()

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import OrganizationsResponse
url_bases = ["https?://organizations.(.+).amazonaws.com"]
url_bases = [r"https?://organizations\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": OrganizationsResponse.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import RDS2Response
url_bases = ["https?://rds.(.+).amazonaws.com", "https?://rds.amazonaws.com"]
url_bases = [r"https?://rds\.(.+)\.amazonaws\.com", r"https?://rds\.amazonaws\.com"]
url_paths = {"{0}/$": RDS2Response.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import RedshiftResponse
url_bases = ["https?://redshift.(.+).amazonaws.com"]
url_bases = [r"https?://redshift\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": RedshiftResponse.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import SecretsManagerResponse
url_bases = ["https?://secretsmanager.(.+).amazonaws.com"]
url_bases = [r"https?://secretsmanager\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": SecretsManagerResponse.dispatch}

View File

@ -1,6 +1,9 @@
from __future__ import unicode_literals
from .responses import EmailResponse
url_bases = ["https?://email.(.+).amazonaws.com", "https?://ses.(.+).amazonaws.com"]
url_bases = [
r"https?://email\.(.+)\.amazonaws\.com",
r"https?://ses\.(.+)\.amazonaws\.com",
]
url_paths = {"{0}/$": EmailResponse.dispatch}

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .responses import SNSResponse
url_bases = ["https?://sns.(.+).amazonaws.com"]
url_bases = [r"https?://sns\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": SNSResponse.dispatch}

View File

@ -1,7 +1,7 @@
from __future__ import unicode_literals
from .responses import SQSResponse
url_bases = ["https?://(.*?)(queue|sqs)(.*?).amazonaws.com"]
url_bases = [r"https?://(.*\.)?(queue|sqs)\.(.*\.)?amazonaws\.com"]
dispatch = SQSResponse().dispatch

View File

@ -1,6 +1,9 @@
from __future__ import unicode_literals
from .responses import SimpleSystemManagerResponse
url_bases = ["https?://ssm.(.+).amazonaws.com", "https?://ssm.(.+).amazonaws.com.cn"]
url_bases = [
r"https?://ssm\.(.+)\.amazonaws\.com",
r"https?://ssm\.(.+)\.amazonaws\.com\.cn",
]
url_paths = {"{0}/$": SimpleSystemManagerResponse.dispatch}

View File

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

View File

@ -1,9 +1,7 @@
from __future__ import unicode_literals
from .responses import SupportResponse
url_bases = [
"https?://support.(.+).amazonaws.com",
]
url_bases = [r"https?://support\.(.+)\.amazonaws\.com"]
url_paths = {

View File

@ -1,5 +1,5 @@
from .responses import SWFResponse
url_bases = ["https?://swf.(.+).amazonaws.com"]
url_bases = [r"https?://swf\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": SWFResponse.dispatch}

View File

@ -2,6 +2,6 @@ from __future__ import unicode_literals
from .responses import TranscribeResponse
url_bases = ["https?://transcribe.(.+).amazonaws.com"]
url_bases = [r"https?://transcribe\.(.+)\.amazonaws\.com"]
url_paths = {"{0}/$": TranscribeResponse.dispatch}

View File

@ -0,0 +1,36 @@
import boto3
import moto
import pytest
from moto import mock_s3
service_names = [
(d[5:], "")
for d in dir(moto)
if d.startswith("mock_")
and not d.endswith("_deprecated")
and not d == "mock_xray_client"
and not d == "mock_all"
]
class TestMockBucketStartingWithServiceName:
"""
https://github.com/spulec/moto/issues/4099
"""
@pytest.mark.parametrize(
"service_name,decorator", service_names,
)
def test_bucketname_starting_with_service_name(self, service_name, decorator):
decorator = getattr(moto, "mock_{}".format(service_name))
with decorator():
with mock_s3():
s3_client = boto3.client("s3", "eu-west-1")
bucket_name = "{}-bucket".format(service_name)
s3_client.create_bucket(
ACL="private",
Bucket=bucket_name,
CreateBucketConfiguration={"LocationConstraint": "eu-west-1"},
)