use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class AbugidasCharsInStringFieldsSanitizeValidateFuzzerTest method shouldProperlyOverrideSuperClassMethods.
@Test
void shouldProperlyOverrideSuperClassMethods() {
FuzzingData data = Mockito.mock(FuzzingData.class);
Map<String, Schema> reqTypes = new HashMap<>();
reqTypes.put("field", new StringSchema());
Mockito.when(data.getRequestPropertyTypes()).thenReturn(reqTypes);
FuzzingStrategy fuzzingStrategy = abugidasCharsInStringFieldsSanitizeValidateFuzzer.getFieldFuzzingStrategy(data, "field").get(0);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(fuzzingStrategy.getData()).contains("జ్ఞ\u200Cా");
Assertions.assertThat(abugidasCharsInStringFieldsSanitizeValidateFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.TWOXX);
Assertions.assertThat(abugidasCharsInStringFieldsSanitizeValidateFuzzer.description()).isNotNull();
Assertions.assertThat(abugidasCharsInStringFieldsSanitizeValidateFuzzer.concreteFuzzStrategy().name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(abugidasCharsInStringFieldsSanitizeValidateFuzzer.getInvisibleChars()).isEmpty();
Assertions.assertThat(abugidasCharsInStringFieldsSanitizeValidateFuzzer.typeOfDataSentToTheService()).isNotNull();
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class AbugidasCharsInStringFieldsValidateSanitizeFuzzerTest method shouldProperlyOverrideSuperClassMethods.
@Test
void shouldProperlyOverrideSuperClassMethods() {
FuzzingData data = Mockito.mock(FuzzingData.class);
Map<String, Schema> reqTypes = new HashMap<>();
reqTypes.put("field", new StringSchema());
Mockito.when(data.getRequestPropertyTypes()).thenReturn(reqTypes);
FuzzingStrategy fuzzingStrategy = abugidasCharsInStringFieldsValidateSanitizeFuzzer.getFieldFuzzingStrategy(data, "field").get(0);
Assertions.assertThat(fuzzingStrategy.getData()).contains("్ఞ\u200Cా");
Assertions.assertThat(abugidasCharsInStringFieldsValidateSanitizeFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(abugidasCharsInStringFieldsValidateSanitizeFuzzer.getExpectedHttpCodeWhenOptionalFieldsAreFuzzed()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(abugidasCharsInStringFieldsValidateSanitizeFuzzer.getExpectedHttpCodeWhenRequiredFieldsAreFuzzed()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(abugidasCharsInStringFieldsValidateSanitizeFuzzer.getInvisibleChars()).isEmpty();
Assertions.assertThat(abugidasCharsInStringFieldsValidateSanitizeFuzzer.description()).isNotNull();
Assertions.assertThat(abugidasCharsInStringFieldsValidateSanitizeFuzzer.typeOfDataSentToTheService()).isNotNull();
Assertions.assertThat(abugidasCharsInStringFieldsValidateSanitizeFuzzer.concreteFuzzStrategy().name()).isEqualTo(FuzzingStrategy.replace().name());
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class OnlyControlCharsInFieldsValidateTrimFuzzerTest 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 = onlyControlCharsInFieldsValidateTrimFuzzer.getFieldFuzzingStrategy(data, "schema").get(1);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo(StringUtils.repeat("\u0007", stringSchema.getMinLength() + 1));
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class OnlyMultiCodePointEmojisInFieldsValidateTrimFuzzerTest 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);
String theEmoji = "\uD83D\uDC68\u200D\uD83C\uDFED️";
FuzzingStrategy fuzzingStrategy = onlyMultiCodePointEmojisInFieldsValidateTrimFuzzer.getFieldFuzzingStrategy(data, "schema").get(1);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo(StringUtils.repeat(theEmoji, (stringSchema.getMinLength() / theEmoji.length()) + 1));
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class OnlySingleCodePointEmojisInFieldsTrimValidateFuzzerTest method shouldProperlyOverrideMethods.
@Test
void shouldProperlyOverrideMethods() {
Assertions.assertThat(onlySingleCodePointEmojisInFieldsTrimValidateFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(onlySingleCodePointEmojisInFieldsTrimValidateFuzzer.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 = onlySingleCodePointEmojisInFieldsTrimValidateFuzzer.getFieldFuzzingStrategy(data, "schema").get(1);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo("\uD83D\uDC80");
stringSchema.setMinLength(5);
fuzzingStrategy = onlySingleCodePointEmojisInFieldsTrimValidateFuzzer.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));
Assertions.assertThat(onlySingleCodePointEmojisInFieldsTrimValidateFuzzer.description()).isNotNull();
Assertions.assertThat(onlySingleCodePointEmojisInFieldsTrimValidateFuzzer.typeOfDataSentToTheService()).isNotNull();
Assertions.assertThat(onlySingleCodePointEmojisInFieldsTrimValidateFuzzer.getInvisibleChars()).contains("\uD83D\uDC7B");
}
Aggregations