Skip to content

Commit

Permalink
Merge branch 'main' into test_different_image_scales_in_serialization…
Browse files Browse the repository at this point in the history
…_and_catalog
  • Loading branch information
davisagli authored Oct 28, 2023
2 parents 654e724 + 5f92149 commit 61951e5
Show file tree
Hide file tree
Showing 22 changed files with 372 additions and 168 deletions.
31 changes: 16 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Tests
on: [push,pull_request]
on: [push, pull_request]
jobs:
build:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
Expand All @@ -8,19 +8,20 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: '3.7'
plone-version: '5.2'
- python-version: '3.8'
plone-version: '5.2'
- python-version: '3.8'
plone-version: '6.0'
- python-version: '3.9'
plone-version: '6.0'
- python-version: '3.10'
plone-version: '6.0'
- python-version: '3.11'
plone-version: '6.0'

- python-version: "3.7"
plone-version: "5.2"
- python-version: "3.8"
plone-version: "5.2"
- python-version: "3.8"
plone-version: "6.0"
- python-version: "3.9"
plone-version: "6.0"
- python-version: "3.10"
plone-version: "6.0"
- python-version: "3.11"
plone-version: "6.0"
- python-version: "3.12"
plone-version: "6.0"
steps:
# git checkout
- uses: actions/checkout@v3
Expand All @@ -30,7 +31,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache: "pip"

# buildout eggs cache
- uses: actions/cache@v3
Expand Down
46 changes: 43 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,46 @@ Changelog
.. towncrier release notes start
9.1.1 (2023-10-28)
------------------

Bug fixes:


