Skip to content
Permalink
Browse files

Merge pull request #134 from EMResearch/large-payload

handling of too large body payloads
  • Loading branch information
arcuri82 committed Nov 29, 2019
2 parents e8ea441 + e04c5b1 commit a255f70f9e32a966194bc9fd9e3e842009a71c31
@@ -83,23 +83,25 @@ class TestCaseWriter {

lines.indented {

if (test.test.individual is RestIndividual) {
val ind = test.test.individual

if (ind is RestIndividual) {
// BMR: test.test should have the used objects attached (if any).
if (config.enableCompleteObjects) {
usedObjects = (test.test.individual as RestIndividual).usedObjects.copy()
usedObjects = ind.usedObjects.copy()
}
if(configuration.expectationsActive){
expectationsWriter.addDeclarations(lines)
}
if (!test.test.individual.dbInitialization.isEmpty()) {
handleDbInitialization(format, (test.test.individual as RestIndividual).dbInitialization, lines)
if (ind.dbInitialization.isNotEmpty()) {
handleDbInitialization(format, ind.dbInitialization, lines)
}
}

if (test.hasChainedLocations()) {
lines.addEmpty()

test.test.evaluatedActions()
test.test.evaluatedActions().asSequence()
.map { it.action }
.filterIsInstance(RestCallAction::class.java)
.filter { it.locationId != null }
@@ -603,12 +605,14 @@ class TestCaseWriter {
else -> {
// This branch will be called if the JSON is null (or has a basic type)
// Currently, it converts the contents to String.
if(bodyString.isNullOrBlank()){
lines.add(".body(isEmptyOrNullString())")
}else {
lines.add(".body(containsString(\"${
GeneUtils.applyEscapes(bodyString, mode = GeneUtils.EscapeMode.BODY, format = format)
}\"))")
when {
res.getTooLargeBody() -> lines.add("/* very large body, which was not handled during the search */")

bodyString.isNullOrBlank() -> lines.add(".body(isEmptyOrNullString())")

else -> lines.add(".body(containsString(\"${
GeneUtils.applyEscapes(bodyString, mode = GeneUtils.EscapeMode.BODY, format = format)
}\"))")
}
}
}
@@ -7,6 +7,7 @@ import org.evomaster.client.java.controller.api.dto.HeuristicEntryDto
import org.evomaster.client.java.controller.api.dto.SutInfoDto
import org.evomaster.client.java.controller.api.dto.TestResultsDto
import org.evomaster.core.database.DatabaseExecution
import org.evomaster.core.logging.LoggingUtil
import org.evomaster.core.problem.rest.*
import org.evomaster.core.problem.rest.auth.NoAuth
import org.evomaster.core.problem.rest.param.BodyParam
@@ -361,7 +362,8 @@ abstract class AbstractRestFitness<T> : FitnessFunction<T>() where T : Individua
if (body.length < configuration.maxResponseByteSize) {
rcr.setBody(body)
} else {
log.warn("A very large response body was retrieved from the endpoint '${a.path}'." +
LoggingUtil.uniqueWarn(log,
"A very large response body was retrieved from the endpoint '${a.path}'." +
" If that was expected, increase the 'maxResponseByteSize' threshold" +
" in the configurations.")
rcr.setTooLargeBody(true)
@@ -7,6 +7,7 @@ import org.evomaster.client.java.controller.api.dto.SutInfoDto
import org.evomaster.client.java.controller.api.dto.TestResultsDto
import org.evomaster.client.java.controller.api.dto.database.execution.ExecutionDto
import org.evomaster.core.database.DbActionTransformer
import org.evomaster.core.logging.LoggingUtil
import org.evomaster.core.problem.rest.*
import org.evomaster.core.problem.rest.auth.NoAuth
import org.evomaster.core.problem.rest.param.HeaderParam
@@ -418,7 +419,8 @@ class ObjFitness : FitnessFunction<ObjIndividual>() {
if (body.length < configuration.maxResponseByteSize) {
rcr.setBody(body)
} else {
log.warn("A very large response body was retrieved from the endpoint '${a.path}'." +
LoggingUtil.uniqueWarn(log,
"A very large response body was retrieved from the endpoint '${a.path}'." +
" If that was expected, increase the 'maxResponseByteSize' threshold" +
" in the configurations.")
rcr.setTooLargeBody(true)

0 comments on commit a255f70

Please sign in to comment.
You can’t perform that action at this time.