use of com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration in project sechub by mercedes-benz.
the class ExampleJSONGenerator method generateScanProjectMockDataConfiguration2.
public String generateScanProjectMockDataConfiguration2() {
ScanProjectMockDataConfiguration config = new ScanProjectMockDataConfiguration();
config.setCodeScan(new ScanMockData(TrafficLight.YELLOW));
return prettyPrint(config);
}
use of com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration in project sechub by mercedes-benz.
the class ScanProjectMockDataRestControllerRestDocTest method get_project_mock_configuration.
@UseCaseRestDoc(useCase = UseCaseUserRetrievesProjectMockdata.class)
@Test
@WithMockUser
public void get_project_mock_configuration() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildGetProjectMockConfiguration(RestDocPathParameter.PROJECT_ID.pathElement());
Class<? extends Annotation> useCase = UseCaseUserRetrievesProjectMockdata.class;
ScanProjectMockDataConfiguration config = new ScanProjectMockDataConfiguration();
config.setCodeScan(new ScanMockData(TrafficLight.RED));
config.setWebScan(new ScanMockData(TrafficLight.YELLOW));
config.setInfraScan(new ScanMockData(TrafficLight.GREEN));
when(configService.retrieveProjectMockDataConfiguration(PROJECT1_ID)).thenReturn(config);
/* @formatter:off */
/* execute + test @formatter:off */
this.mockMvc.perform(get(apiEndpoint, PROJECT1_ID).accept(MediaType.APPLICATION_JSON_VALUE).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(jsonPath("$.codeScan.result").value("RED")).andExpect(jsonPath("$.webScan.result").value("YELLOW")).andExpect(jsonPath("$.infraScan.result").value("GREEN")).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).responseSchema(OpenApiSchema.MOCK_DATA_CONFIGURATION.getSchema()).and().document());
/* @formatter:on */
}
use of com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration in project sechub by mercedes-benz.
the class ScanService method buildOptions.
private void buildOptions(SecHubExecutionContext executionContext) {
/* project specific setup */
String projectId = executionContext.getConfiguration().getProjectId();
if (projectId == null) {
throw new IllegalStateException("projectId not found in configuration - so cannot prepare context options!");
}
ScanProjectConfig scanProjectMockConfig = scanProjectConfigService.get(projectId, ScanProjectConfigID.MOCK_CONFIGURATION, false);
if (scanProjectMockConfig != null) {
String data = scanProjectMockConfig.getData();
ScanProjectMockDataConfiguration mockDataConfig = ScanProjectMockDataConfiguration.fromString(data);
executionContext.putData(ScanKey.PROJECT_MOCKDATA_CONFIGURATION, mockDataConfig);
}
}
use of com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration in project sechub by mercedes-benz.
the class SecHubAdapterOptionsBuilderStrategy method fetchMockConfigurationResultLowerCased.
private String fetchMockConfigurationResultLowerCased() {
String mockConfigurationResult = null;
ScanProjectMockDataConfiguration mockConfiguration = context.getData(ScanKey.PROJECT_MOCKDATA_CONFIGURATION);
Optional<ScanMockData> mockData = Optional.empty();
if (mockConfiguration != null) {
switch(scanType) {
case CODE_SCAN:
mockData = mockConfiguration.getCodeScan();
break;
case WEB_SCAN:
mockData = mockConfiguration.getWebScan();
break;
case INFRA_SCAN:
mockData = mockConfiguration.getInfraScan();
break;
default:
LOG.error("Cannot fetch mock configuration result for scan type:'{}'", scanType);
}
if (mockData.isPresent()) {
ScanMockData scanMockData = mockData.get();
mockConfigurationResult = scanMockData.getResult().name().toLowerCase();
}
}
return mockConfigurationResult;
}
use of com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration in project sechub by mercedes-benz.
the class ScanProjectMockDataRestControllerRestDocTest method set_project_mock_configuration.
@UseCaseRestDoc(useCase = UseCaseUserDefinesProjectMockdata.class)
@Test
@WithMockUser
public void set_project_mock_configuration() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildSetProjectMockConfiguration(RestDocPathParameter.PROJECT_ID.pathElement());
Class<? extends Annotation> useCase = UseCaseUserDefinesProjectMockdata.class;
ScanProjectMockDataConfiguration config = new ScanProjectMockDataConfiguration();
config.setCodeScan(new ScanMockData(TrafficLight.RED));
config.setWebScan(new ScanMockData(TrafficLight.YELLOW));
config.setInfraScan(new ScanMockData(TrafficLight.GREEN));
/* @formatter:off */
/* execute + test @formatter:off */
this.mockMvc.perform(put(apiEndpoint, PROJECT1_ID).accept(MediaType.APPLICATION_JSON_VALUE).contentType(MediaType.APPLICATION_JSON_VALUE).content(config.toJSON())).andExpect(status().isOk()).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).requestSchema(OpenApiSchema.MOCK_DATA_CONFIGURATION.getSchema()).and().document());
/* @formatter:on */
}
Aggregations