use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class CommonWithinMethodsTest method shouldSkipWhenNotStringSchema.
@Test
void shouldSkipWhenNotStringSchema() {
NumberSchema schema = new NumberSchema();
FuzzingData fuzzingData = Mockito.mock(FuzzingData.class);
Map<String, Schema> reqPropTypes = Map.of("test", schema);
Mockito.when(fuzzingData.getRequestPropertyTypes()).thenReturn(reqPropTypes);
List<FuzzingStrategy> fuzzingStrategyList = CommonWithinMethods.getFuzzingStrategies(fuzzingData, "test", List.of("YY"), true);
Assertions.assertThat(fuzzingStrategyList).hasSize(1);
Assertions.assertThat(fuzzingStrategyList.get(0).name()).isEqualTo(FuzzingStrategy.skip().name());
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class CommonWithinMethodsTest method shouldInsertWitReplaceWhenMaintainSize.
@Test
void shouldInsertWitReplaceWhenMaintainSize() {
StringSchema schema = new StringSchema();
int length = 10;
schema.setMinLength(length);
schema.setMaxLength(length);
FuzzingData fuzzingData = Mockito.mock(FuzzingData.class);
Map<String, Schema> reqPropTypes = Map.of("test1", schema);
Mockito.when(fuzzingData.getRequestPropertyTypes()).thenReturn(reqPropTypes);
List<FuzzingStrategy> fuzzingStrategyList = CommonWithinMethods.getFuzzingStrategies(fuzzingData, "test1", List.of(YY), true);
Assertions.assertThat(fuzzingStrategyList).hasSize(1);
Assertions.assertThat(fuzzingStrategyList.get(0).getData()).contains(YY).doesNotStartWith(YY).doesNotEndWith(YY).hasSize(length);
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class ZalgoTextInStringFieldsValidateSanitizeFuzzerTest 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 = zalgoTextInStringFieldsValidateSanitizeFuzzer.getFieldFuzzingStrategy(data, "field").get(0);
Assertions.assertThat(fuzzingStrategy.getData()).contains("c̷̨̛̥̬͉̘̬̻̩͕͚̦̺̻͓̳͇̲̭̝̙̟̈́̉̐͂͒̆͂̿͌̑͐̌̇̈́̾̉̆̀̅̓͛͋̈̄͊̈̄̎̃̒͂̓̊̌̎̌̃́̅͊̏͘͘͘̕̕͘͠͝a̶͖̐͆͑́͆̓͗͆̏̑̈́̾͛̎̂̒̄̏̍͌͛̀́̄̓̍̐͂̀́̈́̂͐̕̕̕̚͘͠͝͠t̵̨̢̨͙̪̼͚͖̲̻̞̦̤̲̖͚̟̯͔̬̜̬͖̺͎̼̬̞̱̳͚͔͎̩̩̩̲̗̩̊̽̈́̔̀̍͒̓̂͐̾̆̐̒̄͂͒̽̾̔͊̒̀͗̿̈́͆͆̂͆̈́̋̏͊̉͌̒̏̓̑͛̉͘͜͜͜͝͝͠͠s̶");
Assertions.assertThat(zalgoTextInStringFieldsValidateSanitizeFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(zalgoTextInStringFieldsValidateSanitizeFuzzer.getExpectedHttpCodeWhenOptionalFieldsAreFuzzed()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(zalgoTextInStringFieldsValidateSanitizeFuzzer.getExpectedHttpCodeWhenRequiredFieldsAreFuzzed()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(zalgoTextInStringFieldsValidateSanitizeFuzzer.getInvisibleChars()).isEmpty();
Assertions.assertThat(zalgoTextInStringFieldsValidateSanitizeFuzzer.description()).isNotNull();
Assertions.assertThat(zalgoTextInStringFieldsValidateSanitizeFuzzer.typeOfDataSentToTheService()).isNotNull();
Assertions.assertThat(zalgoTextInStringFieldsValidateSanitizeFuzzer.concreteFuzzStrategy().name()).isEqualTo(FuzzingStrategy.replace().name());
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class LeadingControlCharsInFieldsValidateTrimFuzzerTest method givenANewLeadingTabsInFieldsValidateTrimFuzzer_whenCreatingANewInstance_thenTheMethodsBeingOverriddenAreMatchingTheLeadingTabsInFieldsValidateTrimFuzzer.
@Test
void givenANewLeadingTabsInFieldsValidateTrimFuzzer_whenCreatingANewInstance_thenTheMethodsBeingOverriddenAreMatchingTheLeadingTabsInFieldsValidateTrimFuzzer() {
FuzzingStrategy fuzzingStrategy = leadingControlCharsInFieldsValidateTrimFuzzer.getFieldFuzzingStrategy(null, null).get(0);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.prefix().name());
Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo("\r\n");
Assertions.assertThat(leadingControlCharsInFieldsValidateTrimFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(leadingControlCharsInFieldsValidateTrimFuzzer.getExpectedHttpCodeWhenOptionalFieldsAreFuzzed()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(leadingControlCharsInFieldsValidateTrimFuzzer.getExpectedHttpCodeWhenRequiredFieldsAreFuzzed()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(leadingControlCharsInFieldsValidateTrimFuzzer.description()).isNotNull();
Assertions.assertThat(leadingControlCharsInFieldsValidateTrimFuzzer.typeOfDataSentToTheService()).isNotNull();
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class LeadingMultiCodePointEmojisInFieldsValidateTrimFuzzerTest method shouldProperlyOverrideMethods.
@Test
void shouldProperlyOverrideMethods() {
FuzzingStrategy fuzzingStrategy = leadingMultiCodePointEmojisInFieldsValidateTrimFuzzer.getFieldFuzzingStrategy(null, null).get(0);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.prefix().name());
Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo("\uD83D\uDC69\uD83C\uDFFE");
Assertions.assertThat(leadingMultiCodePointEmojisInFieldsValidateTrimFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(leadingMultiCodePointEmojisInFieldsValidateTrimFuzzer.getExpectedHttpCodeWhenOptionalFieldsAreFuzzed()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(leadingMultiCodePointEmojisInFieldsValidateTrimFuzzer.getExpectedHttpCodeWhenRequiredFieldsAreFuzzed()).isEqualTo(ResponseCodeFamily.FOURXX);
Assertions.assertThat(leadingMultiCodePointEmojisInFieldsValidateTrimFuzzer.description()).isNotNull();
Assertions.assertThat(leadingMultiCodePointEmojisInFieldsValidateTrimFuzzer.typeOfDataSentToTheService()).isNotNull();
}
Aggregations