dashboard: return bad request on invalid key given to auto_tile (#51282)
This commit is contained in:
parent
69d97b1c08
commit
61d638ef83
|
@ -133,6 +133,9 @@ def dashboard_auto_tile(request, *args, **kwargs):
|
|||
dashboard = DashboardCell.objects.filter(page__snapshot__isnull=True)[0]
|
||||
cell = ConfigJsonCell(key=kwargs.get('key'), order=1, page_id=dashboard.page_id, placeholder='_auto_tile')
|
||||
|
||||
if cell.key not in settings.JSON_CELL_TYPES:
|
||||
return HttpResponseBadRequest('bad request, invalid cell type: "%s"' % cell.key)
|
||||
|
||||
# only keep parameters that are actually defined for this cell type.
|
||||
cell.parameters = {}
|
||||
for field in settings.JSON_CELL_TYPES[cell.key].get('form') or []:
|
||||
|
|
|
@ -247,6 +247,14 @@ def test_auto_tile(app, site):
|
|||
)
|
||||
assert resp.text.strip() == '/var1=one/var2=/'
|
||||
|
||||
# with invalid cell key
|
||||
resp = app.post(
|
||||
reverse('combo-dashboard-auto-tile', kwargs={'key': 'missing'}),
|
||||
params=json.dumps({'var1': 'one', 'var2': 'two'}),
|
||||
content_type='application/json',
|
||||
status=400,
|
||||
)
|
||||
|
||||
# with missing data
|
||||
resp = app.post(
|
||||
reverse('combo-dashboard-auto-tile', kwargs={'key': 'test-config-json-cell'}),
|
||||
|
|
Loading…
Reference in New Issue