citrusframework / citrusframework/citrus

.validate method using JSON path will accept any invalid expected value

Open
#731 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
485
Forks
155
Avg merge
4d 22h
Merged PRs (30d)
6

Description

**Citrus Version**
2.7.2

**Expected behavior**
expected to fail when expected value is set to any junk/random value when using a valid JSON path

**Actual behavior**
passes no matter what the expected value is set as

**Test case sample**
> Please, share the test case (as small as possible) which shows the issue
response body:
[
{
"key": 111,
"apuSerial": "NGE",
"fullApuSerial": "BENSAPUCHANGE",
"manufacturerCode": "123",
"oemPartNum": "123",
"tail": "tail",
"comment": "123",
"tags": "123",
"user": "ben",
"createTimeStamp": "2020-09-25T10:08:32.9433333-04:00",
"updateTimeStamp": "2020-09-25T10:11:23.042-04:00"
}
]

testPostJson(endpoint, searchBody).validate("$[:1].apuSerial", "chicken")

have tried json path as $..apuSerial as well, both tested to be valid using Insomnia

have also upped citrus version number to see if fixed in later releases

used testPostJson method:

protected HttpClientResponseActionBuilder testPostJson(String path, ClassPathResource payload){
basePostRequestBuilder(path)
.payload(payload);
return http()
.client(httpClient)
.receive()
.response(HttpStatus.OK)
.messageType(MessageType.JSON);
}

Contributor guide

Open the contributing guide

Research direction

Start with the JSON-path validation used by .validate and reproduce the report through testPostJson using the supplied response body and path "$[:1].apuSerial". The work is done when an invalid expected value such as "chicken" fails validation while a matching value succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.