use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class OnlySingleCodePointEmojisInFieldsValidateTrimFuzzerTest method shouldReturnProperLengthWhenMinValue.
@Test
void shouldReturnProperLengthWhenMinValue() {
FuzzingData data = Mockito.mock(FuzzingData.class);
Map<String, Schema> schemaMap = new HashMap<>();
StringSchema stringSchema = new StringSchema();
stringSchema.setMinLength(5);
schemaMap.put("schema", stringSchema);
Mockito.when(data.getRequestPropertyTypes()).thenReturn(schemaMap);
FuzzingStrategy fuzzingStrategy = onlySingleCodePointEmojisInFieldsValidateTrimFuzzer.getFieldFuzzingStrategy(data, "schema").get(1);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo(StringUtils.repeat("\uD83D\uDC80", (stringSchema.getMinLength() / 2) + 1));
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class OnlyWhitespacesInFieldsTrimValidateFuzzerTest 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 = onlyWhitespacesInFieldsTrimValidateFuzzer.getFieldFuzzingStrategy(data, "schema").get(0);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo(" ");
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class OnlyWhitespacesInFieldsTrimValidateFuzzerTest method shouldReturnProperLengthWhenMinValue.
@Test
void shouldReturnProperLengthWhenMinValue() {
FuzzingData data = Mockito.mock(FuzzingData.class);
Map<String, Schema> schemaMap = new HashMap<>();
StringSchema stringSchema = new StringSchema();
stringSchema.setMinLength(5);
schemaMap.put("schema", stringSchema);
Mockito.when(data.getRequestPropertyTypes()).thenReturn(schemaMap);
FuzzingStrategy fuzzingStrategy = onlyWhitespacesInFieldsTrimValidateFuzzer.getFieldFuzzingStrategy(data, "schema").get(0);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo(StringUtils.repeat(" ", stringSchema.getMinLength() + 1));
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class NoopFuzzingStrategyTest method givenAString_whenUsingTheNoopFuzzingStrategy_thenTheStringIsCorrectlyProcessed.
@Test
void givenAString_whenUsingTheNoopFuzzingStrategy_thenTheStringIsCorrectlyProcessed() {
FuzzingStrategy strategy = FuzzingStrategy.noop().withData("inner");
Assertions.assertThat(strategy.process("string")).isEqualTo("string");
Assertions.assertThat(strategy.name()).isEqualTo("NOOP");
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class PrefixFuzzingStrategyTest method givenAString_whenUsingThePrefixFuzzingStrategy_thenTheStringIsCorrectlyProcessed.
@Test
void givenAString_whenUsingThePrefixFuzzingStrategy_thenTheStringIsCorrectlyProcessed() {
FuzzingStrategy strategy = FuzzingStrategy.prefix().withData("inner");
Assertions.assertThat(strategy.process("string")).isEqualTo("innerstring");
}
Aggregations