Search in sources :

Example 31 with FuzzingStrategy

use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.

the class CommonWithinMethodsTest method shouldReturnFullZalgoTextWhenMaxLengthNull.

@Test
void shouldReturnFullZalgoTextWhenMaxLengthNull() {
    StringSchema schema = new StringSchema();
    FuzzingStrategy fuzzingStrategy = CommonWithinMethods.getTextBasedOnMaxSize(schema, CommonWithinMethods.ZALGO_TEXT);
    Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo(CommonWithinMethods.ZALGO_TEXT);
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) StringSchema(io.swagger.v3.oas.models.media.StringSchema) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 32 with FuzzingStrategy

use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.

the class CommonWithinMethodsTest method shouldInsertWithoutReplaceWhenNotMaintainSize.

@Test
void shouldInsertWithoutReplaceWhenNotMaintainSize() {
    StringSchema schema = new StringSchema();
    int length = 10;
    schema.setMinLength(length);
    schema.setMaxLength(length);
    FuzzingData fuzzingData = Mockito.mock(FuzzingData.class);
    Map<String, Schema> reqPropTypes = Map.of("test1", schema);
    Mockito.when(fuzzingData.getRequestPropertyTypes()).thenReturn(reqPropTypes);
    List<FuzzingStrategy> fuzzingStrategyList = CommonWithinMethods.getFuzzingStrategies(fuzzingData, "test1", List.of(YY), false);
    Assertions.assertThat(fuzzingStrategyList).hasSize(1);
    Assertions.assertThat(fuzzingStrategyList.get(0).getData()).contains(YY).doesNotStartWith(YY).doesNotEndWith(YY).hasSize(length + YY.length());
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) StringSchema(io.swagger.v3.oas.models.media.StringSchema) NumberSchema(io.swagger.v3.oas.models.media.NumberSchema) Schema(io.swagger.v3.oas.models.media.Schema) FuzzingData(com.endava.cats.model.FuzzingData) StringSchema(io.swagger.v3.oas.models.media.StringSchema) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 33 with FuzzingStrategy

use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.

the class CommonWithinMethodsTest method shouldReturnFullZalgoTextWhenMaxLengthGreaterThenZalgoText.

@Test
void shouldReturnFullZalgoTextWhenMaxLengthGreaterThenZalgoText() {
    StringSchema schema = new StringSchema();
    schema.setMaxLength(1000);
    FuzzingStrategy fuzzingStrategy = CommonWithinMethods.getTextBasedOnMaxSize(schema, CommonWithinMethods.ZALGO_TEXT);
    Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo(CommonWithinMethods.ZALGO_TEXT);
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) StringSchema(io.swagger.v3.oas.models.media.StringSchema) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 34 with FuzzingStrategy

use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.

the class CommonWithinMethodsTest method shouldInsertWithoutReplaceWhenEnums.

@Test
void shouldInsertWithoutReplaceWhenEnums() {
    StringSchema schema = new StringSchema();
    schema.setEnum(List.of("ENUM"));
    FuzzingData fuzzingData = Mockito.mock(FuzzingData.class);
    Map<String, Schema> reqPropTypes = Map.of("test2", schema);
    Mockito.when(fuzzingData.getRequestPropertyTypes()).thenReturn(reqPropTypes);
    List<FuzzingStrategy> fuzzingStrategyList = CommonWithinMethods.getFuzzingStrategies(fuzzingData, "test2", List.of(YY), false);
    Assertions.assertThat(fuzzingStrategyList).hasSize(1);
    Assertions.assertThat(fuzzingStrategyList.get(0).getData()).isEqualTo("EN" + YY + "UM");
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) StringSchema(io.swagger.v3.oas.models.media.StringSchema) NumberSchema(io.swagger.v3.oas.models.media.NumberSchema) Schema(io.swagger.v3.oas.models.media.Schema) FuzzingData(com.endava.cats.model.FuzzingData) StringSchema(io.swagger.v3.oas.models.media.StringSchema) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 35 with FuzzingStrategy

use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.

the class CommonWithinMethodsTest method shouldReturnMaxLengthZalgoText.

@Test
void shouldReturnMaxLengthZalgoText() {
    StringSchema schema = new StringSchema();
    schema.setMaxLength(100);
    FuzzingStrategy fuzzingStrategy = CommonWithinMethods.getTextBasedOnMaxSize(schema, CommonWithinMethods.ZALGO_TEXT);
    Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo(CommonWithinMethods.ZALGO_TEXT.substring(0, 100));
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) StringSchema(io.swagger.v3.oas.models.media.StringSchema) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

FuzzingStrategy (com.endava.cats.model.FuzzingStrategy)67 QuarkusTest (io.quarkus.test.junit.QuarkusTest)62 Test (org.junit.jupiter.api.Test)62 FuzzingData (com.endava.cats.model.FuzzingData)35 StringSchema (io.swagger.v3.oas.models.media.StringSchema)34 Schema (io.swagger.v3.oas.models.media.Schema)30 HashMap (java.util.HashMap)27 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 NumberSchema (io.swagger.v3.oas.models.media.NumberSchema)4 CatsDSLParser (com.endava.cats.dsl.CatsDSLParser)3 FuzzingResult (com.endava.cats.model.FuzzingResult)3 CatsHeader (com.endava.cats.model.CatsHeader)2 CatsResponse (com.endava.cats.model.CatsResponse)2 DryRun (com.endava.cats.annotations.DryRun)1 ApiArguments (com.endava.cats.args.ApiArguments)1 AuthArguments (com.endava.cats.args.AuthArguments)1 FilesArguments (com.endava.cats.args.FilesArguments)1 ProcessingArguments (com.endava.cats.args.ProcessingArguments)1 CatsDSLWords (com.endava.cats.dsl.CatsDSLWords)1 ADDITIONAL_PROPERTIES (com.endava.cats.dsl.CatsDSLWords.ADDITIONAL_PROPERTIES)1