123456789101112131415161718192021222324252627282930 |
- from django.urls import reverse
- from sentry.models import ApiApplication
- from sentry.testutils import APITestCase
- from sentry.testutils.silo import control_silo_test
- @control_silo_test(stable=True)
- class ApiApplicationRotateSecretTest(APITestCase):
- def setUp(self):
- self.app = ApiApplication.objects.create(owner=self.user, name="a")
- self.path = reverse("sentry-api-0-api-application-rotate-secret", args=[self.app.client_id])
- def test_unauthorized_call(self):
- response = self.client.post(self.path)
- assert response.status_code == 403
- def test_invalid_app_id(self):
- self.login_as(self.user)
- path_with_invalid_id = reverse("sentry-api-0-api-application-rotate-secret", args=["abc"])
- response = self.client.post(path_with_invalid_id)
- assert response.status_code == 404
- def test_valid_call(self):
- self.login_as(self.user)
- old_secret = self.app.client_secret
- response = self.client.post(self.path, data={})
- new_secret = response.data["clientSecret"]
- assert len(new_secret) == len(old_secret)
- assert new_secret != old_secret
|