fix: Prevent jsonpath from causing panic when body is expected to be array but isn't (#392)

* fix: Prevent jsonpath from causing panic when body is expected to be array but isn't

Fixes #391
This commit is contained in:
TwiN authored and GitHub committed 2022-12-23 09:55:17 -05:00
1 parent a81a83e2d4
commit 947173bf71
2 files changed
+9 -2

No files matched your search

+7
View File
@@ -231,6 +231,13 @@ func TestCondition_evaluate(t *testing.T) {
ExpectedSuccess: true,
ExpectedOutput: "[BODY][0].id == 1",
},
{
Name: "body-jsonpath-when-body-is-array-but-actual-body-is-not",
Condition: Condition("[BODY][0].name == test"),
Result: &Result{body: []byte("{\"statusCode\": 500, \"message\": \"Internal Server Error\"}")},
ExpectedSuccess: false,
ExpectedOutput: "[BODY][0].name (INVALID) == test",
},
{
Name: "body-jsonpath-complex-int",
Condition: Condition("[BODY].data.id == 1"),