-
Notifications
You must be signed in to change notification settings - Fork 420
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
JSON validation crash on missing array minItems property #1243
Labels
Comments
strange I could reproduce locally with build-hub stuff but not from tests with the exact same data: diff --git a/tests/test_views_collections_schema.py b/tests/test_views_collections_schema.py
index c88c5a8f..a66a4615 100644
--- a/tests/test_views_collections_schema.py
+++ b/tests/test_views_collections_schema.py
@@ -180,6 +180,169 @@ class RecordsValidationTest(BaseWebTestWithSchema, unittest.TestCase):
self.assertEqual(len(resp.json['data']), 1)
+class RequiredProperties(BaseWebTestWithSchema, unittest.TestCase):
+
+ def setUp(self):
+ super().setUp()
+ schema = {
+ "additionalProperties": False,
+ "description": "Mozilla software releases.",
+ "properties": {
+ "build": {
+ "additionalProperties": False,
+ "properties": {
+ "date": {
+ "description": "i.e: 2017-04-13T21:49:00Z",
+ "format": "date-time",
+ "title": "Build date",
+ "type": "string"
+ },
+ "id": {
+ "description": "Build ID",
+ "title": "Build ID",
+ "type": "string"
+ }
+ },
+ "type": "object"
+ },
+ "download": {
+ "additionalProperties": False,
+ "properties": {
+ "date": {
+ "description": "Date of the archive",
+ "format": "date-time",
+ "title": "Date",
+ "type": "string"
+ },
+ "mimetype": {
+ "title": "Archive's mimetype",
+ "type": "string"
+ },
+ "size": {
+ "description": "Size of the archive in bytes",
+ "title": "Size",
+ "type": "integer"
+ },
+ "url": {
+ "description": "URL of the archive",
+ "title": "URL",
+ "type": "string"
+ }
+ },
+ "required": [
+ "url",
+ "mimetype",
+ "size",
+ "date"
+ ],
+ "type": "object"
+ },
+ "source": {
+ "additionalProperties": False,
+ "properties": {
+ "product": {
+ "description": "Product name",
+ "title": "Product",
+ "type": "string"
+ },
+ "repository": {
+ "title": "Repository",
+ "type": "string"
+ },
+ "revision": {
+ "title": "Revision number in the tree",
+ "type": "string"
+ },
+ "tree": {
+ "description": "i.e mozilla-central",
+ "title": "Tree",
+ "type": "string"
+ }
+ },
+ "required": [
+ "product"
+ ],
+ "type": "object"
+ },
+ "systemaddons": {
+ "items": {
+ "additionalProperties": False,
+ "properties": {
+ "builtin": {
+ "description": "Version in release",
+ "title": "Built in version",
+ "type": "string"
+ },
+ "id": {
+ "title": "ID",
+ "type": "string"
+ },
+ "updated": {
+ "description": "Last update version",
+ "title": "Updated version",
+ "type": "string"
+ }
+ },
+ "required": [
+ "id",
+ "builtin",
+ "updated"
+ ],
+ "type": "object"
+ },
+ "title": "Systemaddons",
+ "type": "array"
+ },
+ "target": {
+ "additionalProperties": False,
+ "properties": {
+ "channel": {
+ "title": "Update channel",
+ "type": "string"
+ },
+ "locale": {
+ "title": "Locale",
+ "type": "string"
+ },
+ "platform": {
+ "description": "Operating system and Architecture",
+ "title": "Platform",
+ "type": "string"
+ },
+ "version": {
+ "title": "Version",
+ "type": "string"
+ }
+ },
+ "required": [
+ "platform",
+ "locale",
+ "version",
+ "channel"
+ ],
+ "type": "object"
+ }
+ },
+ "required": [
+ "id",
+ "source",
+ "download",
+ "target"
+ ],
+ "title": "Release",
+ "type": "object"
+ }
+ resp = self.app.put_json(COLLECTION_URL,
+ {'data': {'schema': schema}},
+ headers=self.headers)
+
+ def test_reproduce_1243(self):
+ record = {'download': {'size': 35420548, 'url': 'https://archive.mozilla.org/pub/mobile/nightly/2017/05/2017-05-02-10-02-40-mozilla-central-android-api-15-l10n/fennec-55.0a1.gl.android-arm.apk', 'date': '2017-05-02T12:01:11Z', 'mimetype': 'application/vnd.android.package-archive'}, 'id': 'fennec_2017-05-02-10-02-40_55-0a1_android-arm_gl', 'target': {'version': '55.0a1', 'platform': 'android-arm', 'locale': 'gl', 'channel': 'nightly'}, 'source': {'product': 'fennec'}}
+ self.app.put_json(COLLECTION_URL + "/records/" + record["id"],
+ {'data': record},
+ headers=self.headers)
+
+
class ExtraPropertiesValidationTest(BaseWebTestWithSchema, unittest.TestCase):
def setUp(self):
super().setUp() |
leplatrem
added a commit
that referenced
this issue
May 31, 2017
leplatrem
added a commit
that referenced
this issue
May 31, 2017
leplatrem
added a commit
that referenced
this issue
May 31, 2017
Fix jsonschema validation crash with unknown required properties (fixes #1243)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: