delay: do not apply on PYTEST
This commit is contained in:
@@ -499,7 +499,14 @@ class Application(ApplicationPartDelete, ApplicationPartHead,
|
|||||||
remote_host, login, info)
|
remote_host, login, info)
|
||||||
# Random delay to avoid timing oracles and bruteforce attacks
|
# Random delay to avoid timing oracles and bruteforce attacks
|
||||||
if self._auth_delay > 0:
|
if self._auth_delay > 0:
|
||||||
|
if 'PYTEST_VERSION' in os.environ:
|
||||||
|
# no random during tests
|
||||||
|
random_delay = self._auth_delay
|
||||||
|
if logger.isEnabledFor(logging.DEBUG):
|
||||||
|
logger.debug("Failed login, sleeping fixed(pytest): %.3f sec", random_delay)
|
||||||
|
else:
|
||||||
random_delay = self._auth_delay * (0.5 + random.random())
|
random_delay = self._auth_delay * (0.5 + random.random())
|
||||||
|
if logger.isEnabledFor(logging.DEBUG):
|
||||||
logger.debug("Failed login, sleeping random: %.3f sec", random_delay)
|
logger.debug("Failed login, sleeping random: %.3f sec", random_delay)
|
||||||
time.sleep(random_delay)
|
time.sleep(random_delay)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user