use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class RemoveHeadersFuzzerTest method givenASetOfHeadersWithRequiredHeaders_whenApplyingTheRemoveHeadersFuzzer_thenTheHeadersAreProperlyFuzzed.
@Test
void givenASetOfHeadersWithRequiredHeaders_whenApplyingTheRemoveHeadersFuzzer_thenTheHeadersAreProperlyFuzzed() {
Map<String, List<String>> responses = new HashMap<>();
responses.put("400", Collections.singletonList("response"));
FuzzingData data = FuzzingData.builder().headers(Collections.singleton(CatsHeader.builder().name("header").value("value").required(true).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());
removeHeadersFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(1)).reportResult(Mockito.any(), Mockito.eq(data), Mockito.eq(catsResponse), Mockito.eq(ResponseCodeFamily.TWOXX));
Mockito.verify(testCaseListener, Mockito.times(1)).reportResult(Mockito.any(), Mockito.eq(data), Mockito.eq(catsResponse), Mockito.eq(ResponseCodeFamily.FOURXX));
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class RemoveHeadersFuzzerTest method givenASetOfHeadersWithNoRequiredHeaders_whenApplyingTheRemoveHeadersFuzzer_thenTheHeadersAreProperlyFuzzed.
@Test
void givenASetOfHeadersWithNoRequiredHeaders_whenApplyingTheRemoveHeadersFuzzer_thenTheHeadersAreProperlyFuzzed() {
Map<String, List<String>> responses = new HashMap<>();
responses.put("200", Collections.singletonList("response"));
FuzzingData data = FuzzingData.builder().headers(Collections.singleton(CatsHeader.builder().name("header").value("value").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());
removeHeadersFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(2)).reportResult(Mockito.any(), Mockito.eq(data), Mockito.eq(catsResponse), Mockito.eq(ResponseCodeFamily.TWOXX));
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class ServiceCallerTest method givenAServer_whenDoingAHeadCall_thenProperDetailsAreBeingReturned.
@Test
void givenAServer_whenDoingAHeadCall_thenProperDetailsAreBeingReturned() {
serviceCaller.initHttpClient();
serviceCaller.initRateLimiter();
CatsResponse catsResponse = serviceCaller.call(ServiceData.builder().relativePath("/pets/{id}").payload("{'id':'1'}").httpMethod(HttpMethod.HEAD).headers(Collections.singleton(CatsHeader.builder().name("header").value("header").build())).build());
Assertions.assertThat(catsResponse.responseCodeAsString()).isEqualTo("200");
Assertions.assertThat(catsResponse.getBody()).isEmpty();
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class ServiceCallerTest method givenAServer_whenDoingAPatchCall_thenProperDetailsAreBeingReturned.
@Test
void givenAServer_whenDoingAPatchCall_thenProperDetailsAreBeingReturned() {
serviceCaller.initHttpClient();
serviceCaller.initRateLimiter();
CatsResponse catsResponse = serviceCaller.call(ServiceData.builder().relativePath("/pets").payload("{'id':'1'}").httpMethod(HttpMethod.PATCH).headers(Collections.singleton(CatsHeader.builder().name("header").value("header").build())).build());
Assertions.assertThat(catsResponse.responseCodeAsString()).isEqualTo("200");
Assertions.assertThat(catsResponse.getBody()).isEmpty();
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class ServiceCallerTest method givenAServer_whenDoingAPutCall_thenProperDetailsAreBeingReturned.
@Test
void givenAServer_whenDoingAPutCall_thenProperDetailsAreBeingReturned() {
serviceCaller.initHttpClient();
serviceCaller.initRateLimiter();
CatsResponse catsResponse = serviceCaller.call(ServiceData.builder().relativePath("/pets").payload("{'field':'newValue'}").httpMethod(HttpMethod.PUT).headers(Collections.singleton(CatsHeader.builder().name("header").value("header").build())).build());
Assertions.assertThat(catsResponse.responseCodeAsString()).isEqualTo("200");
Assertions.assertThat(catsResponse.getBody()).isEqualTo("{'result':'OK'}");
}
Aggregations