use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class BypassAuthenticationFuzzerTest method givenAPayloadWithAuthenticationHeaders_whenApplyingTheBypassAuthenticationFuzzer_thenTheFuzzerRuns.
@Test
void givenAPayloadWithAuthenticationHeaders_whenApplyingTheBypassAuthenticationFuzzer_thenTheFuzzerRuns() {
Map<String, List<String>> responses = new HashMap<>();
responses.put("200", Collections.singletonList("response"));
FuzzingData data = FuzzingData.builder().headers(Collections.singleton(CatsHeader.builder().name("authorization").value("auth").build())).responses(responses).reqSchema(new StringSchema()).build();
CatsResponse catsResponse = CatsResponse.builder().body("{}").responseCode(200).build();
Mockito.when(serviceCaller.call(Mockito.any())).thenReturn(catsResponse);
Mockito.doNothing().when(testCaseListener).reportResult(Mockito.any(), Mockito.eq(data), Mockito.any(), Mockito.any());
bypassAuthenticationFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(1)).reportResult(Mockito.any(), Mockito.eq(data), Mockito.eq(catsResponse), Mockito.eq(ResponseCodeFamily.FOURXX_AA));
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class DummyRequestFuzzerTest method givenAHttpMethodWithoutPayload_whenApplyingTheMalformedJsonFuzzer_thenTheResultsAreCorrectlyReported.
@Test
void givenAHttpMethodWithoutPayload_whenApplyingTheMalformedJsonFuzzer_thenTheResultsAreCorrectlyReported() {
FuzzingData data = FuzzingData.builder().method(HttpMethod.GET).build();
CatsResponse catsResponse = CatsResponse.builder().body("{}").responseCode(400).build();
Mockito.when(serviceCaller.call(Mockito.any())).thenReturn(catsResponse);
Mockito.doNothing().when(testCaseListener).reportResult(Mockito.any(), Mockito.eq(data), Mockito.any(), Mockito.any());
dummyRequestFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(1)).skipTest(Mockito.any(), Mockito.anyString());
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class HttpMethodsFuzzerTest method givenAnOperation_whenCallingTheHttpMethodsFuzzerAndTheServiceResponsesWithA2xx_thenResultsAreCorrectlyReported.
@Test
void givenAnOperation_whenCallingTheHttpMethodsFuzzerAndTheServiceResponsesWithA2xx_thenResultsAreCorrectlyReported() {
FuzzingData data = FuzzingData.builder().pathItem(new PathItem()).reqSchema(new StringSchema()).build();
CatsResponse catsResponse = CatsResponse.builder().body("{}").responseCode(200).httpMethod("POST").build();
Mockito.when(serviceCaller.call(Mockito.any())).thenReturn(catsResponse);
httpMethodsFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(7)).reportError(Mockito.any(), Mockito.anyString(), AdditionalMatchers.aryEq(new Object[] { "POST", 405, 200 }));
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class MalformedJsonFuzzerTest method givenAHttpMethodWithoutPayload_whenApplyingTheMalformedJsonFuzzer_thenTheResultsAreCorrectlyReported.
@Test
void givenAHttpMethodWithoutPayload_whenApplyingTheMalformedJsonFuzzer_thenTheResultsAreCorrectlyReported() {
FuzzingData data = FuzzingData.builder().method(HttpMethod.GET).reqSchema(new StringSchema()).build();
CatsResponse catsResponse = CatsResponse.builder().body("{}").responseCode(400).build();
Mockito.when(serviceCaller.call(Mockito.any())).thenReturn(catsResponse);
Mockito.doNothing().when(testCaseListener).reportResult(Mockito.any(), Mockito.eq(data), Mockito.any(), Mockito.any());
malformedJsonFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(1)).skipTest(Mockito.any(), Mockito.anyString());
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class MalformedJsonFuzzerTest method givenAHttpMethodWithPayload_whenApplyingTheMalformedJsonFuzzer_thenTheResultsAreCorrectlyReported.
@Test
void givenAHttpMethodWithPayload_whenApplyingTheMalformedJsonFuzzer_thenTheResultsAreCorrectlyReported() {
FuzzingData data = FuzzingData.builder().method(HttpMethod.POST).reqSchema(new StringSchema()).build();
CatsResponse catsResponse = CatsResponse.builder().body("{}").responseCode(400).build();
Mockito.when(serviceCaller.call(Mockito.any())).thenReturn(catsResponse);
Mockito.doNothing().when(testCaseListener).reportResult(Mockito.any(), Mockito.eq(data), Mockito.any(), Mockito.any());
malformedJsonFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(1)).reportResult(Mockito.any(), Mockito.eq(data), Mockito.eq(catsResponse), Mockito.eq(ResponseCodeFamily.FOURXX));
}
Aggregations