Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: @querystring shouldn't list userids #1824

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Create test_querystring_get.py
askadityapandey authored Oct 16, 2024
commit 7ca1c38674f801db8c8c966affde838430f6cd47
27 changes: 27 additions & 0 deletions src/plone/restapi/tests/test_querystring_get.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from plone.app.testing import PLONE_RESTAPI_FUNCTIONAL_TESTING
from plone.restapi.testing import RelativeSession
import unittest

class TestQuerystringGet(unittest.TestCase):

layer = PLONE_RESTAPI_FUNCTIONAL_TESTING

def setUp(self):
self.portal = self.layer["portal"]
self.api_session = RelativeSession(self.portal.absolute_url())
self.api_session.headers.update({"Accept": "application/json"})

def test_vocabularies_permission_filtering(self):
response = self.api_session.get("/@querystring")
self.assertEqual(response.status_code, 200)
result = response.json()

# Assert that a sensitive vocabulary is filtered out
self.assertNotIn('plone.app.vocabularies.Users', result['indexes'])
self.assertNotIn('plone.app.vocabularies.Groups', result['indexes'])

# Assert that public vocabularies are still present
self.assertIn('plone.app.vocabularies.Keywords', result['indexes'])

def tearDown(self):
self.api_session.close()