Search in sources :

Example 6 with FuzzingStrategy

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

the class BaseBoundaryFieldFuzzerTest method givenABaseBoundaryFuzzerWithNoDefinedBoundary_whenGettingTheFuzzingStrategy_thenTheSkipStrategyIsBeingReturned.

@Test
void givenABaseBoundaryFuzzerWithNoDefinedBoundary_whenGettingTheFuzzingStrategy_thenTheSkipStrategyIsBeingReturned() {
    myBaseBoundaryFuzzer = new MyBaseBoundaryWithoutBoundariesFuzzer(serviceCaller, testCaseListener, catsUtil, filesArguments);
    FuzzingData data = getMockFuzzingData();
    FuzzingStrategy strategy = myBaseBoundaryFuzzer.getFieldFuzzingStrategy(data, "field").get(0);
    Assertions.assertThat(strategy.name()).isEqualTo(FuzzingStrategy.skip().name());
    Assertions.assertThat(strategy.getData()).startsWith("No LEFT or RIGHT boundary");
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) FuzzingData(com.endava.cats.model.FuzzingData) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 7 with FuzzingStrategy

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

the class BaseBoundaryFieldFuzzerTest method givenABaseBoundaryFuzzerWithDefinedBoundary_whenGettingTheFuzzingStrategy_thenTheReplaceStrategyIsBeingReturned.

@Test
void givenABaseBoundaryFuzzerWithDefinedBoundary_whenGettingTheFuzzingStrategy_thenTheReplaceStrategyIsBeingReturned() {
    myBaseBoundaryFuzzer = new MyBaseBoundaryWithBoundariesFuzzer(serviceCaller, testCaseListener, catsUtil, filesArguments);
    FuzzingData data = getMockFuzzingData();
    FuzzingStrategy strategy = myBaseBoundaryFuzzer.getFieldFuzzingStrategy(data, "field").get(0);
    Assertions.assertThat(strategy.name()).isEqualTo(FuzzingStrategy.replace().name());
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) FuzzingData(com.endava.cats.model.FuzzingData) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 8 with FuzzingStrategy

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

the class BaseBoundaryFieldFuzzerTest method givenABaseBoundaryFuzzerAndAFieldWithNoSchema_whenGettingTheFuzzingStrategy_thenTheSkipStrategyIsBeingReturned.

@Test
void givenABaseBoundaryFuzzerAndAFieldWithNoSchema_whenGettingTheFuzzingStrategy_thenTheSkipStrategyIsBeingReturned() {
    myBaseBoundaryFuzzer = new MyBaseBoundaryWithBoundariesAndIntegerSchemaFuzzer(serviceCaller, testCaseListener, catsUtil, filesArguments);
    FuzzingData data = Mockito.mock(FuzzingData.class);
    Mockito.when(data.getRequestPropertyTypes()).thenReturn(new HashMap<>());
    FuzzingStrategy strategy = myBaseBoundaryFuzzer.getFieldFuzzingStrategy(data, "field").get(0);
    Assertions.assertThat(strategy.name()).isEqualTo(FuzzingStrategy.skip().name());
    Assertions.assertThat(strategy.getData()).startsWith("Data type not matching");
    Assertions.assertThat(myBaseBoundaryFuzzer.typeOfDataSentToTheService()).startsWith("outside the boundary values");
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) FuzzingData(com.endava.cats.model.FuzzingData) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 9 with FuzzingStrategy

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

the class BaseBoundaryFieldFuzzerTest method givenABaseBoundaryFuzzerWithNoDefinedBoundaryAndIntegerSchema_whenGettingTheFuzzingStrategy_thenTheSkipStrategyIsBeingReturned.

@Test
void givenABaseBoundaryFuzzerWithNoDefinedBoundaryAndIntegerSchema_whenGettingTheFuzzingStrategy_thenTheSkipStrategyIsBeingReturned() {
    myBaseBoundaryFuzzer = new MyBaseBoundaryWithBoundariesAndIntegerSchemaFuzzer(serviceCaller, testCaseListener, catsUtil, filesArguments);
    FuzzingData data = getMockFuzzingData();
    FuzzingStrategy strategy = myBaseBoundaryFuzzer.getFieldFuzzingStrategy(data, "field").get(0);
    Assertions.assertThat(strategy.name()).isEqualTo(FuzzingStrategy.skip().name());
    Assertions.assertThat(strategy.getData()).startsWith("Data type not matching [IntegerSchema]");
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) FuzzingData(com.endava.cats.model.FuzzingData) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 10 with FuzzingStrategy

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

the class BaseBoundaryFieldFuzzerTest method shouldSkipWhenFormatNotRecognized.

@Test
void shouldSkipWhenFormatNotRecognized() {
    FuzzingData data = getMockFuzzingData();
    StringSchema schema = new StringSchema();
    schema.setFormat("cats");
    data.getRequestPropertyTypes().put("emailAddress", schema);
    myBaseBoundaryFuzzer = new MyBaseBoundaryWithBoundariesButNoBoundaryValueFuzzer(serviceCaller, testCaseListener, catsUtil, filesArguments);
    FuzzingStrategy fuzzingStrategy = myBaseBoundaryFuzzer.getFieldFuzzingStrategy(data, "emailAddress").get(0);
    Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.skip().name());
    Assertions.assertThat(fuzzingStrategy.getData()).startsWith("String format not supplied or not recognized!");
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) 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)

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