Search in sources :

Example 1 with TargetRegistryInfo

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

the class TargetRegistryTest method codeupload_registered_only_for_this_type_registry_info_contains_a_target.

@Test
public void codeupload_registered_only_for_this_type_registry_info_contains_a_target() {
    /* prepare */
    Target target1 = mock(Target.class);
    when(target1.getType()).thenReturn(TargetType.CODE_UPLOAD);
    when(target1.getIdentifierWithoutPrefix()).thenReturn("test1234");
    registryToTest.register(target1);
    /* iterate */
    for (TargetType type : TargetType.values()) {
        /* execute */
        TargetRegistryInfo info = registryToTest.createRegistryInfo(type);
        /* test */
        if (type == TargetType.CODE_UPLOAD) {
            assertTrue(info.containsAtLeastOneTarget());
        } else {
            assertFalse(info.containsAtLeastOneTarget());
        }
    }
}
Also used : TargetType(com.mercedesbenz.sechub.domain.scan.TargetType) TargetRegistryInfo(com.mercedesbenz.sechub.domain.scan.TargetRegistry.TargetRegistryInfo) Test(org.junit.Test)

Example 2 with TargetRegistryInfo

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

the class AbstractInstallSetupProductExecutor method executeAdapterWhenTargetTypeSupported.

private void executeAdapterWhenTargetTypeSupported(SecHubExecutionContext context, ProductExecutorContext executorContext, TargetRegistry registry, S setup, List<ProductResult> result, TargetType targetType) throws Exception {
    if (!setup.isAbleToScan(targetType)) {
        LOG.debug("{} Setup says its not able to scan target type {} with {}", context.getTraceLogId(), targetType, getIdentifier());
        return;
    } else {
        LOG.debug("{} Setup says it IS able to scan target type {} with {}", context.getTraceLogId(), targetType, getIdentifier());
    }
    TargetRegistryInfo registryInfo = registry.createRegistryInfo(targetType);
    if (!registryInfo.containsAtLeastOneTarget()) {
        LOG.debug("{} Did not found any IP, URI, or identifier defined for target type '{}' for {}", context.getTraceLogId(), targetType, getIdentifier());
        return;
    }
    LocalDateTime started = LocalDateTime.now();
    List<ProductResult> productResults = executeWithAdapter(context, executorContext, setup, registryInfo);
    LocalDateTime ended = LocalDateTime.now();
    if (productResults != null) {
        for (ProductResult pr : productResults) {
            pr.setStarted(started);
            pr.setEnded(ended);
        }
        result.addAll(productResults);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) TargetRegistryInfo(com.mercedesbenz.sechub.domain.scan.TargetRegistry.TargetRegistryInfo)

Example 3 with TargetRegistryInfo

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

the class TargetRegistryTest method codeupload_registered__registry_info_ontains_justfolderinfo.

@Test
public void codeupload_registered__registry_info_ontains_justfolderinfo() {
    /* prepare */
    Target target1 = mock(Target.class);
    when(target1.getType()).thenReturn(TargetType.CODE_UPLOAD);
    when(target1.getIdentifierWithoutPrefix()).thenReturn("test1234");
    Target target2 = mock(Target.class);
    when(target2.getType()).thenReturn(TargetType.CODE_UPLOAD);
    when(target2.getIdentifierWithoutPrefix()).thenReturn("test5436");
    registryToTest.register(target1);
    registryToTest.register(target2);
    /* execute */
    TargetRegistryInfo info = registryToTest.createRegistryInfo(CODE_UPLOAD);
    /* test */
    Set<String> folders = info.getCodeUploadFileSystemFolders();
    assertTrue(folders.contains("test1234"));
    assertTrue(folders.contains("test5436"));
}
Also used : TargetRegistryInfo(com.mercedesbenz.sechub.domain.scan.TargetRegistry.TargetRegistryInfo) Test(org.junit.Test)

Aggregations

TargetRegistryInfo (com.mercedesbenz.sechub.domain.scan.TargetRegistry.TargetRegistryInfo)3 Test (org.junit.Test)2 TargetType (com.mercedesbenz.sechub.domain.scan.TargetType)1 LocalDateTime (java.time.LocalDateTime)1