SeUniVr / RestTestGen

A framework for automated black-box testing of RESTful APIs.
Apache License 2.0
36 stars 9 forks source link

it went wrong when adding header value because of okhttp #26

Open maeve13 opened 3 weeks ago

maeve13 commented 3 weeks ago

when I try to test harbor an error occurred.The The error message is: 02:55:44.446 [main] ERROR io.resttestgen.boot.cli.App - An error occurred during the execution of RestTestGen. Please report it on GitHub. java.lang.IllegalArgumentException: Unexpected char 0xe0 at 9 in X-Request-Id value: jV02VKE6Rà at okhttp3.Headers$Companion.checkValue(Headers.kt:450) at okhttp3.Headers$Companion.access$checkValue(Headers.kt:362) at okhttp3.Headers$Builder.set(Headers.kt:344) at okhttp3.Request$Builder.header(Request.kt:199) at io.resttestgen.core.helper.RequestManager.lambda$requestBuilder$3(RequestManager.java:168) at java.base/java.lang.Iterable.forEach(Iterable.java:75) at io.resttestgen.core.helper.RequestManager.requestBuilder(RequestManager.java:167) at io.resttestgen.core.helper.RequestManager.buildRequest(RequestManager.java:51) at io.resttestgen.core.testing.TestRunner.executeTestInteraction(TestRunner.java:185) at io.resttestgen.core.testing.TestRunner.tryTestInteractionExecution(TestRunner.java:141) at java.base/java.lang.Iterable.forEach(Iterable.java:75) at io.resttestgen.core.testing.TestRunner.run(TestRunner.java:106) at io.resttestgen.implementation.strategy.NominalAndErrorStrategy.start(NominalAndErrorStrategy.java:42) at io.resttestgen.boot.Starter.launchStrategyByClass(Starter.java:153) at io.resttestgen.boot.Starter.launchStrategyByClassName(Starter.java:138) at io.resttestgen.boot.Starter.start(Starter.java:30) at io.resttestgen.boot.cli.App.main(App.java:56)

Task :run FAILED

FAILURE: Build failed with an exception.

davidecorradini commented 3 weeks ago

Hello, could you please provide more context? When does the error occur? Can you attach the OpenAPI specification you are using as input? Thank you!

maeve13 commented 3 weeks ago

Here is the oas file: harbor.json And I use docker to run rtg,the error value "jV02VKE6Rà" from the error massage seems to be randomly generated by rtg, not from oas or other response as I know. And I went to check the bug , found some useful information from https://stackoverflow.com/questions/60945415/okhttp-illegalargumentexception-unexpected-char-0xea. Hope it will be useful for you too. But I can't change the code in RequestManager, so I can't validate whether the method from stackoverflow can solve the problem. Thank you for your reply !

davidecorradini commented 3 weeks ago

Thank you for your report. Apparently, the cause is that RTG generates an unsupported value for headers. I will try to fix this for the next release. It might take a few days/weeks tho. I believe that if you run it again it might work without issues as it will probably not generate that random value again. I will reply to this thread as soon as I fixed it! Thanks