Fix regex URLs so that a dot is actually interpreted as a dot (#4110)
This commit is contained in:
parent
8f79edba38
commit
07bb843214
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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 = {
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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()
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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 = {
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
36
tests/test_core/test_url_base_regex.py
Normal file
36
tests/test_core/test_url_base_regex.py
Normal 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"},
|
||||
)
|
Loading…
Reference in New Issue
Block a user