|
@@ -234,6 +234,25 @@ class OrganizationDashboardDetailsDeleteTest(OrganizationDashboardDetailsTestCas
|
|
|
self.create_user_member_role()
|
|
|
self.test_delete()
|
|
|
|
|
|
+ def test_disallow_delete_when_no_project_access(self):
|
|
|
+ # disable Open Membership
|
|
|
+ self.organization.flags.allow_joinleave = False
|
|
|
+ self.organization.save()
|
|
|
+
|
|
|
+ # assign a project to a dashboard
|
|
|
+ self.dashboard.projects.set([self.project])
|
|
|
+
|
|
|
+ # user has no access to the above project
|
|
|
+ user_no_team = self.create_user(is_superuser=False)
|
|
|
+ self.create_member(
|
|
|
+ user=user_no_team, organization=self.organization, role="member", teams=[]
|
|
|
+ )
|
|
|
+ self.login_as(user_no_team)
|
|
|
+
|
|
|
+ response = self.do_request("delete", self.url(self.dashboard.id))
|
|
|
+ assert response.status_code == 403
|
|
|
+ assert response.data == {"detail": "You do not have permission to perform this action."}
|
|
|
+
|
|
|
def test_dashboard_does_not_exist(self):
|
|
|
response = self.do_request("delete", self.url(1234567890))
|
|
|
assert response.status_code == 404
|
|
@@ -338,6 +357,27 @@ class OrganizationDashboardDetailsPutTest(OrganizationDashboardDetailsTestCase):
|
|
|
assert response.status_code == 409, response.data
|
|
|
assert list(response.data) == ["Dashboard with that title already exists."]
|
|
|
|
|
|
+ def test_disallow_put_when_no_project_access(self):
|
|
|
+ # disable Open Membership
|
|
|
+ self.organization.flags.allow_joinleave = False
|
|
|
+ self.organization.save()
|
|
|
+
|
|
|
+ # assign a project to a dashboard
|
|
|
+ self.dashboard.projects.set([self.project])
|
|
|
+
|
|
|
+ # user has no access to the above project
|
|
|
+ user_no_team = self.create_user(is_superuser=False)
|
|
|
+ self.create_member(
|
|
|
+ user=user_no_team, organization=self.organization, role="member", teams=[]
|
|
|
+ )
|
|
|
+ self.login_as(user_no_team)
|
|
|
+
|
|
|
+ response = self.do_request(
|
|
|
+ "put", self.url(self.dashboard.id), data={"title": "Dashboard Hello"}
|
|
|
+ )
|
|
|
+ assert response.status_code == 403, response.data
|
|
|
+ assert response.data == {"detail": "You do not have permission to perform this action."}
|
|
|
+
|
|
|
def test_add_widget(self):
|
|
|
data: dict[str, Any] = {
|
|
|
"title": "First dashboard",
|