Search in sources :

Example 11 with MappingData

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.

the class MappingDataToNamePatternToIdEntryConverterTest method one_mapping_containing_two_entries_transformed_to_config.

@Test
public void one_mapping_containing_two_entries_transformed_to_config() {
    /* prepare */
    MappingData mapping1 = createMapping(new MappingEntry("pattern1", "replacement1", "comment1"), new MappingEntry("pattern2", "replacement2", "comment2"));
    /* execute */
    List<NamePatternToIdEntry> namePatternList = converterToTest.convert(mapping1);
    /* test */
    assertNotNull(namePatternList);
    assertEquals(2, namePatternList.size());
    NamePatternToIdEntry first = namePatternList.get(0);
    assertEquals("pattern1", first.getNamePattern());
    assertEquals("replacement1", first.getId());
    NamePatternToIdEntry second = namePatternList.get(1);
    assertEquals("pattern2", second.getNamePattern());
    assertEquals("replacement2", second.getId());
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) Test(org.junit.Test)

Example 12 with MappingData

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.

the class ScanMappingToScanMappingConfigurationTransformerTest method one_mapping_containing_two_entries_transformed_to_config.

@Test
public void one_mapping_containing_two_entries_transformed_to_config() {
    /* prepare */
    MappingData data = createMappingData(new MappingEntry("x", "y", "z"), new MappingEntry("a", "b", "c"));
    ScanMapping mapping1 = createMapping("id1", data);
    when(converter.convert(any())).thenReturn(Arrays.asList(new NamePatternToIdEntry("pattern1", "replacement1"), new NamePatternToIdEntry("pattern2", "replacement2")));
    /* execute */
    ScanMappingConfiguration result = transformerToTest.transform(Collections.singletonList(mapping1));
    /* test */
    assertNotNull(result);
    assertEquals(1, result.getNamePatternMappings().size());
    List<NamePatternToIdEntry> namePatternList = result.getNamePatternMappings().get("id1");
    assertEquals(2, namePatternList.size());
    NamePatternToIdEntry first = namePatternList.get(0);
    assertEquals("pattern1", first.getNamePattern());
    assertEquals("replacement1", first.getId());
    NamePatternToIdEntry second = namePatternList.get(1);
    assertEquals("pattern2", second.getNamePattern());
    assertEquals("replacement2", second.getId());
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) Test(org.junit.Test)

Example 13 with MappingData

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.

the class MappingScenario3IntTest method mapping_for_checkmarx_preset_template_cannot_be_changed_by_user1_scenario3.

@Test
public void mapping_for_checkmarx_preset_template_cannot_be_changed_by_user1_scenario3() throws IOException {
    /* prepare */
    MappingData mappingData1 = new MappingData();
    MappingEntry entry = new MappingEntry("scenario3_project1", "123456", "");
    mappingData1.getEntries().add(entry);
    /* @formatter:off */
    expectHttpFailure(() -> {
        /* execute */
        as(USER_1).updateMapping(MappingIdentifier.CHECKMARX_NEWPROJECT_PRESET_ID.getId(), mappingData1);
    }, HttpStatus.FORBIDDEN);
/* @formatter:on */
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) Test(org.junit.Test)

Example 14 with MappingData

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.

the class MappingScenario3IntTest method checkmarx_executor_config_mapping_for_checkmarx_preset_changed_is_used_in_next_checkmarx_scan.

