File tree Expand file tree Collapse file tree
main/kotlin/org/evomaster/core/problem/rest
test/kotlin/org/evomaster/core/problem/rest Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -329,7 +329,7 @@ class RestPath(path: String) {
329329 gene.getViewOfElements()
330330 .joinToString(" &" ) { " $name =${encode(it.getValueAsRawString())} " }
331331 } else {
332- val value = encode(gene!! .getValueAsRawString())
332+ val value = encode(gene.getValueAsRawString())
333333 " $name =$value "
334334 }
335335 }
Original file line number Diff line number Diff line change @@ -883,17 +883,31 @@ abstract class AbstractRestFitness : HttpWsFitness<RestIndividual>() {
883883 }
884884
885885
886- val builder = if (a.produces.isEmpty()) {
887- log.debug(" No 'produces' type defined for {}" , path)
888- client.target(fullUri).request(" */*" )
886+ val builder = try {
887+ if (a.produces.isEmpty()) {
888+ log.debug(" No 'produces' type defined for {}" , path)
889+ client.target(fullUri).request(" */*" )
889890
890- } else {
891- /*
891+ } else {
892+ /*
892893 TODO: This only considers the first in the list of produced responses
893894 This is fine for endpoints that only produce one type of response.
894895 Could be a problem in future
895896 */
896- client.target(fullUri).request(a.produces.first())
897+ client.target(fullUri).request(a.produces.first())
898+ }
899+ } catch (e: Exception ) {
900+ /*
901+ FIXME we need to solve this issue somehow, as location values might be invalid...
902+ but i guess that should be done in resolveLocation
903+ */
904+ throw RuntimeException ("""
905+ Failed to build HTTP invocation.
906+ Resolved path: $path
907+ Location header: $locationHeader
908+ Resolved location: $fullUri
909+ Error: ${e.message}
910+ """ .trimIndent(), e)
897911 }
898912
899913 handleHeaders(a, builder, cookies, tokens)
Original file line number Diff line number Diff line change @@ -10,13 +10,33 @@ import org.evomaster.core.search.gene.collection.ArrayGene
1010import org.evomaster.core.search.gene.wrapper.CustomMutationRateGene
1111import org.evomaster.core.search.gene.numeric.IntegerGene
1212import org.evomaster.core.search.gene.string.StringGene
13+ import org.glassfish.jersey.uri.internal.JerseyUriBuilder
1314import org.junit.jupiter.api.Assertions.*
1415import org.junit.jupiter.api.Test
1516import org.junit.jupiter.params.ParameterizedTest
1617import org.junit.jupiter.params.provider.ValueSource
18+ import java.net.URISyntaxException
19+ import org.junit.jupiter.api.assertThrows
1720
1821internal class RestPathTest {
1922
23+ @Test
24+ fun testFamilieBaSakIssue (){
25+
26+ val x = " /api/satsendring/kjorsatsendring?EMextraParam123=42/Trigget satsendring for fagsakene []"
27+
28+ assertThrows<Exception >{JerseyUriBuilder .fromUri(x).build()}
29+
30+ val path = RestPath (" /api/satsendring/kjorsatsendring" )
31+ val q = QueryParam (" EMextraParam123" , StringGene (" EMextraParam123" , " 42/Trigget satsendring for fagsakene []" ))
32+
33+ val uri = path.resolve(listOf (q))
34+
35+ assertNotEquals(x, uri)
36+
37+ JerseyUriBuilder .fromUri(uri).build()
38+ }
39+
2040
2141 @Test
2242 fun testNameQualifier (){
You can’t perform that action at this time.
0 commit comments