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