diff --git a/swh/web/api/throttling.py b/swh/web/api/throttling.py --- a/swh/web/api/throttling.py +++ b/swh/web/api/throttling.py @@ -184,7 +184,9 @@ # no throttling for staff users or users with adequate permission return True scope = self.get_scope(view) - if scope == "save_origin" and request.user.has_perm(API_SAVE_ORIGIN_PERMISSION): + if scope == "swh_save_origin" and request.user.has_perm( + API_SAVE_ORIGIN_PERMISSION + ): # no throttling on save origin endpoint for users with adequate permission return True return super().allow_request(request, view) diff --git a/swh/web/settings/tests.py b/swh/web/settings/tests.py --- a/swh/web/settings/tests.py +++ b/swh/web/settings/tests.py @@ -18,7 +18,7 @@ scope2_limiter_rate_post = 2 scope3_limiter_rate = 1 scope3_limiter_rate_post = 1 -save_origin_rate_post = 10 +save_origin_rate_post = 5 swh_web_config = get_config() diff --git a/swh/web/tests/api/views/test_origin_save.py b/swh/web/tests/api/views/test_origin_save.py --- a/swh/web/tests/api/views/test_origin_save.py +++ b/swh/web/tests/api/views/test_origin_save.py @@ -1,4 +1,4 @@ -# Copyright (C) 2018-2021 The Software Heritage developers +# Copyright (C) 2018-2022 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU Affero General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -11,6 +11,7 @@ from django.core.exceptions import ObjectDoesNotExist from django.utils import timezone +from swh.web.api.throttling import SwhWebUserRateThrottle from swh.web.auth.utils import API_SAVE_ORIGIN_PERMISSION, SWH_AMBASSADOR_PERMISSION from swh.web.common.models import ( SAVE_REQUEST_ACCEPTED, @@ -366,7 +367,7 @@ url_args={"visit_type": _visit_type, "origin_url": _origin_url}, ) - for _ in range(save_origin_rate_post): + for _ in range(save_origin_rate_post * SwhWebUserRateThrottle.NUM_REQUESTS_FACTOR): check_api_post_response(api_client, url, status_code=200) check_api_post_response(api_client, url, status_code=200)