Search in sources :

Example 11 with CatsHeader

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

the class CheckSecurityHeadersFuzzerTest method shouldNotReportMissingSecurityHeaders.

@Test
void shouldNotReportMissingSecurityHeaders() {
    FuzzingData data = FuzzingData.builder().headers(new HashSet<>(HEADERS)).requestContentTypes(Collections.singletonList("application/json")).reqSchema(new StringSchema()).build();
    Mockito.doNothing().when(testCaseListener).reportResult(Mockito.any(), Mockito.eq(data), Mockito.any(), Mockito.eq(ResponseCodeFamily.TWOXX));
    Mockito.doNothing().when(testCaseListener).reportError(Mockito.any(), Mockito.anyString(), Mockito.any());
    List<CatsHeader> allHeaders = new ArrayList<>(SOME_SECURITY_HEADERS);
    allHeaders.add(CatsHeader.builder().name("dummy").value("dummy").build());
    CatsResponse catsResponse = CatsResponse.builder().body("{}").responseCode(200).headers(Stream.concat(allHeaders.stream(), MISSING_HEADERS.stream()).collect(Collectors.toList())).build();
    Mockito.when(serviceCaller.call(Mockito.any())).thenReturn(catsResponse);
    checkSecurityHeadersFuzzer.fuzz(data);
    Mockito.verify(testCaseListener, Mockito.times(1)).reportResult(Mockito.any(), Mockito.eq(data), Mockito.any(), Mockito.eq(ResponseCodeFamily.TWOXX));
}
Also used : CatsResponse(com.endava.cats.model.CatsResponse) FuzzingData(com.endava.cats.model.FuzzingData) ArrayList(java.util.ArrayList) StringSchema(io.swagger.v3.oas.models.media.StringSchema) HashSet(java.util.HashSet) CatsHeader(com.endava.cats.model.CatsHeader) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

CatsHeader (com.endava.cats.model.CatsHeader)11 CatsResponse (com.endava.cats.model.CatsResponse)6 FuzzingData (com.endava.cats.model.FuzzingData)5 ArrayList (java.util.ArrayList)4 ServiceData (com.endava.cats.io.ServiceData)2 FuzzingStrategy (com.endava.cats.model.FuzzingStrategy)2 TestCaseListener (com.endava.cats.report.TestCaseListener)2 PrettyLogger (io.github.ludovicianul.prettylogger.PrettyLogger)2 PrettyLoggerFactory (io.github.ludovicianul.prettylogger.PrettyLoggerFactory)2 QuarkusTest (io.quarkus.test.junit.QuarkusTest)2 StringSchema (io.swagger.v3.oas.models.media.StringSchema)2 Arrays (java.util.Arrays)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 Test (org.junit.jupiter.api.Test)2 Fuzzer (com.endava.cats.Fuzzer)1 DryRun (com.endava.cats.annotations.DryRun)1 ApiArguments (com.endava.cats.args.ApiArguments)1 AuthArguments (com.endava.cats.args.AuthArguments)1