Fix: more api fixes (#10204)

This commit is contained in:
shamoon
2025-06-19 08:28:41 -07:00
committed by GitHub
parent 0a1786f39b
commit 83391af866
5 changed files with 183 additions and 16 deletions

View File

@@ -1278,3 +1278,34 @@ class TestBulkEditObjectPermissions(APITestCase):
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
class TestFullPermissionsFlag(APITestCase):
def setUp(self):
super().setUp()
self.admin = User.objects.create_superuser(username="admin")
def test_full_perms_flag(self):
"""
GIVEN:
- API request to list documents
WHEN:
- full_perms flag is set to true, 1, false, or a random value
THEN:
- Permissions field is included or excluded accordingly
"""
self.client.force_authenticate(self.admin)
Document.objects.create(title="Doc", checksum="xyz", owner=self.admin)
resp = self.client.get("/api/documents/?full_perms=true")
self.assertIn("permissions", resp.data["results"][0])
resp = self.client.get("/api/documents/?full_perms=1")
self.assertIn("permissions", resp.data["results"][0])
resp = self.client.get("/api/documents/?full_perms=false")
self.assertNotIn("permissions", resp.data["results"][0])
resp = self.client.get("/api/documents/?full_perms=garbage")
self.assertNotIn("permissions", resp.data["results"][0])