- Be more strict when checking if mimetype is allowed to be displayed inline.
[maurits] (#1167)


9.1.0 (2023-10-18)
------------------

New features:


- Add support for Python 3.12. @tisto (#1722)


Bug fixes:


- Treat sub-items like items in ``@linkintegrity`` endpoint. @jaroel (#1714)
- Limits the use of multilingual services only if multilingual is actually installed. @mamico (#1723)


Internal:


- Remove unused code. @davisagli (#1703)
- Replace deprecated assert methods. @gforcada (#1719)
- Drop, already unused plone.app.robotframework test. @gforcada (#1720)


Documentation:


- Fix redirect for https://json-schema.org/. @stevepiercy (#1718)


9.0.0 (2023-09-23)
------------------

Expand Down Expand Up @@ -461,9 +501,9 @@ Bug fixes:


- Added url field to Actions (#817)
- Update statictime tests following changes to p.a.disucssion (see
https://github.com/plone/plone.app.discussion/pull/204) - [instification] (#1520)
- Update @portrait endpoint to use sanitized user id [instification] (#1524)
- Updated ``statictime`` tests following changes to ``p.a.discussion`` (see
https://github.com/plone/plone.app.discussion/pull/204). @instification (#1520)
- Updated ``@portrait`` endpoint to use sanitized user id. @instification (#1524)


8.31.0 (2022-10-20)
Expand Down
2 changes: 0 additions & 2 deletions base.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ allow-hosts =
files.pythonhosted.org
launchpad.net
code.google.com
robotframework.googlecode.com

[versions]
# Do not use a release of plone.restapi:
Expand All @@ -42,7 +41,6 @@ debug-exceptions = on
eggs =
Plone
Pillow
plone.app.debugtoolbar
plone.restapi [test]
environment-vars =
zope_i18n_compile_mo_files true
Expand Down
2 changes: 1 addition & 1 deletion docs/source/endpoints/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ To get the schema of a content type, access the `/@types` endpoint with the name
:language: http
```

The content type schema uses the [JSON Schema](http://json-schema.org/) format.
The content type schema uses the [JSON Schema](https://json-schema.org/) format.
The tagged values for the widgets are also exposed in the `properties` attribute of the schema.

For `Choice` fields, their vocabulary or source will be linked to in a `vocabulary` or `querysource` property (one or the other, never both):
Expand Down
3 changes: 2 additions & 1 deletion plone-5.2.x.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ extends =
black = 22.3.0

# we need the newest plone.rest release
plone.rest = 3.0.1
plone.rest = 3.0.1
plone.app.linkintegrity = 3.6.2
6 changes: 6 additions & 0 deletions plone-6.0.x.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ zodb-temporary-storage = off
[versions]
black = 22.3.0
pygments = 2.14.0
plone.app.linkintegrity = 4.0.3
robotframework-browser = 17.5.2
robotframework-assertion-engine = 2.0.0
robotframework-debuglibrary = 2.3.0
robotframework-pythonlibcore = 4.2.0
grpcio-tools = 1.59.0
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys


version = "9.0.1.dev0"
version = "9.1.2.dev0"

if sys.version_info.major == 2:
raise ValueError(
Expand Down Expand Up @@ -42,9 +42,8 @@ def read(filename):
TEST_REQUIRES = [
"collective.MockMailHost",
"plone.app.caching",
"plone.app.contenttypes",
"plone.app.robotframework",
"plone.app.testing [robot] >= 4.2.2", # ROBOT_TEST_LEVEL added
"plone.app.contenttypes[test]",
"plone.app.testing",
"plone.api",
"requests",
"mock",
Expand All @@ -71,6 +70,7 @@ def read(filename):
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Software Development :: Libraries :: Python Modules",
],
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/services/linkintegrity/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def reply(self):
data = getMultiAdapter((item, self.request), ISerializeToJsonSummary)()
data["breaches"] = []
for breach in breaches:
if breach["target"]["uid"] not in uids:
uids.append(breach["target"]["uid"])
continue
for source in breach.get("sources", []):
# remove unwanted data
source["@id"] = source["url"]
Expand Down
4 changes: 4 additions & 0 deletions src/plone/restapi/services/multilingual/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
factory=".pam.TranslationInfo"
for="Products.CMFCore.interfaces.IContentish"
permission="zope2.View"
layer="plone.app.multilingual.interfaces.IPloneAppMultilingualInstalled"
name="@translations"
/>
<cache:ruleset
Expand All @@ -33,6 +34,7 @@
factory=".pam.LinkTranslations"
for="Products.CMFCore.interfaces.IContentish"
permission="plone.app.multilingual.ManageTranslations"
layer="plone.app.multilingual.interfaces.IPloneAppMultilingualInstalled"
name="@translations"
/>

Expand All @@ -41,6 +43,7 @@
factory=".pam.UnlinkTranslations"
for="Products.CMFCore.interfaces.IContentish"
permission="plone.app.multilingual.ManageTranslations"
layer="plone.app.multilingual.interfaces.IPloneAppMultilingualInstalled"
name="@translations"
/>

Expand All @@ -49,6 +52,7 @@
factory=".locator.TranslationLocator"
for="Products.CMFCore.interfaces.IContentish"
permission="plone.app.multilingual.ManageTranslations"
layer="plone.app.multilingual.interfaces.IPloneAppMultilingualInstalled"
name="@translation-locator"
/>

Expand Down
2 changes: 0 additions & 2 deletions src/plone/restapi/services/navigation/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ def render_item(self, item, path):

item.update({"items": sub})

if "title" in item and item["title"]:
item["title"] = item["title"]
if "path" in item:
del item["path"]
return item
Expand Down
29 changes: 26 additions & 3 deletions src/plone/restapi/services/users/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,31 @@

DEFAULT_SEARCH_RESULTS_LIMIT = 25

try:
# Zope 5.8.4+
from OFS.Image import extract_media_type as _extract_media_type
except ImportError:
try:
from plone.namedfile.utils import extract_media_type as _extract_media_type
except ImportError:
# Note that we start the method with an underscore, to signal that this
# is a private implementation detail and no one should be importing this.

def _extract_media_type(content_type):
"""extract the proper media type from *content_type*.
Ignore parameters and whitespace and normalize to lower case.
See https://github.com/zopefoundation/Zope/pull/1167
"""
if not content_type:
return content_type
# ignore parameters
content_type = content_type.split(";", 1)[0]
# ignore whitespace
content_type = "".join(content_type.split())
# normalize to lowercase
return content_type.lower()


def getPortraitUrl(user):
if not user:
Expand Down Expand Up @@ -84,7 +109,6 @@ def _sort_users(users: Iterable[MemberData]) -> Sequence[MemberData]:
def _principal_search_results(
self, search_for_principal, get_principal_by_id, principal_type, id_key
):

hunter = getMultiAdapter((self.context, self.request), name="pas_search")

principals = []
Expand Down Expand Up @@ -209,7 +233,6 @@ def reply(self):
if self.has_permission_to_access_user_info() or (
current_user_id and current_user_id == self._get_user_id
):

# we retrieve the user on the user id not the username
user = self._get_user(self._get_user_id)
if not user:
Expand Down Expand Up @@ -251,7 +274,7 @@ def _get_user_id(self):

def _should_force_download(self, portrait):
# If this returns True, the caller should set the Content-Disposition header.
mimetype = portrait.content_type
mimetype = _extract_media_type(portrait.content_type)
if not mimetype:
return False
if self.use_denylist:
Expand Down
22 changes: 0 additions & 22 deletions src/plone/restapi/tests/robot/test.robot

This file was deleted.

8 changes: 4 additions & 4 deletions src/plone/restapi/tests/test_batching.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def test_first_link_contained(self):

self.request.form["b_size"] = 10
batch = HypermediaBatch(self.request, items)
self.assertDictContainsSubset({"first": "http://nohost?b_start=0"}, batch.links)
self.assertEqual(batch.links["first"], "http://nohost?b_start=0")

def test_first_link_preserves_list_like_querystring_params(self):
items = list(range(1, 26))
Expand All @@ -478,14 +478,14 @@ def test_last_link_contained(self):

self.request.form["b_size"] = 10
batch = HypermediaBatch(self.request, items)
self.assertDictContainsSubset({"last": "http://nohost?b_start=20"}, batch.links)
self.assertEqual(batch.links["last"], "http://nohost?b_start=20")

def test_next_link_contained_if_necessary(self):
items = list(range(1, 26))

self.request.form["b_size"] = 10
batch = HypermediaBatch(self.request, items)
self.assertDictContainsSubset({"next": "http://nohost?b_start=10"}, batch.links)
self.assertEqual(batch.links["next"], "http://nohost?b_start=10")

def test_next_link_omitted_on_last_page(self):
items = list(range(1, 26))
Expand All @@ -503,7 +503,7 @@ def test_prev_link_contained_if_necessary(self):
self.request.form["b_size"] = 10
self.request.form["b_start"] = 20
batch = HypermediaBatch(self.request, items)
self.assertDictContainsSubset({"prev": "http://nohost?b_start=10"}, batch.links)
self.assertEqual(batch.links["prev"], "http://nohost?b_start=10")

def test_prev_link_omitted_on_first_page(self):
items = list(range(1, 26))
Expand Down
10 changes: 4 additions & 6 deletions src/plone/restapi/tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ def test_unauthorized_if_missing_permission(self):

response = self.api_session.get(self.portal_url)
self.assertEqual(response.status_code, 401)
self.assertDictContainsSubset(
{
"type": "Unauthorized",
"message": "Missing 'plone.restapi: Use REST API' permission",
},
response.json(),
data = response.json()
self.assertEqual(data["type"], "Unauthorized")
self.assertEqual(
data["message"], "Missing 'plone.restapi: Use REST API' permission"
)
28 changes: 0 additions & 28 deletions src/plone/restapi/tests/test_robot.py.txt

This file was deleted.

Loading

0 comments on commit 61951e5

Please sign in to comment.