Linting
This commit is contained in:
parent
7d43a1d23d
commit
6ab2f58b21
@ -418,7 +418,7 @@ class ServerModeMockAWS(BaseMockAWS):
|
|||||||
|
|
||||||
def fake_boto3_client(*args, **kwargs):
|
def fake_boto3_client(*args, **kwargs):
|
||||||
service, region = args
|
service, region = args
|
||||||
kwargs["config"] = Config(user_agent_extra="region/"+region)
|
kwargs["config"] = Config(user_agent_extra="region/" + region)
|
||||||
if "endpoint_url" not in kwargs:
|
if "endpoint_url" not in kwargs:
|
||||||
kwargs["endpoint_url"] = "http://localhost:5000"
|
kwargs["endpoint_url"] = "http://localhost:5000"
|
||||||
return real_boto3_client(*args, **kwargs)
|
return real_boto3_client(*args, **kwargs)
|
||||||
|
@ -188,7 +188,9 @@ class BaseResponse(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
|||||||
default_region = "us-east-1"
|
default_region = "us-east-1"
|
||||||
# to extract region, use [^.]
|
# to extract region, use [^.]
|
||||||
region_regex = re.compile(r"\.(?P<region>[a-z]{2}-[a-z]+-\d{1})\.amazonaws\.com")
|
region_regex = re.compile(r"\.(?P<region>[a-z]{2}-[a-z]+-\d{1})\.amazonaws\.com")
|
||||||
region_from_useragent_regex = re.compile(r"region/(?P<region>[a-z]{2}-[a-z]+-\d{1})")
|
region_from_useragent_regex = re.compile(
|
||||||
|
r"region/(?P<region>[a-z]{2}-[a-z]+-\d{1})"
|
||||||
|
)
|
||||||
param_list_regex = re.compile(r"(.*)\.(\d+)\.")
|
param_list_regex = re.compile(r"(.*)\.(\d+)\.")
|
||||||
access_key_regex = re.compile(
|
access_key_regex = re.compile(
|
||||||
r"AWS.*(?P<access_key>(?<![A-Z0-9])[A-Z0-9]{20}(?![A-Z0-9]))[:/]"
|
r"AWS.*(?P<access_key>(?<![A-Z0-9])[A-Z0-9]{20}(?![A-Z0-9]))[:/]"
|
||||||
@ -274,7 +276,9 @@ class BaseResponse(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
|||||||
|
|
||||||
def get_region_from_url(self, request, full_url):
|
def get_region_from_url(self, request, full_url):
|
||||||
url_match = self.region_regex.search(full_url)
|
url_match = self.region_regex.search(full_url)
|
||||||
user_agent_match = self.region_from_useragent_regex.search(request.headers["User-Agent"])
|
user_agent_match = self.region_from_useragent_regex.search(
|
||||||
|
request.headers.get("User-Agent", "")
|
||||||
|
)
|
||||||
if url_match:
|
if url_match:
|
||||||
region = url_match.group(1)
|
region = url_match.group(1)
|
||||||
elif user_agent_match:
|
elif user_agent_match:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user