|
@@ -1,8 +1,10 @@
|
|
|
from django.core import mail
|
|
|
+from django.test import override_settings
|
|
|
from django.urls import reverse
|
|
|
|
|
|
from sentry.models.options.project_option import ProjectOption
|
|
|
from sentry.testutils.cases import APITestCase
|
|
|
+from sentry.testutils.helpers.datetime import freeze_time
|
|
|
|
|
|
|
|
|
class ProjectTransferTest(APITestCase):
|
|
@@ -73,3 +75,27 @@ class ProjectTransferTest(APITestCase):
|
|
|
|
|
|
assert response.status_code == 404
|
|
|
assert not mail.outbox
|
|
|
+
|
|
|
+ @override_settings(SENTRY_SELF_HOSTED=False)
|
|
|
+ def test_rate_limit(self):
|
|
|
+ project = self.create_project()
|
|
|
+ # new user is not an owner of anything
|
|
|
+ new_user = self.create_user("b@example.com")
|
|
|
+ self.login_as(user=self.user)
|
|
|
+
|
|
|
+ url = reverse(
|
|
|
+ "sentry-api-0-project-transfer",
|
|
|
+ kwargs={
|
|
|
+ "organization_id_or_slug": project.organization.slug,
|
|
|
+ "project_id_or_slug": project.slug,
|
|
|
+ },
|
|
|
+ )
|
|
|
+
|
|
|
+ with freeze_time("2024-07-01"):
|
|
|
+ for _ in range(3 + 1):
|
|
|
+ response = self.client.post(url, {"email": new_user.email})
|
|
|
+ assert response.status_code == 429
|
|
|
+ assert (
|
|
|
+ response.content
|
|
|
+ == b'"You are attempting to use this endpoint too frequently. Limit is 3 requests in 3600 seconds"'
|
|
|
+ )
|