From 9a2350b7eb39b82d230c94c9cf0909968c6e5e7f Mon Sep 17 00:00:00 2001 From: Hung Le Date: Sun, 24 Dec 2017 16:08:54 +0700 Subject: [PATCH 1/4] Oplog skipped even if confg.OPLOG=True Check for resource name validity is being reversed. Closes #1074. --- eve/methods/common.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eve/methods/common.py b/eve/methods/common.py index 2ffb666a9..036fd8020 100644 --- a/eve/methods/common.py +++ b/eve/methods/common.py @@ -1234,7 +1234,7 @@ def oplog_push(resource, document, op, id=None): 'r' = resource endpoint, 'o' = operation performed, 'i' = unique id of the document involved, - 'pi' = client IP, + 'ip' = client IP, 'c' = changes config.LAST_UPDATED, config.LAST_CREATED and AUTH_FIELD are not being @@ -1258,9 +1258,10 @@ def oplog_push(resource, document, op, id=None): .. versionadded:: 0.5 """ + if not config.OPLOG \ or op not in config.OPLOG_METHODS\ - or resource in config.URLS[resource]: + or resource not in config.URLS: return resource_def = config.DOMAIN[resource] From eed600260484b7cc638cc0c47a58ef44bc8488dd Mon Sep 17 00:00:00 2001 From: Nicola Iarocci Date: Fri, 30 Mar 2018 10:51:08 +0200 Subject: [PATCH 2/4] Regression test for PR #1095. The original test was a false positive. --- eve/tests/methods/common.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/eve/tests/methods/common.py b/eve/tests/methods/common.py index 16497d528..09954e1d2 100644 --- a/eve/tests/methods/common.py +++ b/eve/tests/methods/common.py @@ -653,10 +653,12 @@ def oplog_callback(resource, entries): self.assertTrue('customvalue' in oplog_entry['extra']['customfield']) def test_post_oplog(self): - r = self.test_client.post(self.known_resource_url, - data=json.dumps(self.data), - headers=self.headers, - environ_base={'REMOTE_ADDR': '127.0.0.1'}) + r = self.test_client.post( + self.different_resource_url, + data=json.dumps({'username': 'test', 'ref': + '1234567890123456789012345' }), + headers=self.headers, environ_base={'REMOTE_ADDR': '127.0.0.1'}) + r, status = self.oplog_get() self.assert200(status) self.assertEqual(len(r['_items']), 1) From 795abe9154448468c3036dc80e5b8a9ac0407eb3 Mon Sep 17 00:00:00 2001 From: Nicola Iarocci Date: Fri, 30 Mar 2018 10:53:36 +0200 Subject: [PATCH 3/4] Changelog for #1095. --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index f9bb9808a..21f13870d 100644 --- a/CHANGES +++ b/CHANGES @@ -8,6 +8,7 @@ Development Version 0.8 ~~~~~~~~~~~ +- Fix: OPLOG skipped even if ``OPLOG = True``. Closes 1074 (Hung Le). - Fix: Cannot define default projection and request specific field. Closes #1036 (DHuan). - Dev: pin testfixtures to v5.x as latest releases break on Python 2.6. From 91edb11c2d2112c5f8d5468b77b8f83ff4d6ef66 Mon Sep 17 00:00:00 2001 From: Nicola Iarocci Date: Fri, 30 Mar 2018 10:54:20 +0200 Subject: [PATCH 4/4] Hung Le --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index eb4bd2ec3..26c4c3917 100644 --- a/AUTHORS +++ b/AUTHORS @@ -64,6 +64,7 @@ Patches and Contributions - Henrique Barroso - Huan Di - Hugo Larcher +- Hung Le - James Stewart - Jaroslav Semančík - Javier Gonel