use of com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc in project sechub by mercedes-benz.
the class ConfigAdministrationRestControllerRestDocTest method restdoc_admin_fetches_auto_cleanup_configuration.
@Test
@UseCaseRestDoc(useCase = UseCaseAdminFetchesAutoCleanupConfiguration.class)
public void restdoc_admin_fetches_auto_cleanup_configuration() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildAdminFetchesAutoCleanupConfigurationUrl();
Class<? extends Annotation> useCase = UseCaseAdminFetchesAutoCleanupConfiguration.class;
AdministrationAutoCleanupConfig config = new AdministrationAutoCleanupConfig();
when(configService.fetchAutoCleanupConfiguration()).thenReturn(config);
/* execute + test @formatter:off */
this.mockMvc.perform(get(apiEndpoint).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().json(config.toJSON())).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).and().document());
/* @formatter:on */
}
use of com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc in project sechub by mercedes-benz.
the class FalsePositiveRestControllerRestDocTest method restdoc_mark_false_positives_for_job.
@Test
@UseCaseRestDoc(useCase = UseCaseUserMarksFalsePositivesForJob.class)
public void restdoc_mark_false_positives_for_job() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildUserAddsFalsePositiveJobDataListForProject(PROJECT_ID.pathElement());
Class<? extends Annotation> useCase = UseCaseUserMarksFalsePositivesForJob.class;
FalsePositiveJobDataList jobDataList = new FalsePositiveJobDataList();
jobDataList.setApiVersion("1.0");
List<FalsePositiveJobData> list = jobDataList.getJobData();
FalsePositiveJobData data = new FalsePositiveJobData();
data.setComment("an optional comment why this is a false positive...");
data.setFindingId(42);
data.setJobUUID(UUID.fromString("f1d02a9d-5e1b-4f52-99e5-401854ccf936"));
list.add(data);
String content = jobDataList.toJSON();
/* execute + test @formatter:off */
this.mockMvc.perform(put(apiEndpoint, PROJECT1_ID).contentType(MediaType.APPLICATION_JSON_VALUE).content(content)).andExpect(status().isOk()).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).requestSchema(OpenApiSchema.FALSE_POSITVES_FOR_JOB.getSchema()).and().document(requestFields(fieldWithPath(PROPERTY_API_VERSION).description("The api version, currently only 1.0 is supported"), fieldWithPath(PROPERTY_TYPE).description("The type of the json content. Currently only accepted value is '" + FalsePositiveJobDataList.ACCEPTED_TYPE + "'."), fieldWithPath(PROPERTY_JOBDATA).description("Job data list containing false positive setup based on former jobs"), fieldWithPath(PROPERTY_JOBDATA + "[]." + PROPERTY_JOBUUID).description("SecHub job uuid where finding was"), fieldWithPath(PROPERTY_JOBDATA + "[]." + PROPERTY_FINDINGID).description("SecHub finding identifier - identifies problem inside the job which shall be markeda as a false positive. *ATTENTION*: at the moment only code scan false positive handling is supported. Infra and web scan findings will lead to a non accepted error!"), fieldWithPath(PROPERTY_JOBDATA + "[]." + PROPERTY_COMMENT).optional().description("A comment describing why this is a false positive")), pathParameters(parameterWithName(PROJECT_ID.paramName()).description("The projectId of the project where users adds false positives for"))));
/* @formatter:on */
}
use of com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc in project sechub by mercedes-benz.
the class JobAdministrationRestControllerRestDocTest method restdoc_restart_job.
@Test
@UseCaseRestDoc(useCase = UseCaseAdminRestartsJob.class)
public void restdoc_restart_job() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildAdminRestartsJob(JOB_UUID.pathElement());
Class<? extends Annotation> useCase = UseCaseAdminRestartsJob.class;
/* execute + test @formatter:off */
UUID jobUUID = UUID.randomUUID();
this.mockMvc.perform(post(apiEndpoint, jobUUID).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).and().document(pathParameters(parameterWithName(JOB_UUID.paramName()).description("The job UUID"))));
/* @formatter:on */
}
use of com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc in project sechub by mercedes-benz.
the class JobAdministrationRestControllerRestDocTest method restdoc_restart_job_hard.
@Test
@UseCaseRestDoc(useCase = UseCaseAdminRestartsJobHard.class)
public void restdoc_restart_job_hard() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildAdminRestartsJobHard(JOB_UUID.pathElement());
Class<? extends Annotation> useCase = UseCaseAdminRestartsJobHard.class;
/* execute + test @formatter:off */
UUID jobUUID = UUID.randomUUID();
this.mockMvc.perform(post(apiEndpoint, jobUUID).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).and().document(pathParameters(parameterWithName(JOB_UUID.paramName()).description("The job UUID"))));
/* @formatter:on */
}
use of com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc in project sechub by mercedes-benz.
the class ProductExecutionProfileRestControllerRestDocTest method restDoc_admin_fetches_profiles_list.
@Test
@UseCaseRestDoc(useCase = UseCaseAdminFetchesExecutionProfileList.class)
public void restDoc_admin_fetches_profiles_list() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildAdminFetchesListOfProductExecutionProfiles();
Class<? extends Annotation> useCase = UseCaseAdminFetchesExecutionProfileList.class;
TestExecutionProfileList profileList = new TestExecutionProfileList();
TestExecutionProfileListEntry entry1 = new TestExecutionProfileListEntry();
entry1.description = "A short decription for profile1";
entry1.id = "profile1";
TestExecutionProfileListEntry entry2 = new TestExecutionProfileListEntry();
entry2.description = "A short decription for profile2";
entry2.id = "profile2";
profileList.executionProfiles.add(entry1);
profileList.executionProfiles.add(entry2);
ProductExecutionProfilesList list = JSONConverter.get().fromJSON(ProductExecutionProfilesList.class, JSONConverter.get().toJSON(profileList));
when(fetchListService.fetchProductExecutionProfileList()).thenReturn(list);
/* execute + test @formatter:off */
this.mockMvc.perform(get(apiEndpoint).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).responseSchema(OpenApiSchema.EXECUTION_PROFILE_LIST.getSchema()).and().document(responseFields(fieldWithPath("type").description("Always `executorProfileList` as an identifier for the list"), fieldWithPath("executionProfiles[]." + PROPERTY_ID).description("The profile id"), fieldWithPath("executionProfiles[]." + PROPERTY_DESCRIPTION).description("A profile description"), fieldWithPath("executionProfiles[]." + PROPERTY_ENABLED).description("Enabled state of profile"))));
/* @formatter:on */
}
Aggregations