From c5d7447059dbae85af458db5023045a46c7da8d9 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Thu, 17 Jun 2021 10:43:28 +0200 Subject: [PATCH] Copy schema field to destination metadata (fixes #518) --- CHANGELOG.rst | 4 ++++ kinto_signer/updater.py | 5 +++-- tests/test_signoff_flow.py | 9 ++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0616fb62..1caf3a45 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,6 +10,10 @@ This document describes changes between each past release. - Removed ability to resign using ``to-sign`` twice. Use to ``to-resign`` instead. +**New feature** + +- Copy ``schema`` field to destination metadata (fixes #518) + **Bug fixes** - Reset the editor/reviewer comments when not specified. diff --git a/kinto_signer/updater.py b/kinto_signer/updater.py index 5613faa5..7976454e 100644 --- a/kinto_signer/updater.py +++ b/kinto_signer/updater.py @@ -19,6 +19,8 @@ FIELD_ID = "id" FIELD_LAST_MODIFIED = "last_modified" +# Source collection fields to be copied to destination. +PUBLISHED_COLLECTION_FIELDS = ("schema", "sort", "displayFields", "attachment") class TRACKING_FIELDS(Enum): @@ -371,8 +373,7 @@ def set_destination_signature(self, signature, source_attributes, request): new_collection = dict(**collection_record) new_collection.pop(FIELD_LAST_MODIFIED, None) new_collection["signature"] = signature - # Copy some Kinto-Admin UI attributes from source to destination. - for attr in ("sort", "displayFields", "attachment"): + for attr in PUBLISHED_COLLECTION_FIELDS: if attr in source_attributes: new_collection.setdefault(attr, source_attributes[attr]) diff --git a/tests/test_signoff_flow.py b/tests/test_signoff_flow.py index c9e1680e..6cdf347e 100644 --- a/tests/test_signoff_flow.py +++ b/tests/test_signoff_flow.py @@ -904,12 +904,19 @@ def test_the_preview_collection_is_updated_and_signed(self): def test_the_preview_collection_receives_kinto_admin_ui_attributes(self): self.app.patch_json( self.source_collection, - {"data": {"status": "to-review", "displayFields": ["age"]}}, + { + "data": { + "status": "to-review", + "displayFields": ["age"], + "schema": {"type": "object"}, + } + }, headers=self.headers, ) resp = self.app.get(self.preview_collection, headers=self.headers) assert resp.json["data"]["displayFields"] == ["age"] + assert "schema" in resp.json["data"] def test_the_preview_collection_is_also_resigned(self): self.app.patch_json(