mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
test_helpers: Switch add/remove_ratelimit to a contextmanager.
Failing to remove all of the rules which were added causes action at a
distance with other tests. The two methods were also only used by
test code, making their existence in zerver.lib.rate_limiter clearly
misplaced.
This fixes one instance of a mis-balanced add/remove, which caused
tests to start failing if run non-parallel and one more anonymous
request was added within a rate-limit-enabled block.
(cherry picked from commit 0dbe111ab3)
This commit is contained in:
@@ -293,7 +293,6 @@ def is_subdomain_in_allowed_subdomains_list(subdomain: str, allowed_subdomains:
|
||||
|
||||
|
||||
AuthFuncT = TypeVar("AuthFuncT", bound=Callable[..., Optional[UserProfile]])
|
||||
rate_limiting_rules = settings.RATE_LIMITING_RULES["authenticate_by_username"]
|
||||
|
||||
|
||||
class RateLimitedAuthenticationByUsername(RateLimitedObject):
|
||||
@@ -305,7 +304,7 @@ class RateLimitedAuthenticationByUsername(RateLimitedObject):
|
||||
return f"{type(self).__name__}:{self.username}"
|
||||
|
||||
def rules(self) -> List[Tuple[int, int]]:
|
||||
return rate_limiting_rules
|
||||
return settings.RATE_LIMITING_RULES["authenticate_by_username"]
|
||||
|
||||
|
||||
def rate_limit_authentication_by_username(request: HttpRequest, username: str) -> None:
|
||||
|
||||
Reference in New Issue
Block a user