Search in sources :

Example 46 with FuzzingData

use of com.endava.cats.model.FuzzingData 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 47 with FuzzingData

use of com.endava.cats.model.FuzzingData 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 48 with FuzzingData

use of com.endava.cats.model.FuzzingData 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 49 with FuzzingData

use of com.endava.cats.model.FuzzingData 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 50 with FuzzingData

use of com.endava.cats.model.FuzzingData 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

FuzzingData (com.endava.cats.model.FuzzingData)167 QuarkusTest (io.quarkus.test.junit.QuarkusTest)139 Test (org.junit.jupiter.api.Test)139 StringSchema (io.swagger.v3.oas.models.media.StringSchema)73 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)47 CatsResponse (com.endava.cats.model.CatsResponse)43 HashMap (java.util.HashMap)43 Schema (io.swagger.v3.oas.models.media.Schema)36 FuzzingStrategy (com.endava.cats.model.FuzzingStrategy)35 CsvSource (org.junit.jupiter.params.provider.CsvSource)19 List (java.util.List)17 OpenAPI (io.swagger.v3.oas.models.OpenAPI)14 OpenAPIParser (io.swagger.parser.OpenAPIParser)12 PathItem (io.swagger.v3.oas.models.PathItem)12 HashSet (java.util.HashSet)8 File (java.io.File)7 CatsHeader (com.endava.cats.model.CatsHeader)6 Set (java.util.Set)6 CatsUtil (com.endava.cats.util.CatsUtil)5 NumberSchema (io.swagger.v3.oas.models.media.NumberSchema)5