Search in sources :

Example 1 with FilesArguments

use of com.endava.cats.args.FilesArguments in project cats by Endava.

the class FuzzingDataFactoryTest method setup.

@BeforeEach
void setup() {
    filesArguments = Mockito.mock(FilesArguments.class);
    processingArguments = Mockito.mock(ProcessingArguments.class);
    Mockito.when(processingArguments.isUseExamples()).thenReturn(true);
    Mockito.when(processingArguments.getContentType()).thenReturn("application/json");
    fuzzingDataFactory = new FuzzingDataFactory(filesArguments, processingArguments, catsGlobalContext);
}
Also used : ProcessingArguments(com.endava.cats.args.ProcessingArguments) FilesArguments(com.endava.cats.args.FilesArguments) FuzzingDataFactory(com.endava.cats.factory.FuzzingDataFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with FilesArguments

use of com.endava.cats.args.FilesArguments in project cats by Endava.

the class SecurityFuzzerTest method setup.

@BeforeEach
void setup() {
    catsDSLParser = new CatsDSLParser();
    catsUtil = new CatsUtil(catsDSLParser);
    serviceCaller = Mockito.mock(ServiceCaller.class);
    filesArguments = new FilesArguments(catsUtil);
    customFuzzerUtil = new CustomFuzzerUtil(serviceCaller, catsUtil, testCaseListener, catsDSLParser);
    securityFuzzer = new SecurityFuzzer(filesArguments, customFuzzerUtil);
    ReflectionTestUtils.setField(testCaseListener, "testCaseExporter", Mockito.mock(TestCaseExporter.class));
}
Also used : FilesArguments(com.endava.cats.args.FilesArguments) CatsUtil(com.endava.cats.util.CatsUtil) CustomFuzzerUtil(com.endava.cats.fuzzer.CustomFuzzerUtil) ServiceCaller(com.endava.cats.io.ServiceCaller) TestCaseExporter(com.endava.cats.report.TestCaseExporter) CatsDSLParser(com.endava.cats.dsl.CatsDSLParser) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with FilesArguments

use of com.endava.cats.args.FilesArguments in project cats by Endava.

the class FunctionalFuzzerTest method setup.

@BeforeEach
void setup() {
    catsDSLParser = new CatsDSLParser();
    catsUtil = new CatsUtil(catsDSLParser);
    serviceCaller = Mockito.mock(ServiceCaller.class);
    filesArguments = new FilesArguments(catsUtil);
    customFuzzerUtil = new CustomFuzzerUtil(serviceCaller, catsUtil, testCaseListener, catsDSLParser);
    functionalFuzzer = new FunctionalFuzzer(filesArguments, customFuzzerUtil);
    filesArguments.getCustomFuzzerDetails().clear();
    ReflectionTestUtils.setField(testCaseListener, "testCaseExporter", Mockito.mock(TestCaseExporter.class));
}
Also used : FilesArguments(com.endava.cats.args.FilesArguments) CatsUtil(com.endava.cats.util.CatsUtil) CustomFuzzerUtil(com.endava.cats.fuzzer.CustomFuzzerUtil) ServiceCaller(com.endava.cats.io.ServiceCaller) TestCaseExporter(com.endava.cats.report.TestCaseExporter) CatsDSLParser(com.endava.cats.dsl.CatsDSLParser) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with FilesArguments

use of com.endava.cats.args.FilesArguments in project cats by Endava.

the class FunctionalFuzzerTest method setupFuzzingData.

private FuzzingData setupFuzzingData(CatsResponse catsResponse, JsonObject jsonObject, String... customFieldValues) throws IOException {
    Map<String, List<String>> responses = new HashMap<>();
    responses.put("200", Collections.singletonList("response"));
    FuzzingData data = FuzzingData.builder().path("path1").payload("{\"field\":\"oldValue\"}").responses(responses).responseCodes(Collections.singleton("200")).reqSchema(new StringSchema()).method(HttpMethod.POST).build();
    CatsUtil mockCatsUtil = Mockito.mock(CatsUtil.class);
    Mockito.when(mockCatsUtil.parseYaml(any())).thenReturn(createCustomFuzzerFile(customFieldValues));
    Mockito.when(serviceCaller.call(Mockito.any())).thenReturn(catsResponse);
    filesArguments = new FilesArguments(mockCatsUtil);
    customFuzzerUtil = new CustomFuzzerUtil(serviceCaller, mockCatsUtil, testCaseListener, catsDSLParser);
    functionalFuzzer = new FunctionalFuzzer(filesArguments, customFuzzerUtil);
    ReflectionTestUtils.setField(filesArguments, "customFuzzerFile", new File("custom"));
    return data;
}
Also used : FilesArguments(com.endava.cats.args.FilesArguments) HashMap(java.util.HashMap) CatsUtil(com.endava.cats.util.CatsUtil) FuzzingData(com.endava.cats.model.FuzzingData) CustomFuzzerUtil(com.endava.cats.fuzzer.CustomFuzzerUtil) List(java.util.List) StringSchema(io.swagger.v3.oas.models.media.StringSchema) File(java.io.File)

Example 5 with FilesArguments

use of com.endava.cats.args.FilesArguments in project cats by Endava.

the class AbugidasCharsInStringFieldsSanitizeValidateFuzzerTest method setup.

@BeforeEach
void setup() {
    ServiceCaller serviceCaller = Mockito.mock(ServiceCaller.class);
    TestCaseListener testCaseListener = Mockito.mock(TestCaseListener.class);
    FilesArguments filesArguments = Mockito.mock(FilesArguments.class);
    abugidasCharsInStringFieldsSanitizeValidateFuzzer = new AbugidasCharsInStringFieldsSanitizeValidateFuzzer(serviceCaller, testCaseListener, catsUtil, filesArguments);
    Mockito.when(testCaseListener.isFieldNotADiscriminator(Mockito.anyString())).thenReturn(true);
    Mockito.when(testCaseListener.isFieldNotADiscriminator("pet#type")).thenReturn(false);
}
Also used : FilesArguments(com.endava.cats.args.FilesArguments) ServiceCaller(com.endava.cats.io.ServiceCaller) TestCaseListener(com.endava.cats.report.TestCaseListener) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

FilesArguments (com.endava.cats.args.FilesArguments)11 BeforeEach (org.junit.jupiter.api.BeforeEach)10 ServiceCaller (com.endava.cats.io.ServiceCaller)8 TestCaseListener (com.endava.cats.report.TestCaseListener)6 CatsUtil (com.endava.cats.util.CatsUtil)4 CustomFuzzerUtil (com.endava.cats.fuzzer.CustomFuzzerUtil)3 TestCaseExporter (com.endava.cats.report.TestCaseExporter)3 CatsDSLParser (com.endava.cats.dsl.CatsDSLParser)2 File (java.io.File)2 ProcessingArguments (com.endava.cats.args.ProcessingArguments)1 FuzzingDataFactory (com.endava.cats.factory.FuzzingDataFactory)1 FuzzingData (com.endava.cats.model.FuzzingData)1 StringSchema (io.swagger.v3.oas.models.media.StringSchema)1 HashMap (java.util.HashMap)1 List (java.util.List)1