summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2019-06-02 16:11:10 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2019-06-03 10:30:13 (GMT)
commit6439c43b482c393320295aa5e0f59c4f317ecfd9 (patch)
tree0455c231f565babcc0fbf68a941ca7f654362468
parent0863f0fa7af92e79e03882d94108e31fca8c0f7c (diff)
downloadcombo-6439c43b482c393320295aa5e0f59c4f317ecfd9.zip
combo-6439c43b482c393320295aa5e0f59c4f317ecfd9.tar.gz
combo-6439c43b482c393320295aa5e0f59c4f317ecfd9.tar.bz2
wcs: raise a bad request when tracking code is missing from request (#33079)
-rw-r--r--combo/apps/wcs/views.py2
-rw-r--r--tests/test_wcs.py3
2 files changed, 5 insertions, 0 deletions
diff --git a/combo/apps/wcs/views.py b/combo/apps/wcs/views.py
index 685cba4..80d470a 100644
--- a/combo/apps/wcs/views.py
+++ b/combo/apps/wcs/views.py
@@ -60,6 +60,8 @@ class TrackingCodeView(View):
cell = TrackingCodeInputCell.objects.get(id=request.POST['cell'])
except (KeyError, ValueError, TrackingCodeInputCell.DoesNotExist):
return HttpResponseBadRequest('Invalid cell id')
+ if not 'code' in request.POST:
+ return HttpResponseBadRequest('Missing code')
code = request.POST['code']
url = self.search(code, wcs_site=cell.wcs_site)
diff --git a/tests/test_wcs.py b/tests/test_wcs.py
index 7bdc60c..244bbb4 100644
--- a/tests/test_wcs.py
+++ b/tests/test_wcs.py
@@ -14,6 +14,7 @@ import os
from django.apps import apps
from django.conf import settings
from django.core.cache import cache
+from django.core.urlresolvers import reverse
from django.test import override_settings
from django.test.client import RequestFactory
from django.utils.six.moves.urllib import parse as urlparse
@@ -668,6 +669,8 @@ def test_tracking_code_cell(app):
resp.form['code'] = 'CNPHNTFB'
resp = resp.form.submit(status=400)
+ resp = app.post(reverse('wcs-tracking-code'), params={'cell': cell.id}, status=400)
+
@wcsctl_present
def test_cell_assets(app, admin_user):
page = Page(title='xxx', slug='test_cell_assets', template_name='standard')