Autoscaling: params not sorted properly when tags are present (#6038)
This commit is contained in:
parent
0231979c18
commit
8d09d797e6
@ -12,7 +12,11 @@ from collections import defaultdict, OrderedDict
|
||||
from moto import settings
|
||||
from moto.core.common_types import TYPE_RESPONSE, TYPE_IF_NONE
|
||||
from moto.core.exceptions import DryRunClientError
|
||||
from moto.core.utils import camelcase_to_underscores, method_names_from_class
|
||||
from moto.core.utils import (
|
||||
camelcase_to_underscores,
|
||||
method_names_from_class,
|
||||
params_sort_function,
|
||||
)
|
||||
from moto.utilities.utils import load_resource
|
||||
from jinja2 import Environment, DictLoader, Template
|
||||
from typing import (
|
||||
@ -122,7 +126,6 @@ class _TemplateEnvironmentMixin(object):
|
||||
|
||||
|
||||
class ActionAuthenticatorMixin(object):
|
||||
|
||||
request_count: ClassVar[int] = 0
|
||||
|
||||
def _authenticate_and_authorize_action(self, iam_request_cls: type) -> None:
|
||||
@ -204,7 +207,6 @@ class ActionAuthenticatorMixin(object):
|
||||
|
||||
|
||||
class BaseResponse(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
||||
|
||||
default_region = "us-east-1"
|
||||
# to extract region, use [^.]
|
||||
# Note that the URL region can be anything, thanks to our MOTO_ALLOW_NONEXISTENT_REGION-config - so we can't have a very specific regex
|
||||
@ -687,7 +689,7 @@ class BaseResponse(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
||||
}
|
||||
"""
|
||||
params: Dict[str, Any] = {}
|
||||
for k, v in sorted(self.querystring.items()):
|
||||
for k, v in sorted(self.querystring.items(), key=params_sort_function):
|
||||
self._parse_param(k, v[0], params)
|
||||
return params
|
||||
|
||||
|
@ -2,7 +2,7 @@ import datetime
|
||||
import inspect
|
||||
import re
|
||||
from botocore.exceptions import ClientError
|
||||
from typing import Any, Optional, List, Callable, Dict
|
||||
from typing import Any, Optional, List, Callable, Dict, Tuple
|
||||
from urllib.parse import urlparse
|
||||
from .common_types import TYPE_RESPONSE
|
||||
|
||||
@ -307,3 +307,15 @@ def extract_region_from_aws_authorization(string: str) -> Optional[str]:
|
||||
if region == auth:
|
||||
return None
|
||||
return region
|
||||
|
||||
|
||||
def params_sort_function(item: Tuple[str, Any]) -> Tuple[str, Any]:
|
||||
"""
|
||||
Comparison function used to sort params appropriately taking tags non
|
||||
alphabetical order into consideration
|
||||
"""
|
||||
key, _ = item
|
||||
if key.startswith("Tags.member"):
|
||||
member_num = int(key.split(".")[2])
|
||||
return ("Tags.member", member_num)
|
||||
return item
|
||||
|
Loading…
Reference in New Issue
Block a user