3
0

Fix panicking report filter marshaling when invalid

This commit is contained in:
Tomaž Jerman
2021-12-09 15:55:53 +01:00
parent 08ef5ab104
commit 59ef8da1ac
2 changed files with 50 additions and 1 deletions

View File

@@ -99,7 +99,7 @@ func (t *typedValue) MarshalJSON() ([]byte, error) {
)
if t.V == nil {
return nil, nil
return json.Marshal(aux)
}
aux.Type = t.V.Type()

View File

@@ -104,6 +104,55 @@ func TestReportFilterCasting(t *testing.T) {
End()
}
func TestReportCreate_invalidFilter(t *testing.T) {
h := newHelper(t)
h.clearReports()
helpers.AllowMe(h, types.ComponentRbacResource(), "report.create")
h.apiInit().
Post("/reports/").
Header("Accept", "application/json").
JSON(`{
"handle": "test_report",
"meta": { "name": "Test Report", "description": "" },
"sources": [
{
"meta": {},
"step": {
"load": {
"name": "Load",
"source": "composeRecords",
"definition": {
"module": "test",
"namespace": "test"
},
"columns": null,
"filter": {
"ref": "or",
"args": [
{
"ref": "eq",
"args": [
{ "symbol": "id_str" },
{
"value": { "@type": "", "@value": "" }
}
]
}
]
}
}
}
}
],
"blocks": []
}`).
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
End()
}
func TestReportScenarios_create(t *testing.T) {
h := newHelper(t)
h.clearReports()