|
7 | 7 |
|
8 | 8 |
|
9 | 9 | class ShortIdLookupEndpointTest(APITestCase): |
10 | | - def test_simple(self) -> None: |
11 | | - org = self.create_organization(owner=self.user) |
12 | | - project = self.create_project(organization=org) |
13 | | - group = self.create_group(project=project, short_id=project.next_short_id()) |
14 | | - |
15 | | - self.login_as(user=self.user) |
16 | | - url = reverse( |
| 10 | + def setUp(self) -> None: |
| 11 | + self.group = self.create_group(project=self.project, short_id=self.project.next_short_id()) |
| 12 | + self.url = reverse( |
17 | 13 | "sentry-api-0-short-id-lookup", |
18 | | - kwargs={"organization_id_or_slug": org.slug, "short_id": group.qualified_short_id}, |
| 14 | + kwargs={ |
| 15 | + "organization_id_or_slug": self.organization.slug, |
| 16 | + "issue_id": self.group.qualified_short_id, |
| 17 | + }, |
19 | 18 | ) |
20 | | - response = self.client.get(url, format="json") |
| 19 | + |
| 20 | + def test_simple(self) -> None: |
| 21 | + self.login_as(user=self.user) |
| 22 | + response = self.client.get(self.url, format="json") |
21 | 23 |
|
22 | 24 | assert response.status_code == 200, response.content |
23 | | - assert response.data["organizationSlug"] == org.slug |
24 | | - assert response.data["projectSlug"] == project.slug |
25 | | - assert response.data["groupId"] == str(group.id) |
26 | | - assert response.data["group"]["id"] == str(group.id) |
| 25 | + assert response.data["organizationSlug"] == self.organization.slug |
| 26 | + assert response.data["projectSlug"] == self.project.slug |
| 27 | + assert response.data["groupId"] == str(self.group.id) |
| 28 | + assert response.data["group"]["id"] == str(self.group.id) |
| 29 | + |
| 30 | + def test_access_non_member_project(self) -> None: |
| 31 | + # disable Open Membership |
| 32 | + self.organization.flags.allow_joinleave = False |
| 33 | + self.organization.save() |
| 34 | + |
| 35 | + # user has no access to the first project |
| 36 | + user_no_team = self.create_user(is_superuser=False) |
| 37 | + self.create_member( |
| 38 | + user=user_no_team, organization=self.organization, role="member", teams=[] |
| 39 | + ) |
| 40 | + self.login_as(user_no_team) |
| 41 | + |
| 42 | + response = self.client.get(self.url, format="json") |
| 43 | + assert response.status_code == 403, response.content |
| 44 | + assert response.data["detail"] == "You do not have permission to perform this action." |
0 commit comments