Search in sources :

Example 56 with FuzzingStrategy

use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.

the class WithinControlCharsInFieldsValidateSanitizeFuzzerTest 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 = controlCharsWithinFieldsValidateSanitizeFuzzer.getFieldFuzzingStrategy(data, "field").get(1);
    Assertions.assertThat(fuzzingStrategy.getData()).contains("\u0007");
    Assertions.assertThat(controlCharsWithinFieldsValidateSanitizeFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.FOURXX);
    Assertions.assertThat(controlCharsWithinFieldsValidateSanitizeFuzzer.getExpectedHttpCodeWhenOptionalFieldsAreFuzzed()).isEqualTo(ResponseCodeFamily.FOURXX);
    Assertions.assertThat(controlCharsWithinFieldsValidateSanitizeFuzzer.getExpectedHttpCodeWhenRequiredFieldsAreFuzzed()).isEqualTo(ResponseCodeFamily.FOURXX);
    Assertions.assertThat(controlCharsWithinFieldsValidateSanitizeFuzzer.description()).isNotNull();
    Assertions.assertThat(controlCharsWithinFieldsValidateSanitizeFuzzer.typeOfDataSentToTheService()).isNotNull();
    Assertions.assertThat(controlCharsWithinFieldsValidateSanitizeFuzzer.concreteFuzzStrategy().name()).isEqualTo(FuzzingStrategy.replace().name());
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) HashMap(java.util.HashMap) StringSchema(io.swagger.v3.oas.models.media.StringSchema) Schema(io.swagger.v3.oas.models.media.Schema) FuzzingData(com.endava.cats.model.FuzzingData) StringSchema(io.swagger.v3.oas.models.media.StringSchema) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 57 with FuzzingStrategy

use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.

the class WithinMultiCodePointEmojisInFieldsTrimValidateFuzzerTest 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 = withinMultiCodePointEmojisInFieldsTrimValidateFuzzer.getFieldFuzzingStrategy(data, "field").get(1);
    Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
    Assertions.assertThat(fuzzingStrategy.getData()).contains("\uD83D\uDC68\u200D\uD83C\uDFED️");
    Assertions.assertThat(withinMultiCodePointEmojisInFieldsTrimValidateFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.TWOXX);
    Assertions.assertThat(withinMultiCodePointEmojisInFieldsTrimValidateFuzzer.description()).isNotNull();
    Assertions.assertThat(withinMultiCodePointEmojisInFieldsTrimValidateFuzzer.concreteFuzzStrategy().name()).isEqualTo(FuzzingStrategy.replace().name());
    Assertions.assertThat(withinMultiCodePointEmojisInFieldsTrimValidateFuzzer.typeOfDataSentToTheService()).isNotNull();
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) HashMap(java.util.HashMap) StringSchema(io.swagger.v3.oas.models.media.StringSchema) Schema(io.swagger.v3.oas.models.media.Schema) FuzzingData(com.endava.cats.model.FuzzingData) StringSchema(io.swagger.v3.oas.models.media.StringSchema) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 58 with FuzzingStrategy

use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.

the class WithinSingleCodePointEmojisInFieldsTrimValidateFuzzerTest 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 = withinSingleCodePointEmojisInFieldsTrimValidateFuzzer.getFieldFuzzingStrategy(data, "field").get(1);
    Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.replace().name());
    Assertions.assertThat(fuzzingStrategy.getData()).contains("\uD83D\uDC80");
    Assertions.assertThat(withinSingleCodePointEmojisInFieldsTrimValidateFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.TWOXX);
    Assertions.assertThat(withinSingleCodePointEmojisInFieldsTrimValidateFuzzer.description()).isNotNull();
    Assertions.assertThat(withinSingleCodePointEmojisInFieldsTrimValidateFuzzer.concreteFuzzStrategy().name()).isEqualTo(FuzzingStrategy.replace().name());
    Assertions.assertThat(withinSingleCodePointEmojisInFieldsTrimValidateFuzzer.typeOfDataSentToTheService()).isNotNull();
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) HashMap(java.util.HashMap) StringSchema(io.swagger.v3.oas.models.media.StringSchema) Schema(io.swagger.v3.oas.models.media.Schema) FuzzingData(com.endava.cats.model.FuzzingData) StringSchema(io.swagger.v3.oas.models.media.StringSchema) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 59 with FuzzingStrategy

use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.