/* @formatter:off */
@Test
public void checkmarx_executor_config_mapping_for_checkmarx_preset_changed_is_used_in_next_checkmarx_scan() throws IOException {
    /* prepare */
    String projectId = PROJECT_1.getProjectId();
    /* add new parameters before default for execution:*/
    MappingData teamIdMapping = new MappingData();
    List<MappingEntry> teamIdMappingEntries = teamIdMapping.getEntries();
    teamIdMappingEntries.add(new MappingEntry(projectId, "replacedTeamId", ""));
    teamIdMappingEntries.add(IntegrationTestDefaultExecutorConfigurations.CHECKMARX_TEAMID_MAPPING_DEFAULT_MAPPING);
    MappingData presetMapping = new MappingData();
    List<MappingEntry> presetIdMappingEntries = presetMapping.getEntries();
    presetIdMappingEntries.add(new MappingEntry(projectId, "123456", ""));
    presetIdMappingEntries.add(IntegrationTestDefaultExecutorConfigurations.CHECKMARX_PRESETID_MAPPING_DEFAULT_MAPPING);
    /* execute */
    as(SUPER_ADMIN).changeProductExecutorJobParameter(CHECKMARX_V1, MappingIdentifier.CHECKMARX_NEWPROJECT_TEAM_ID.getId(), teamIdMapping.toJSON()).changeProductExecutorJobParameter(CHECKMARX_V1, MappingIdentifier.CHECKMARX_NEWPROJECT_PRESET_ID.getId(), presetMapping.toJSON());
    clearMetaDataInspection();
    assertMetaDataInspections().hasAmountOfInspections(0);
    /* test */
    ExecutionResult result = as(USER_1).withSecHubClient().startSynchronScanFor(PROJECT_1, CLIENT_JSON_SOURCESCAN_GREEN_ZERO_WAIT);
    UUID sechubJobUUID = result.getSechubJobUUID();
    assertNotNull("No sechub jobUUId found-maybe client call failed?", sechubJobUUID);
    assertMetaDataInspections().hasAmountOfInspections(1).inspectionNr(0).hasId("CHECKMARX").hasNotice("presetid", // scenario3_project1 -> replacedPresetId
    "123456").hasNotice("teamid", // scenario3_project1 -> replacedTeamId
    "replacedTeamId");
/* @formatter:on */
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) ExecutionResult(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult) UUID(java.util.UUID) Test(org.junit.Test)

Example 15 with MappingData

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.

the class StatusAdministrationRestControllerRestDocTest method before.

@Before
public void before() {
    mappingDataTeam = new MappingData();
    mappingDataTeam.getEntries().add(new MappingEntry("testproject_*", "8be4e3d4-6b53-4636-b65a-949a9ebdf6b9", "testproject-team"));
    mappingDataTeam.getEntries().add(new MappingEntry(".*", "3be4e3d2-2b55-2336-b65a-949b9ebdf6b9", "default-team"));
    /*
         * there could be more status examples in future - currently only scheduler
         * status info available
         */
    when(fetchMappingService.fetchMappingData(MappingIdentifier.CHECKMARX_NEWPROJECT_TEAM_ID.getId())).thenReturn(mappingDataTeam);
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) Before(org.junit.Before)

Aggregations

MappingData (com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)35 MappingEntry (com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry)21 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)5 ScanMapping (com.mercedesbenz.sechub.domain.scan.config.ScanMapping)2 TestURLBuilder (com.mercedesbenz.sechub.test.TestURLBuilder)2 DeveloperAdministration (com.mercedesbenz.sechub.developertools.admin.DeveloperAdministration)1 CSVRow (com.mercedesbenz.sechub.developertools.admin.importer.CSVRow)1 SimpleCSVImporter (com.mercedesbenz.sechub.developertools.admin.importer.SimpleCSVImporter)1 NamePatternIdProvider (com.mercedesbenz.sechub.domain.scan.config.NamePatternIdProvider)1 NamePatternToIdEntry (com.mercedesbenz.sechub.domain.scan.config.NamePatternToIdEntry)1 ScanConfig (com.mercedesbenz.sechub.domain.scan.config.ScanConfig)1 ScanMappingConfiguration (com.mercedesbenz.sechub.domain.scan.config.ScanMappingConfiguration)1 ScanMappingToScanConfigTransformer (com.mercedesbenz.sechub.domain.scan.config.ScanMappingToScanConfigTransformer)1 ScanMappingToScanMappingConfigurationTransformer (com.mercedesbenz.sechub.domain.scan.config.ScanMappingToScanMappingConfigurationTransformer)1 ProductExecutorConfigSetup (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup)1 ProductExecutorConfigSetupCredentials (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupCredentials)1 ProductExecutorConfigSetupJobParameter (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupJobParameter)1 ExecutionResult (com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult)1 TestExecutorConfig (com.mercedesbenz.sechub.test.executorconfig.TestExecutorConfig)1