Search in sources :

Example 1 with UseCaseRestDoc

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 */
}
Also used : UseCaseAdminFetchesAutoCleanupConfiguration(com.mercedesbenz.sechub.sharedkernel.usecases.admin.config.UseCaseAdminFetchesAutoCleanupConfiguration) AdministrationAutoCleanupConfig(com.mercedesbenz.sechub.domain.administration.autocleanup.AdministrationAutoCleanupConfig) UseCaseRestDoc(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 2 with UseCaseRestDoc

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 */
}
Also used : FalsePositiveJobData(com.mercedesbenz.sechub.domain.scan.project.FalsePositiveJobData) FalsePositiveJobDataList(com.mercedesbenz.sechub.domain.scan.project.FalsePositiveJobDataList) UseCaseUserMarksFalsePositivesForJob(com.mercedesbenz.sechub.sharedkernel.usecases.user.execute.UseCaseUserMarksFalsePositivesForJob) UseCaseRestDoc(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest) Test(org.junit.Test)

Example 3 with UseCaseRestDoc

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 */
}
Also used : UseCaseAdminRestartsJob(com.mercedesbenz.sechub.sharedkernel.usecases.job.UseCaseAdminRestartsJob) UUID(java.util.UUID) UseCaseRestDoc(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 4 with UseCaseRestDoc

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 */
}
Also used : UseCaseAdminRestartsJobHard(com.mercedesbenz.sechub.sharedkernel.usecases.job.UseCaseAdminRestartsJobHard) UUID(java.util.UUID) UseCaseRestDoc(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 5 with UseCaseRestDoc

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 */
}
Also used : TestExecutionProfileListEntry(com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileListEntry) UseCaseAdminFetchesExecutionProfileList(com.mercedesbenz.sechub.sharedkernel.usecases.admin.config.UseCaseAdminFetchesExecutionProfileList) TestExecutionProfileList(com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileList) ProductExecutionProfilesList(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutionProfilesList) UseCaseRestDoc(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest) Test(org.junit.Test)

Aggregations

UseCaseRestDoc (com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc)37 Test (org.junit.Test)35 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)35 UUID (java.util.UUID)17 WithMockUser (org.springframework.security.test.context.support.WithMockUser)7 SchedulerResult (com.mercedesbenz.sechub.domain.schedule.SchedulerResult)5 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)5 UseCaseUserCreatesNewJob (com.mercedesbenz.sechub.sharedkernel.usecases.user.execute.UseCaseUserCreatesNewJob)5 TestExecutorConfig (com.mercedesbenz.sechub.test.executorconfig.TestExecutorConfig)5 ScheduleJobStatus (com.mercedesbenz.sechub.domain.schedule.ScheduleJobStatus)4 ScheduleSecHubJob (com.mercedesbenz.sechub.domain.schedule.job.ScheduleSecHubJob)4 TestExecutorSetupJobParam (com.mercedesbenz.sechub.test.executorconfig.TestExecutorSetupJobParam)4 Project (com.mercedesbenz.sechub.domain.administration.project.Project)3 User (com.mercedesbenz.sechub.domain.administration.user.User)3 TestExecutionProfile (com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfile)3 AdministrationAutoCleanupConfig (com.mercedesbenz.sechub.domain.administration.autocleanup.AdministrationAutoCleanupConfig)2 ProjectDetailInformation (com.mercedesbenz.sechub.domain.administration.project.ProjectDetailInformation)2 ProjectMetaDataEntity (com.mercedesbenz.sechub.domain.administration.project.ProjectMetaDataEntity)2 FalsePositiveJobData (com.mercedesbenz.sechub.domain.scan.project.FalsePositiveJobData)2 ScanMockData (com.mercedesbenz.sechub.domain.scan.project.ScanMockData)2