the class TrailingMultiCodePointEmojisInFieldsTrimValidateFuzzerTest method shouldProperlyOverrideMethods.

@Test
void shouldProperlyOverrideMethods() {
    FuzzingStrategy fuzzingStrategy = trailingMultiCodePointEmojisInFieldsTrimValidateFuzzer.getFieldFuzzingStrategy(null, null).get(1);
    Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.trail().name());
    Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo("\uD83D\uDC68\u200D\uD83C\uDFED️");
    Assertions.assertThat(trailingMultiCodePointEmojisInFieldsTrimValidateFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.TWOXX);
    Assertions.assertThat(trailingMultiCodePointEmojisInFieldsTrimValidateFuzzer.description()).isNotNull();
    Assertions.assertThat(trailingMultiCodePointEmojisInFieldsTrimValidateFuzzer.typeOfDataSentToTheService()).isNotNull();
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 60 with FuzzingStrategy

use of com.endava.cats.model.FuzzingStrategy in project cats by Endava.

the class TrailingSingleCodePointEmojisInFieldsValidateTrimFuzzerTest method givenANewTrailingTabsInFieldsValidateTrimFuzzer_whenCreatingANewInstance_thenTheMethodsBeingOverriddenAreMatchingTheTrailingTabsInFieldsValidateTrimFuzzer.

@Test
void givenANewTrailingTabsInFieldsValidateTrimFuzzer_whenCreatingANewInstance_thenTheMethodsBeingOverriddenAreMatchingTheTrailingTabsInFieldsValidateTrimFuzzer() {
    FuzzingStrategy fuzzingStrategy = trailingSingleCodePointEmojisInFieldsValidateTrimFuzzer.getFieldFuzzingStrategy(null, null).get(1);
    Assertions.assertThat(fuzzingStrategy.name()).isEqualTo(FuzzingStrategy.trail().name());
    Assertions.assertThat(fuzzingStrategy.getData()).isEqualTo("\uD83D\uDC80");
    Assertions.assertThat(trailingSingleCodePointEmojisInFieldsValidateTrimFuzzer.getExpectedHttpCodeWhenFuzzedValueNotMatchesPattern()).isEqualTo(ResponseCodeFamily.FOURXX);
    Assertions.assertThat(trailingSingleCodePointEmojisInFieldsValidateTrimFuzzer.getExpectedHttpCodeWhenOptionalFieldsAreFuzzed()).isEqualTo(ResponseCodeFamily.FOURXX);
    Assertions.assertThat(trailingSingleCodePointEmojisInFieldsValidateTrimFuzzer.getExpectedHttpCodeWhenRequiredFieldsAreFuzzed()).isEqualTo(ResponseCodeFamily.FOURXX);
    Assertions.assertThat(trailingSingleCodePointEmojisInFieldsValidateTrimFuzzer.description()).isNotNull();
    Assertions.assertThat(trailingSingleCodePointEmojisInFieldsValidateTrimFuzzer.typeOfDataSentToTheService()).isNotNull();
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Aggregations

FuzzingStrategy (com.endava.cats.model.FuzzingStrategy)67 QuarkusTest (io.quarkus.test.junit.QuarkusTest)62 Test (org.junit.jupiter.api.Test)62 FuzzingData (com.endava.cats.model.FuzzingData)35 StringSchema (io.swagger.v3.oas.models.media.StringSchema)34 Schema (io.swagger.v3.oas.models.media.Schema)30 HashMap (java.util.HashMap)27 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 NumberSchema (io.swagger.v3.oas.models.media.NumberSchema)4 CatsDSLParser (com.endava.cats.dsl.CatsDSLParser)3 FuzzingResult (com.endava.cats.model.FuzzingResult)3 CatsHeader (com.endava.cats.model.CatsHeader)2 CatsResponse (com.endava.cats.model.CatsResponse)2 DryRun (com.endava.cats.annotations.DryRun)1 ApiArguments (com.endava.cats.args.ApiArguments)1 AuthArguments (com.endava.cats.args.AuthArguments)1 FilesArguments (com.endava.cats.args.FilesArguments)1 ProcessingArguments (com.endava.cats.args.ProcessingArguments)1 CatsDSLWords (com.endava.cats.dsl.CatsDSLWords)1 ADDITIONAL_PROPERTIES (com.endava.cats.dsl.CatsDSLWords.ADDITIONAL_PROPERTIES)1