Search in sources :

Example 1 with FuzzingConstraints

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

the class BaseFieldsFuzzer method process.

protected void process(FuzzingData data, String fuzzedField, FuzzingStrategy fuzzingStrategy) {
    FuzzingConstraints fuzzingConstraints = this.createFuzzingConstraints(data, fuzzingStrategy, fuzzedField);
    testCaseListener.addScenario(logger, "Send [{}] in request fields: field [{}], value [{}], is required [{}]", this.typeOfDataSentToTheService(), fuzzedField, fuzzingStrategy.truncatedValue(), fuzzingConstraints.getRequiredString());
    if (this.isFuzzingPossible(data, fuzzedField, fuzzingStrategy)) {
        FuzzingResult fuzzingResult = catsUtil.replaceField(data.getPayload(), fuzzedField, fuzzingStrategy);
        boolean isFuzzedValueMatchingPattern = this.isFuzzedValueMatchingPattern(fuzzingResult.getFuzzedValue(), data, fuzzedField);
        ServiceData serviceData = ServiceData.builder().relativePath(data.getPath()).headers(data.getHeaders()).payload(fuzzingResult.getJson()).httpMethod(data.getMethod()).fuzzedField(fuzzedField).queryParams(data.getQueryParams()).build();
        CatsResponse response = serviceCaller.call(serviceData);
        ResponseCodeFamily expectedResponseCodeBasedOnConstraints = this.getExpectedResponseCodeBasedOnConstraints(isFuzzedValueMatchingPattern, fuzzingConstraints);
        testCaseListener.addExpectedResult(logger, "Should return [{}]", expectedResponseCodeBasedOnConstraints.asString());
        testCaseListener.reportResult(logger, data, response, expectedResponseCodeBasedOnConstraints);
    } else {
        FuzzingStrategy strategy = this.createSkipStrategy(fuzzingStrategy);
        testCaseListener.skipTest(logger, strategy.process(""));
    }
}
Also used : CatsResponse(com.endava.cats.model.CatsResponse) ResponseCodeFamily(com.endava.cats.http.ResponseCodeFamily) FuzzingStrategy(com.endava.cats.model.FuzzingStrategy) FuzzingResult(com.endava.cats.model.FuzzingResult) FuzzingConstraints(com.endava.cats.model.FuzzingConstraints) ServiceData(com.endava.cats.io.ServiceData)

Aggregations

ResponseCodeFamily (com.endava.cats.http.ResponseCodeFamily)1 ServiceData (com.endava.cats.io.ServiceData)1 CatsResponse (com.endava.cats.model.CatsResponse)1 FuzzingConstraints (com.endava.cats.model.FuzzingConstraints)1 FuzzingResult (com.endava.cats.model.FuzzingResult)1 FuzzingStrategy (com.endava.cats.model.FuzzingStrategy)1