use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class DuplicateHeaderFuzzer method process.
private void process(FuzzingData data, List<CatsHeader> headers, CatsHeader targetHeader) {
testCaseListener.addScenario(LOGGER, "Add a duplicate header inside the request: name [{}], value [{}]. All other details are similar to a happy flow", targetHeader.getName(), targetHeader.getTruncatedValue());
testCaseListener.addExpectedResult(LOGGER, "Should get a 4XX response code");
CatsResponse response = serviceCaller.call(ServiceData.builder().relativePath(data.getPath()).headers(headers).payload(data.getPayload()).queryParams(data.getQueryParams()).httpMethod(data.getMethod()).build());
testCaseListener.reportResult(LOGGER, data, response, ResponseCodeFamily.FOURXX);
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class RemoveHeadersFuzzer method process.
private void process(FuzzingData data, Set<CatsHeader> headersSubset, Set<CatsHeader> requiredHeaders) {
testCaseListener.addScenario(LOGGER, "Send only the following headers: {} plus any authentication headers.", headersSubset);
boolean anyMandatoryHeaderRemoved = this.isAnyMandatoryHeaderRemoved(headersSubset, requiredHeaders);
testCaseListener.addExpectedResult(LOGGER, "Should return [{}] response code as mandatory headers [{}] removed", ResponseCodeFamily.getExpectedWordingBasedOnRequiredFields(anyMandatoryHeaderRemoved));
CatsResponse response = serviceCaller.call(ServiceData.builder().relativePath(data.getPath()).headers(headersSubset).payload(data.getPayload()).addUserHeaders(false).queryParams(data.getQueryParams()).httpMethod(data.getMethod()).build());
testCaseListener.reportResult(LOGGER, data, response, ResponseCodeFamily.getResultCodeBasedOnRequiredFieldsRemoved(anyMandatoryHeaderRemoved));
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class BaseHeadersFuzzer method process.
private void process(FuzzingData data, Set<CatsHeader> clonedHeaders, CatsHeader header, FuzzingStrategy fuzzingStrategy) {
String previousHeaderValue = header.getValue();
header.withValue(fuzzingStrategy.process(previousHeaderValue));
try {
boolean isRequiredHeaderFuzzed = clonedHeaders.stream().filter(CatsHeader::isRequired).collect(Collectors.toList()).contains(header);
testCaseListener.addScenario(logger, "Send [{}] in headers: header [{}] with value [{}]", this.typeOfDataSentToTheService(), header.getName(), fuzzingStrategy.truncatedValue());
testCaseListener.addExpectedResult(logger, "Should get a [{}] response code", this.getExpectedResultCode(isRequiredHeaderFuzzed).asString());
ServiceData serviceData = ServiceData.builder().relativePath(data.getPath()).headers(clonedHeaders).payload(data.getPayload()).fuzzedHeader(header.getName()).queryParams(data.getQueryParams()).httpMethod(data.getMethod()).build();
CatsResponse response = serviceCaller.call(serviceData);
testCaseListener.reportResult(logger, data, response, this.getExpectedResultCode(isRequiredHeaderFuzzed), this.matchResponseSchema());
} finally {
/* we reset back the current header */
header.withValue(previousHeaderValue);
}
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class BaseSecurityChecksHeadersFuzzer method process.
private void process(FuzzingData data, Set<CatsHeader> headers) {
String headerValue = headers.stream().filter(header -> header.getName().equalsIgnoreCase(targetHeaderName())).findFirst().orElse(CatsHeader.builder().build()).getValue();
testCaseListener.addScenario(log, "Send a happy flow request with a [{}] {} header, value [{}]", typeOfHeader(), targetHeaderName(), headerValue);
testCaseListener.addExpectedResult(log, "Should get a {} response code", getExpectedResponseCode());
CatsResponse response = serviceCaller.call(ServiceData.builder().relativePath(data.getPath()).headers(new ArrayList<>(headers)).payload(data.getPayload()).queryParams(data.getQueryParams()).httpMethod(data.getMethod()).build());
testCaseListener.reportResult(log, data, response, ResponseCodeFamily.FOURXX_MT);
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class BaseHttpWithPayloadSimpleFuzzer method process.
private void process(FuzzingData data) {
testCaseListener.addScenario(logger, this.getScenario());
testCaseListener.addExpectedResult(logger, "Should get a 4XX response code");
ServiceData serviceData = ServiceData.builder().relativePath(data.getPath()).headers(data.getHeaders()).payload(this.getPayload(data)).replaceRefData(false).httpMethod(data.getMethod()).build();
if (JsonUtils.isHttpMethodWithPayload(data.getMethod())) {
CatsResponse response = serviceCaller.call(serviceData);
testCaseListener.reportResult(logger, data, response, ResponseCodeFamily.FOURXX);
} else {
testCaseListener.skipTest(logger, "Method " + data.getMethod() + " not supported by " + this);
}
}
Aggregations