use of com.endava.cats.model.CatsHeader in project cats by Endava.
the class RecommendedHeadersContractInfoFuzzerTest method shouldReportInfo.
@ParameterizedTest
@CsvSource({ "X-Trace-Id", "XTraceid", "X-CorrelationId", "X-APP-Correlation_Id" })
void shouldReportInfo(String header) {
CatsHeader catsHeader = CatsHeader.builder().name(header).build();
FuzzingData data = FuzzingData.builder().headers(Sets.newHashSet(catsHeader)).method(HttpMethod.POST).build();
recommendedHeadersContractInfoFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(1)).reportInfo(Mockito.any(), Mockito.eq("Path contains the recommended [TracedId/CorrelationId] headers for HTTP method {}"), Mockito.eq(HttpMethod.POST));
}
use of com.endava.cats.model.CatsHeader in project cats by Endava.
the class CheckSecurityHeadersFuzzer method process.
private void process(FuzzingData data) {
testCaseListener.addScenario(log, "Send a happy flow request and check the following Security Headers: {}", SECURITY_HEADERS_AS_STRING);
testCaseListener.addExpectedResult(log, "Should get a 2XX response code and all the above security headers within the response");
CatsResponse response = serviceCaller.call(ServiceData.builder().relativePath(data.getPath()).headers(data.getHeaders()).payload(data.getPayload()).queryParams(data.getQueryParams()).httpMethod(data.getMethod()).build());
List<CatsHeader> missingSecurityHeaders = getMissingSecurityHeaders(response);
if (!missingSecurityHeaders.isEmpty()) {
testCaseListener.reportError(log, "Missing recommended Security Headers: {}", missingSecurityHeaders.stream().map(CatsHeader::nameAndValue).collect(Collectors.toSet()));
} else {
testCaseListener.reportResult(log, data, response, ResponseCodeFamily.TWOXX);
}
}
use of com.endava.cats.model.CatsHeader in project cats by Endava.
the class ExtraHeaderFuzzer method process.
private void process(FuzzingData data) {
Set<CatsHeader> headerSet = new HashSet<>(data.getHeaders());
headerSet.add(CatsHeader.builder().name(CATS_FUZZY_HEADER).required(false).value(CATS_FUZZY_HEADER).build());
testCaseListener.addScenario(LOGGER, "Add extra header inside the request: name [{}], value [{}]. All other details are similar to a happy flow", CATS_FUZZY_HEADER, CATS_FUZZY_HEADER);
testCaseListener.addExpectedResult(LOGGER, "Should get a 2XX response code");
CatsResponse response = serviceCaller.call(ServiceData.builder().relativePath(data.getPath()).httpMethod(data.getMethod()).headers(headerSet).payload(data.getPayload()).queryParams(data.getQueryParams()).build());
testCaseListener.reportResult(LOGGER, data, response, ResponseCodeFamily.TWOXX);
}
use of com.endava.cats.model.CatsHeader in project cats by Endava.
the class RecommendedHeadersContractInfoFuzzerTest method shouldReportError.
@ParameterizedTest
@CsvSource({ "X-Trac-Id", "XTracing", "X-Correlation", "X-APP-Correlation*Id" })
void shouldReportError(String header) {
CatsHeader catsHeader = CatsHeader.builder().name(header).build();
FuzzingData data = FuzzingData.builder().headers(Sets.newHashSet(catsHeader)).method(HttpMethod.POST).build();
recommendedHeadersContractInfoFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(1)).reportError(Mockito.any(), Mockito.eq("Path does not contain the recommended [TracedId/CorrelationId] headers for HTTP method {}"), Mockito.eq(HttpMethod.POST));
}
use of com.endava.cats.model.CatsHeader in project cats by Endava.
the class BypassAuthenticationFuzzerTest method shouldProperlyIdentifyAuthHeadersFromContract.
@Test
void shouldProperlyIdentifyAuthHeadersFromContract() {
List<CatsHeader> headers = Arrays.asList(CatsHeader.builder().name("jwt").build(), CatsHeader.builder().name("authorization").build(), CatsHeader.builder().name("api-key").build(), CatsHeader.builder().name("api_key").build(), CatsHeader.builder().name("cats").build());
FuzzingData data = FuzzingData.builder().headers(new HashSet<>(headers)).reqSchema(new StringSchema()).build();
Set<String> authHeaders = bypassAuthenticationFuzzer.getAuthenticationHeaderProvided(data);
Assertions.assertThat(authHeaders).containsExactlyInAnyOrder("jwt", "api-key", "authorization", "api_key");
}
Aggregations