use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class ReplaceFuzzingStrategyTest method givenAString_whenUsingTheReplaceFuzzingStrategy_thenTheStringIsCorrectlyProcessed.
@Test
void givenAString_whenUsingTheReplaceFuzzingStrategy_thenTheStringIsCorrectlyProcessed() {
FuzzingStrategy strategy = FuzzingStrategy.replace().withData("inner");
Assertions.assertThat(strategy.process("string")).isEqualTo("inner");
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class SkipFuzzingStrategyTest method givenAString_whenUsingTheSkipFuzzingStrategy_thenTheStringIsCorrectlyProcessed.
@Test
void givenAString_whenUsingTheSkipFuzzingStrategy_thenTheStringIsCorrectlyProcessed() {
FuzzingStrategy strategy = FuzzingStrategy.skip().withData("inner");
Assertions.assertThat(strategy.process("string")).isEqualTo("inner");
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class TrailFuzzingStrategyTest method givenAString_whenUsingTheTrailFuzzingStrategy_thenTheStringIsCorrectlyProcessed.
@Test
void givenAString_whenUsingTheTrailFuzzingStrategy_thenTheStringIsCorrectlyProcessed() {
FuzzingStrategy strategy = FuzzingStrategy.trail().withData("inner");
Assertions.assertThat(strategy.process("string")).isEqualTo("stringinner");
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class CatsUtilTest method givenAPayloadAndAFuzzingStrategy_whenReplacingTheFuzzedValue_thenThePayloadIsProperlyFuzzed.
@ParameterizedTest
@CsvSource(value = { "{\"field\":\"value\", \"anotherField\":\"otherValue\"}|field", "{\"field\": 2, \"anotherField\":\"otherValue\"}|field", "[{\"field\": 2, \"anotherField\":\"otherValue\"},{\"field\": 2, \"anotherField\":\"otherValue\"}]|field", "{\"field\": {\"subField\":\"value\"}, \"anotherField\":\"otherValue\"}|field#subField", "{\"field\": [{\"subField\":\"value\"},{\"subField\":\"value\"}], \"anotherField\":\"otherValue\"}|field[*]#subField" }, delimiter = '|')
void givenAPayloadAndAFuzzingStrategy_whenReplacingTheFuzzedValue_thenThePayloadIsProperlyFuzzed(String json, String path) {
CatsUtil catsUtil = new CatsUtil(new CatsDSLParser());
FuzzingStrategy strategy = FuzzingStrategy.replace().withData("fuzzed");
FuzzingResult result = catsUtil.replaceField(json, path, strategy);
Assertions.assertThat(result.getFuzzedValue()).isEqualTo("fuzzed");
Assertions.assertThat(result.getJson()).contains("fuzzed");
}
use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.
the class WithinControlCharsInFieldsSanitizeValidateFuzzerTest 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 = withinControlCharsInFieldsSanitizeValidateFuzzer.getFieldFuzzingStrategy(data, "field").get(1);
Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(fuzzingStrategy.getData()).contains("\u0007");
Assertions.assertThat(withinControlCharsInFieldsSanitizeValidateFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.TWOXX);
Assertions.assertThat(withinControlCharsInFieldsSanitizeValidateFuzzer.description()).isNotNull();
Assertions.assertThat(withinControlCharsInFieldsSanitizeValidateFuzzer.concreteFuzzStrategy().name()).isEqualTo(FuzzingStrategy.replace().name());
Assertions.assertThat(withinControlCharsInFieldsSanitizeValidateFuzzer.typeOfDataSentToTheService()).isNotNull();
}
Aggregations