From 8fed3ed418e821fb307dcda3d425546f06dbb0be Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Mon, 16 Oct 2023 00:58:47 +0200 Subject: [PATCH 1/3] fix: use pam layer in pam services --- .../services/multilingual/configure.zcml | 4 +++ src/plone/restapi/tests/test_translations.py | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/plone/restapi/services/multilingual/configure.zcml b/src/plone/restapi/services/multilingual/configure.zcml index 58d65c74d3..1928b12de5 100644 --- a/src/plone/restapi/services/multilingual/configure.zcml +++ b/src/plone/restapi/services/multilingual/configure.zcml @@ -21,6 +21,7 @@ for="Products.CMFCore.interfaces.IContentish" permission="zope2.View" name="@translations" + layer="plone.app.multilingual.interfaces.IPloneAppMultilingualInstalled" /> diff --git a/src/plone/restapi/tests/test_translations.py b/src/plone/restapi/tests/test_translations.py index c32f72eff8..a8fa3bdd61 100644 --- a/src/plone/restapi/tests/test_translations.py +++ b/src/plone/restapi/tests/test_translations.py @@ -9,6 +9,7 @@ from plone.restapi.bbb import ILanguage from plone.restapi.testing import PLONE_RESTAPI_DX_PAM_FUNCTIONAL_TESTING from plone.restapi.testing import PLONE_RESTAPI_DX_PAM_INTEGRATION_TESTING +from plone.restapi.testing import PLONE_RESTAPI_DX_FUNCTIONAL_TESTING from zope.component import getMultiAdapter from zope.interface import alsoProvides @@ -374,3 +375,30 @@ def test_translation_locator(self): self.assertEqual(200, response.status_code) self.assertEqual(self.portal_url + "/de", response.json().get("@id")) + + +class TestPAMNotinstalled(unittest.TestCase): + layer = PLONE_RESTAPI_DX_FUNCTIONAL_TESTING + + def setUp(self): + self.portal = self.layer["portal"] + self.request = self.layer["request"] + login(self.portal, SITE_OWNER_NAME) + self.folder = createContentInContainer(self.portal, "Folder", title="Folder") + transaction.commit() + + def test_translations(self): + response = requests.get( + f"{self.folder.absolute_url()}/@translations", + headers={"Accept": "application/json"}, + auth=(SITE_OWNER_NAME, SITE_OWNER_PASSWORD), + ) + self.assertEqual(404, response.status_code) + + def test_translation_locator(self): + response = requests.get( + f"{self.folder.absolute_url()}/@translation-locator", + headers={"Accept": "application/json"}, + auth=(SITE_OWNER_NAME, SITE_OWNER_PASSWORD), + ) + self.assertEqual(404, response.status_code) From 67abd2d99c8c3a9ac395b98b922eba9169d7631c Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Mon, 16 Oct 2023 01:06:56 +0200 Subject: [PATCH 2/3] zpretty --- src/plone/restapi/services/multilingual/configure.zcml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plone/restapi/services/multilingual/configure.zcml b/src/plone/restapi/services/multilingual/configure.zcml index 1928b12de5..8eec6946c0 100644 --- a/src/plone/restapi/services/multilingual/configure.zcml +++ b/src/plone/restapi/services/multilingual/configure.zcml @@ -20,8 +20,8 @@ factory=".pam.TranslationInfo" for="Products.CMFCore.interfaces.IContentish" permission="zope2.View" - name="@translations" layer="plone.app.multilingual.interfaces.IPloneAppMultilingualInstalled" + name="@translations" /> From 1744dfe21e9dc2c221c260c56df8c560bb706e22 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Mon, 16 Oct 2023 01:08:23 +0200 Subject: [PATCH 3/3] changelog --- news/1723.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/1723.bugfix diff --git a/news/1723.bugfix b/news/1723.bugfix new file mode 100644 index 0000000000..dc682e57c5 --- /dev/null +++ b/news/1723.bugfix @@ -0,0 +1 @@ +limits the use of multilingual services only if multilingual is actually installed. @mamico