use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class BaseFieldsFuzzerTest method shouldSkipWhenFuzzingNotPossibleFromFuzzer.
@Test
void shouldSkipWhenFuzzingNotPossibleFromFuzzer() {
FuzzingData data = createFuzzingData();
BaseFieldsFuzzer spyFuzzer = Mockito.spy(baseFieldsFuzzer);
Mockito.when(spyFuzzer.isFuzzingPossibleSpecificToFuzzer(Mockito.eq(data), Mockito.anyString(), Mockito.any())).thenReturn(false);
spyFuzzer.fuzz(data);
Mockito.verify(testCaseListener).skipTest(Mockito.any(), Mockito.eq("Field could not be fuzzed. Possible reasons: field is not a primitive, is a discriminator or is not matching the Fuzzer schemas"));
}
use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class OnlyControlCharsInFieldsTrimValidateFuzzerTest method givenANewTabsOnlyInFieldsTrimValidateFuzzer_whenCreatingANewInstance_thenTheMethodsBeingOverriddenAreMatchingTheTabsOnlyInFieldsTrimValidateFuzzer.
@Test
void givenANewTabsOnlyInFieldsTrimValidateFuzzer_whenCreatingANewInstance_thenTheMethodsBeingOverriddenAreMatchingTheTabsOnlyInFieldsTrimValidateFuzzer() {
Assertions.assertThat(onlyControlCharsInFieldsTrimValidateFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(onlyControlCharsInFieldsTrimValidateFuzzer.skipForHttpMethods()).containsExactly(HttpMethod.GET, HttpMethod.DELETE);
FuzzingData data = Mockito.mock(FuzzingData.class);
Map<String, Schema> schemaMap = new HashMap<>();
StringSchema stringSchema = new StringSchema();
schemaMap.put("schema", stringSchema);
Mockito.when(data.getRequestPropertyTypes()).thenReturn(schemaMap);
FuzzingStrategy fuzzingStrategy = onlyControlCharsInFieldsTrimValidateFuzzer.getFieldFuzzingStrategy(data, "schema").get(1);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo("\u0007");
stringSchema.setMinLength(5);
fuzzingStrategy = onlyControlCharsInFieldsTrimValidateFuzzer.getFieldFuzzingStrategy(data, "schema").get(1);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo(StringUtils.repeat("\u0007", stringSchema.getMinLength() + 1));
Assertions.assertThat(onlyControlCharsInFieldsTrimValidateFuzzer.description()).isNotNull();
Assertions.assertThat(onlyControlCharsInFieldsTrimValidateFuzzer.typeOfDataSentToTheService()).isNotNull();
Assertions.assertThat(onlyControlCharsInFieldsTrimValidateFuzzer.getInvisibleChars()).contains("\t");
Assertions.assertThat(onlyControlCharsInFieldsTrimValidateFuzzer.skipForFields()).containsOnly("pet");
}
use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class OnlyControlCharsInFieldsTrimValidateFuzzerTest method givenANewTabsOnlyInFieldsTrimValidateFuzzer_whenGettingTheFieldsFuzzingStrategyAndTheSchemaDoesNotExist_thenTheDefaultNumberOfTabsAreReturned.
@Test
void givenANewTabsOnlyInFieldsTrimValidateFuzzer_whenGettingTheFieldsFuzzingStrategyAndTheSchemaDoesNotExist_thenTheDefaultNumberOfTabsAreReturned() {
FuzzingData data = Mockito.mock(FuzzingData.class);
Map<String, Schema> schemaMap = new HashMap<>();
StringSchema stringSchema = new StringSchema();
schemaMap.put("schema", stringSchema);
Mockito.when(data.getRequestPropertyTypes()).thenReturn(schemaMap);
FuzzingStrategy fuzzingStrategy = onlyControlCharsInFieldsTrimValidateFuzzer.getFieldFuzzingStrategy(data, "another_schema").get(0);
Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo("\r\n");
}
use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class OnlyControlCharsInFieldsValidateTrimFuzzerTest method shouldReturnProperLengthWhenNoMinLLength.
@Test
void shouldReturnProperLengthWhenNoMinLLength() {
FuzzingData data = Mockito.mock(FuzzingData.class);
Map<String, Schema> schemaMap = new HashMap<>();
StringSchema stringSchema = new StringSchema();
schemaMap.put("schema", stringSchema);
Mockito.when(data.getRequestPropertyTypes()).thenReturn(schemaMap);
FuzzingStrategy fuzzingStrategy = onlyControlCharsInFieldsValidateTrimFuzzer.getFieldFuzzingStrategy(data, "schema").get(1);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo("\u0007");
}
use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class OnlyMultiCodePointEmojisInFieldsTrimValidateFuzzerTest method shouldReturnFirstCharacter.
@Test
void shouldReturnFirstCharacter() {
FuzzingData data = Mockito.mock(FuzzingData.class);
Map<String, Schema> schemaMap = new HashMap<>();
StringSchema stringSchema = new StringSchema();
schemaMap.put("schema", stringSchema);
Mockito.when(data.getRequestPropertyTypes()).thenReturn(schemaMap);
FuzzingStrategy fuzzingStrategy = onlyMultiCodePointEmojisInFieldsTrimValidateFuzzer.getFieldFuzzingStrategy(data, "another_schema").get(0);
Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo("\uD83D\uDC69\uD83C\uDFFE");
}
Aggregations