diff --git a/core-tests/e2e-tests/spring/spring-rest-h2-v1/src/test/java/org/evomaster/e2etests/spring/examples/adaptivehypermutation/DeterminismTest.java b/core-tests/e2e-tests/spring/spring-rest-h2-v1/src/test/java/org/evomaster/e2etests/spring/examples/adaptivehypermutation/DeterminismTest.java index 75c9268ddd..1abf1572cb 100644 --- a/core-tests/e2e-tests/spring/spring-rest-h2-v1/src/test/java/org/evomaster/e2etests/spring/examples/adaptivehypermutation/DeterminismTest.java +++ b/core-tests/e2e-tests/spring/spring-rest-h2-v1/src/test/java/org/evomaster/e2etests/spring/examples/adaptivehypermutation/DeterminismTest.java @@ -28,7 +28,7 @@ public void testDeterminismOfLog(boolean enableConstraintHandling){ OpenAPI schema = (new OpenAPIParser()).readLocation("swagger-ahm/ahm.json", null, null).getOpenAPI(); isDeterminismConsumer( new ArrayList<>(), (args) -> RestActionBuilderV3.INSTANCE .getModelsFromSwagger(schema, new LinkedHashMap<>(), - new RestActionBuilderV3.Options(false,enableConstraintHandling,false,0.0,0.0,true,false,false))); + new RestActionBuilderV3.Options(false,enableConstraintHandling,false,0.0,0.0,true,false,false,true))); } diff --git a/core-tests/jdk-8/spring-rest-openapi-v2-tests/src/test/java/org/evomaster/e2etests/spring/examples/adaptivehypermutation/DeterminismTest.java b/core-tests/jdk-8/spring-rest-openapi-v2-tests/src/test/java/org/evomaster/e2etests/spring/examples/adaptivehypermutation/DeterminismTest.java index 2ddc3b2b3e..7989a039a8 100644 --- a/core-tests/jdk-8/spring-rest-openapi-v2-tests/src/test/java/org/evomaster/e2etests/spring/examples/adaptivehypermutation/DeterminismTest.java +++ b/core-tests/jdk-8/spring-rest-openapi-v2-tests/src/test/java/org/evomaster/e2etests/spring/examples/adaptivehypermutation/DeterminismTest.java @@ -27,7 +27,7 @@ public void testDeterminismOfLog(boolean enableConstraintHandling){ OpenAPI schema = (new OpenAPIParser()).readLocation("swagger-ahm/ahm.json", null, null).getOpenAPI(); isDeterminismConsumer( new ArrayList<>(), (args) -> { RestActionBuilderV3.INSTANCE.getModelsFromSwagger(schema, new LinkedHashMap<>(), - new RestActionBuilderV3.Options(false,enableConstraintHandling,false,0.0,0.0,true,false,false)); + new RestActionBuilderV3.Options(false,enableConstraintHandling,false,0.0,0.0,true,false,false,true)); }); } diff --git a/core/src/main/kotlin/org/evomaster/core/EMConfig.kt b/core/src/main/kotlin/org/evomaster/core/EMConfig.kt index aa00cc9f80..9ad78df750 100644 --- a/core/src/main/kotlin/org/evomaster/core/EMConfig.kt +++ b/core/src/main/kotlin/org/evomaster/core/EMConfig.kt @@ -1378,6 +1378,10 @@ class EMConfig { "Only available for JVM languages") var dtoForRequestPayload = false + @Experimental + @Cfg("Enable multipart/form-data support when building REST actions.") + var enableMultipartFormDataSupport = false + @Important(6.0) @Cfg("Host name or IP address of where the SUT EvoMaster Controller Driver is listening on." + " This option is only needed for white-box testing.") diff --git a/core/src/main/kotlin/org/evomaster/core/problem/rest/builder/RestActionBuilderV3.kt b/core/src/main/kotlin/org/evomaster/core/problem/rest/builder/RestActionBuilderV3.kt index f81355b0c3..ae6447b5a2 100644 --- a/core/src/main/kotlin/org/evomaster/core/problem/rest/builder/RestActionBuilderV3.kt +++ b/core/src/main/kotlin/org/evomaster/core/problem/rest/builder/RestActionBuilderV3.kt @@ -117,6 +117,8 @@ object RestActionBuilderV3 { val enableAdvancedFormats: Boolean = true, val inferFormatFromNames: Boolean = true, + + val enableMultipartFormDataSupport: Boolean = false, ){ constructor(config: EMConfig): this( enableConstraintHandling = config.enableSchemaConstraintHandling, @@ -125,7 +127,8 @@ object RestActionBuilderV3 { probUseExamples = config.probRestExamples, usingWhiteBox = !config.blackBox, enableAdvancedFormats = config.enableAdvancedFormats, - inferFormatFromNames = config.inferFormatFromNames + inferFormatFromNames = config.inferFormatFromNames, + enableMultipartFormDataSupport = config.enableMultipartFormDataSupport, ) init { diff --git a/core/src/test/kotlin/org/evomaster/core/problem/rest/RestActionBuilderV3Test.kt b/core/src/test/kotlin/org/evomaster/core/problem/rest/RestActionBuilderV3Test.kt index 56ac900bb6..1831a96b45 100644 --- a/core/src/test/kotlin/org/evomaster/core/problem/rest/RestActionBuilderV3Test.kt +++ b/core/src/test/kotlin/org/evomaster/core/problem/rest/RestActionBuilderV3Test.kt @@ -47,6 +47,14 @@ class RestActionBuilderV3Test{ RestActionBuilderV3.cleanCache() } + @Test + fun testMultipartFormDataSupportOptionDefaultsToDisabled(){ + val config = EMConfig() + + assertFalse(config.enableMultipartFormDataSupport) + assertFalse(RestActionBuilderV3.Options(config).enableMultipartFormDataSupport) + assertTrue(RestActionBuilderV3.Options(enableMultipartFormDataSupport = true).enableMultipartFormDataSupport) + } @Test fun testDtoIssueWithWronglyHandledField(){ diff --git a/docs/options.md b/docs/options.md index f3a9eebce2..9e78bd0202 100644 --- a/docs/options.md +++ b/docs/options.md @@ -289,6 +289,7 @@ There are 3 types of options: |`enableAdvancedFormats`| __Boolean__. Whether to enable the handling of new type formats in OpenAPI schemas, e.g., the ones introduced in 3.1.0. *Default value*: `false`.| |`enableCustomizedMethodForMockObjectHandling`| __Boolean__. Whether to apply customized method (i.e., implement 'customizeMockingRPCExternalService' for external services or 'customizeMockingDatabase' for database) to handle mock object. *Default value*: `false`.| |`enableCustomizedMethodForScheduleTaskHandling`| __Boolean__. Whether to apply customized method (i.e., implement 'customizeScheduleTaskInvocation' for invoking schedule task) to invoke schedule task. *Default value*: `false`.| +|`enableMultipartFormDataSupport`| __Boolean__. Enable multipart/form-data support when building REST actions. *Default value*: `false`.| |`enableRPCCustomizedTestOutput`| __Boolean__. Whether to enable customized RPC Test output if 'customizeRPCTestOutput' is implemented. *Default value*: `false`.| |`enableStaticFlakyInference`| __Boolean__. Specify whether to infer potential flakiness statically from response values, such as timestamps, UUIDs, hashes and runtime-specific messages. *Depends on*: `handleFlakiness=true`. *Default value*: `true`.| |`enableWriteSnapshotTests`| __Boolean__. Enable to print snapshots of the generated tests during the search in an interval defined in snapshotsInterval. *Default value*: `false`.|