diff --git a/ckanext/datapusher/logic/action.py b/ckanext/datapusher/logic/action.py index 1872a1ef265..359fcb3d21f 100644 --- a/ckanext/datapusher/logic/action.py +++ b/ckanext/datapusher/logic/action.py @@ -153,6 +153,7 @@ def datapusher_hook(context, data_dict): task['state'] = status task['last_updated'] = str(datetime.datetime.now()) + context['ignore_auth'] = True p.toolkit.get_action('task_status_update')(context, task) diff --git a/ckanext/datapusher/tests/test.py b/ckanext/datapusher/tests/test.py index 2ec2df42d21..af7488736f6 100644 --- a/ckanext/datapusher/tests/test.py +++ b/ckanext/datapusher/tests/test.py @@ -138,7 +138,7 @@ def test_send_datapusher_creates_task(self): assert task['state'] == 'pending', task - def test_datapusher_hook(self): + def _call_datapusher_hook(self, user): package = model.Package.get('annakarenina') resource = package.resources[0] @@ -163,7 +163,7 @@ def test_datapusher_hook(self): } } postparams = '%s=1' % json.dumps(data) - auth = {'Authorization': str(self.sysadmin_user.apikey)} + auth = {'Authorization': str(user.apikey)} res = self.app.post('/api/action/datapusher_hook', params=postparams, extra_environ=auth, status=200) print res.body @@ -182,3 +182,11 @@ def test_datapusher_hook(self): task_type='datapusher', key='datapusher') assert task['state'] == 'success', task + + def test_datapusher_hook_sysadmin(self): + + self._call_datapusher_hook(self.sysadmin_user) + + def test_datapusher_hook_normal_user(self): + + self._call_datapusher_hook(self.normal_user)