Add ObjectMapper unescaping ASCII control characters when using DTOs#1429
Add ObjectMapper unescaping ASCII control characters when using DTOs#1429
Conversation
core/src/main/kotlin/org/evomaster/core/output/dto/JavaDtoOutput.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/org/evomaster/core/output/dto/JavaDtoOutput.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/org/evomaster/core/output/dto/KotlinDtoOutput.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/org/evomaster/core/output/service/TestSuiteWriter.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/org/evomaster/core/output/service/TestSuiteWriter.kt
Outdated
Show resolved
Hide resolved
|
Ready for re-review @arcuri82! |
| * Control characters break JSON and transform it into an invalid payload. If there's any invalid character | ||
| * then we'll avoid using DTOs and have the payload in the test case be represented by the raw JSON string. | ||
| */ | ||
| private fun payloadIsValidJson(bodyParam: BodyParam): Boolean { |
There was a problem hiding this comment.
this function, or parts of it (if taking as input a string and not a BodyParam), should go to org.evomaster.core.output.JsonUtils . also, we need unit tests for it, to make sure it works (eg, you can re-use the exact same JSON payload that was failing the E2E test)
There was a problem hiding this comment.
actually, looks like there is also a TestWriterUtils in the same package having functions for JSON, including a call to OutputFormatter.JSON_FORMATTER.isValid(json) where the same type of check is done. maybe better to call that directly
| * Control characters break JSON and transform it into an invalid payload. If there's any invalid character | ||
| * then we'll avoid using DTOs and have the payload in the test case be represented by the raw JSON string. | ||
| */ | ||
| private fun payloadIsValidJson(bodyParam: BodyParam): Boolean { |
There was a problem hiding this comment.
actually, looks like there is also a TestWriterUtils in the same package having functions for JSON, including a call to OutputFormatter.JSON_FORMATTER.isValid(json) where the same type of check is done. maybe better to call that directly
arcuri82
left a comment
There was a problem hiding this comment.
what happened to the also, we need unit tests for it, to make sure it works (eg, you can re-use the exact same JSON payload that was failing the E2E test) ? :)
Sorry!! Had missed that comment! Just pushed |
ASCII control characters were being escaped by Jackson when using DTOs. Control characters in a JSON payload generate an invalid payload, which was being tested by EvoMaster. As such, we created a custom object mapper that will not escape the ASCII control characters, allowing for incorrect payloads to be tested.