set_initial_no_auth_action_count should also set request_count to 0.

This commit is contained in:
acsbendi 2019-07-24 18:58:50 +02:00
commit e22e8b5a67
3 changed files with 23 additions and 18 deletions

View file

@ -1,5 +1,6 @@
from __future__ import unicode_literals
import functools
from collections import defaultdict
import datetime
import json
@ -123,6 +124,25 @@ class ActionAuthenticatorMixin(object):
def _authenticate_s3_action(self):
self._authenticate_action(S3IAMRequest)
@staticmethod
def set_initial_no_auth_action_count(initial_no_auth_action_count):
def decorator(function):
def wrapper(*args, **kwargs):
original_initial_no_auth_action_count = settings.INITIAL_NO_AUTH_ACTION_COUNT
settings.INITIAL_NO_AUTH_ACTION_COUNT = initial_no_auth_action_count
ActionAuthenticatorMixin.request_count = 0
try:
result = function(*args, **kwargs)
finally:
settings.INITIAL_NO_AUTH_ACTION_COUNT = original_initial_no_auth_action_count
return result
functools.update_wrapper(wrapper, function)
wrapper.__wrapped__ = function
return wrapper
return decorator
class BaseResponse(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):