Search in sources :

Example 6 with ScanProjectMockDataConfiguration

use of com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration in project sechub by mercedes-benz.

the class ScanServiceTest method scan_service_fetches_mock_configuration_and_puts_mock_project_configuration_complete_in_execution_context.

@Test
public void scan_service_fetches_mock_configuration_and_puts_mock_project_configuration_complete_in_execution_context() throws Exception {
    /* prepare */
    SecHubConfiguration configNoProjectId = prepareValidConfiguration();
    DomainMessage request = prepareRequest(configNoProjectId);
    ScanProjectMockDataConfiguration projectMockDataConfig = new ScanProjectMockDataConfiguration();
    projectMockDataConfig.setCodeScan(new ScanMockData(TrafficLight.YELLOW));
    ScanProjectConfig projectConfig = new ScanProjectConfig(ScanProjectConfigID.MOCK_CONFIGURATION, TEST_PROJECT_ID1);
    projectConfig.setData(projectMockDataConfig.toJSON());
    when(scanProjectConfigService.get("test-project-id1", ScanProjectConfigID.MOCK_CONFIGURATION, false)).thenReturn(projectConfig);
    /* execute */
    simulateEventSend(request, serviceToTest);
    /* test */
    ArgumentCaptor<SecHubExecutionContext> contextCaptor = ArgumentCaptor.forClass(SecHubExecutionContext.class);
    verify(codeScanProductExecutionService).executeProductsAndStoreResults(contextCaptor.capture());
    SecHubExecutionContext context = contextCaptor.getValue();
    assertEquals(projectMockDataConfig, context.getData(ScanKey.PROJECT_MOCKDATA_CONFIGURATION));
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) ScanMockData(com.mercedesbenz.sechub.domain.scan.project.ScanMockData) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) ScanProjectConfig(com.mercedesbenz.sechub.domain.scan.project.ScanProjectConfig) ScanProjectMockDataConfiguration(com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.Test)

Example 7 with ScanProjectMockDataConfiguration

use of com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration in project sechub by mercedes-benz.

the class SecHubAdapterOptionsBuilderStrategyTest method before.

@Before
public void before() {
    data = mock(ProductExecutorData.class);
    SecHubExecutionContext context = mock(SecHubExecutionContext.class);
    configBuilder = mock(AbstractAdapterConfigBuilder.class);
    scanProjectMockDataConfig = new ScanProjectMockDataConfiguration();
    ScanMockData codeScan = new ScanMockData(TrafficLight.RED);
    ScanMockData webScan = new ScanMockData(TrafficLight.YELLOW);
    ScanMockData infraScan = new ScanMockData(TrafficLight.GREEN);
    scanProjectMockDataConfig.setCodeScan(codeScan);
    scanProjectMockDataConfig.setWebScan(webScan);
    scanProjectMockDataConfig.setInfraScan(infraScan);
    when(context.getData(ScanKey.PROJECT_MOCKDATA_CONFIGURATION)).thenReturn(scanProjectMockDataConfig);
    when(data.getSechubExecutionContext()).thenReturn(context);
}
Also used : AbstractAdapterConfigBuilder(com.mercedesbenz.sechub.adapter.AbstractAdapterConfigBuilder) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) ScanMockData(com.mercedesbenz.sechub.domain.scan.project.ScanMockData) ProductExecutorData(com.mercedesbenz.sechub.domain.scan.product.ProductExecutorData) ScanProjectMockDataConfiguration(com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration) Before(org.junit.Before)

Example 8 with ScanProjectMockDataConfiguration

use of com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration in project sechub by mercedes-benz.

the class ExampleJSONGenerator method generateScanProjectMockDataConfiguration1.

public String generateScanProjectMockDataConfiguration1() {
    ScanProjectMockDataConfiguration config = new ScanProjectMockDataConfiguration();
    config.setCodeScan(new ScanMockData(TrafficLight.RED));
    config.setWebScan(new ScanMockData(TrafficLight.YELLOW));
    config.setInfraScan(new ScanMockData(TrafficLight.GREEN));
    return prettyPrint(config);
}
Also used : ScanMockData(com.mercedesbenz.sechub.domain.scan.project.ScanMockData) ScanProjectMockDataConfiguration(com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration)

Aggregations

ScanProjectMockDataConfiguration (com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration)8 ScanMockData (com.mercedesbenz.sechub.domain.scan.project.ScanMockData)7 Test (org.junit.Test)3 ScanProjectConfig (com.mercedesbenz.sechub.domain.scan.project.ScanProjectConfig)2 SecHubExecutionContext (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)2 UseCaseRestDoc (com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc)2 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)2 WithMockUser (org.springframework.security.test.context.support.WithMockUser)2 AbstractAdapterConfigBuilder (com.mercedesbenz.sechub.adapter.AbstractAdapterConfigBuilder)1 ProductExecutorData (com.mercedesbenz.sechub.domain.scan.product.ProductExecutorData)1 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)1 DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)1 UseCaseUserDefinesProjectMockdata (com.mercedesbenz.sechub.sharedkernel.usecases.user.UseCaseUserDefinesProjectMockdata)1 UseCaseUserRetrievesProjectMockdata (com.mercedesbenz.sechub.sharedkernel.usecases.user.UseCaseUserRetrievesProjectMockdata)1 Before (org.junit.Before)1