Search in sources :

Example 61 with FuzzingStrategy

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());
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) StringSchema(io.swagger.v3.oas.models.media.StringSchema) NumberSchema(io.swagger.v3.oas.models.media.NumberSchema) Schema(io.swagger.v3.oas.models.media.Schema) FuzzingData(com.endava.cats.model.FuzzingData) NumberSchema(io.swagger.v3.oas.models.media.NumberSchema) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 62 with FuzzingStrategy

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);
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) StringSchema(io.swagger.v3.oas.models.media.StringSchema) NumberSchema(io.swagger.v3.oas.models.media.NumberSchema) 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) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 63 with FuzzingStrategy

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());
}
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 64 with FuzzingStrategy

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();
}
Also used : FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 65 with FuzzingStrategy

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();
}
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