I'm looking for some clarity on how to approach API testing holistically, I have a project to automate a Restful web service, containing 2 controllers(foo & bar) with a collective sum of around ~30 calls available.
Some implications - There are no test cases written for this, so I'm not coming along and automating what is already existing, I have to write those cases myself.
I have added integration capabilities into my test framework already and did all the heavy lifting, so now I'm just left with my internal service which takes an object, parses it to json and using rest assured makes the calls, returing me the response, here is a small example:
@Test
@Step
@Severity(SeverityLevel.CRITICAL)
@TmsLink("19793")
@DisplayName("SaveCourse: User can add a new course")
public void savecourse_user_can_add_a_new_course_successfully_returns_200() {
log.info("-- Test: Successfully adding a new course --");
Course c = new Course(0, data.randomString(20), data.randomString(20), 0, 1, false);
Response response = ets.saveCourse(c, statusOK);
resultModel = new GeneralResultModel(false, ets.getCourseSuccessfullySaved(), response.path("Result").toString(), null);
GeneralResultModel result = response.as((GeneralResultModel.class));
assertThat(resultModel).isEqualTo(result);
}
Lets consider the saveCourse takes a course object(JSON) in the request and lets assume it contains the following information:
id (long)
name (String)
description (string)
locationId (long)
iconId (long)
Payload example:
{
"id": 0,
"Name": "abc;",
"Description": "aa",
"locationId ": 0,
"iconId ": 1
}
When crafting JSON requests for this call for the controller to handle, how do we best approach this for test case derivation that isn't bordering on insanity? I could think of hundreds of combinations and invalid data types, sql injection, xss, empty, duplicates etc! the list could go on forever here.
How do we, as testers best approach this to cover the API to a good level while maintaining its security etc. Worth noting that this API is a private API and just used with a front end in a micro service setup.
Thank you for your time.