use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class HttpStatusCodeInValidRangeContractInfoFuzzerTest method shouldReportInfoWhenAllResponseCodesAreValid.
@ParameterizedTest
@CsvSource({ "100", "200", "599", "default" })
void shouldReportInfoWhenAllResponseCodesAreValid(String responseCode) {
FuzzingData data = ContractFuzzerDataUtil.prepareFuzzingData("PetStore", responseCode);
httpStatusCodeInValidRangeContractInfoFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(1)).reportInfo(Mockito.any(), Mockito.eq("All defined response codes are valid!"));
}
use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class NamingsContractInfoFuzzerTest method shouldReportErrorWhenJsonObjectsNotMatchingCamelCase.
@ParameterizedTest
@CsvSource({ "first_Payload-test", "secondpayload_tesAaa" })
void shouldReportErrorWhenJsonObjectsNotMatchingCamelCase(String schemaName) {
FuzzingData data = ContractFuzzerDataUtil.prepareFuzzingData(schemaName, "200");
namingsContractInfoFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(1)).reportError(Mockito.any(), Mockito.eq("Path does not follow RESTful API naming good practices: {}"), Mockito.contains(String.format("The following request/response objects are not matching CamelCase, snake_case or hyphen-case: <strong>%s</strong><br /><br />", schemaName)));
}
use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class NamingsContractInfoFuzzerTest method shouldMatchRestNamingStandards.
@ParameterizedTest
@CsvSource({ "first_payload", "SecondPayload", "third-payload", "body_120" })
void shouldMatchRestNamingStandards(String schemaName) {
FuzzingData data = ContractFuzzerDataUtil.prepareFuzzingData(schemaName, "200");
namingsContractInfoFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(1)).reportInfo(Mockito.any(), Mockito.eq("Path follows the RESTful API naming good practices."));
}
use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class TopLevelElementsContractInfoFuzzerTest method shouldNotReportAnyError.
@Test
void shouldNotReportAnyError() throws Exception {
OpenAPI openAPI = new OpenAPIParser().readContents(new String(Files.readAllBytes(Paths.get("src/test/resources/openapi.yml"))), null, null).getOpenAPI();
FuzzingData data = FuzzingData.builder().openApi(openAPI).build();
topLevelElementsContractInfoFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(1)).reportInfo(Mockito.any(), Mockito.contains("OpenAPI contract contains all top level relevant information!"));
}
use of com.endava.cats.model.FuzzingData in project cats by Endava.
the class TopLevelElementsContractInfoFuzzerTest method shouldReportError.
@ParameterizedTest
@CsvSource({ "src/test/resources/contract-missing-info.yml,info.version, info.contact.url, info.description, info.contact.name, info.title, info.contact.email", "src/test/resources/contract-missing-servers.yml,servers", "src/test/resources/contract-missing-tags.yml,tags", "src/test/resources/contract-incomplete-contact.yml,info.contact.url, info.contact.email", "src/test/resources/contract-incomplete-tags.yml,tags,description" })
void shouldReportError(String contractPath, String expectedError) throws Exception {
OpenAPI openAPI = new OpenAPIParser().readContents(new String(Files.readAllBytes(Paths.get(contractPath))), null, null).getOpenAPI();
FuzzingData data = FuzzingData.builder().openApi(openAPI).build();
topLevelElementsContractInfoFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(1)).reportError(Mockito.any(), Mockito.contains(expectedError));
}
Aggregations