use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class NullValuesInFieldsFuzzerTest method shouldNotRunForSkippedFields.
@Test
void shouldNotRunForSkippedFields() {
Mockito.when(ignoreArguments.getSkippedFields()).thenReturn(Collections.singletonList("id"));
Assertions.assertThat(nullValuesInFieldsFuzzer.skipForFields()).containsOnly("id");
FuzzingData data = Mockito.mock(FuzzingData.class);
Mockito.when(data.getAllFieldsByHttpMethod()).thenReturn(Sets.newHashSet("id"));
Mockito.when(data.getPayload()).thenReturn("{}");
nullValuesInFieldsFuzzer.fuzz(data);
Mockito.verify(testCaseListener).skipTest(Mockito.any(), Mockito.any());
}
use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class SecurityFuzzerTest method givenAnEmptySecurityFuzzerFile_whenTheFuzzerRuns_thenNothingHappens.
@Test
void givenAnEmptySecurityFuzzerFile_whenTheFuzzerRuns_thenNothingHappens() {
FuzzingData data = FuzzingData.builder().build();
SecurityFuzzer spyCustomFuzzer = Mockito.spy(securityFuzzer);
spyCustomFuzzer.fuzz(data);
Mockito.verifyNoInteractions(testCaseListener);
Assertions.assertThat(securityFuzzer.description()).isNotNull();
Assertions.assertThat(securityFuzzer).hasToString(securityFuzzer.getClass().getSimpleName());
Assertions.assertThat(securityFuzzer.reservedWords()).containsOnly(CatsDSLWords.EXPECTED_RESPONSE_CODE, CatsDSLWords.DESCRIPTION, CatsDSLWords.OUTPUT, CatsDSLWords.VERIFY, CatsDSLWords.STRINGS_FILE, CatsDSLWords.TARGET_FIELDS, CatsDSLWords.MAP_VALUES, CatsDSLWords.ONE_OF_SELECTION, CatsDSLWords.ADDITIONAL_PROPERTIES, CatsDSLWords.ELEMENT, CatsDSLWords.HTTP_METHOD, CatsDSLWords.TARGET_FIELDS_TYPES);
}
use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class SecurityFuzzerTest method givenASecurityFuzzerFileWithAPathThatIsNotInContract_whenTheFuzzerRuns_thenAnErrorIsReported.
@Test
void givenASecurityFuzzerFileWithAPathThatIsNotInContract_whenTheFuzzerRuns_thenAnErrorIsReported() throws Exception {
FuzzingData data = setContext("src/test/resources/securityFuzzer.yml", "{'name': {'first': 'Cats'}, 'id': '25'}");
SecurityFuzzer spySecurityFuzzer = Mockito.spy(securityFuzzer);
filesArguments.loadSecurityFuzzerFile();
spySecurityFuzzer.fuzz(data);
Mockito.verifyNoInteractions(testCaseListener);
}
use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class ZalgoTextInStringFieldsSanitizeValidateFuzzerTest 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 = zalgoTextInStringFieldsSanitizeValidateFuzzer.getFieldFuzzingStrategy(data, "field").get(0);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(fuzzingStrategy.getData()).contains("c̷̨̛̥̬͉̘̬̻̩͕͚̦̺̻͓̳͇̲̭̝̙̟̈́̉̐͂͒̆͂̿͌̑͐̌̇̈́̾̉̆̀̅̓͛͋̈̄͊̈̄̎̃̒͂̓̊̌̎̌̃́̅͊̏͘͘͘̕̕͘͠͝a");
Assertions.assertThat(zalgoTextInStringFieldsSanitizeValidateFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.TWOXX);
Assertions.assertThat(zalgoTextInStringFieldsSanitizeValidateFuzzer.description()).isNotNull();
Assertions.assertThat(zalgoTextInStringFieldsSanitizeValidateFuzzer.concreteFuzzStrategy().name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(zalgoTextInStringFieldsSanitizeValidateFuzzer.getInvisibleChars()).isEmpty();
Assertions.assertThat(zalgoTextInStringFieldsSanitizeValidateFuzzer.typeOfDataSentToTheService()).isNotNull();
}
use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class BaseBoundaryFieldFuzzerTest method getMockFuzzingData.
private FuzzingData getMockFuzzingData() {
Map<String, Schema> schemaMap = new HashMap<>();
schemaMap.put("field", new StringSchema());
FuzzingData data = Mockito.mock(FuzzingData.class);
Mockito.when(data.getRequestPropertyTypes()).thenReturn(schemaMap);
return data;
}
Aggregations