Search in sources :

Example 6 with SecHubInfrastructureScanConfiguration

use of com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration in project sechub by mercedes-benz.

the class NessusProductExecutorTest method prepareInfraScanWithThreeURIs.

private void prepareInfraScanWithThreeURIs() throws URISyntaxException, SecHubExecutionException {
    SecHubInfrastructureScanConfiguration webscan = mock(SecHubInfrastructureScanConfiguration.class);
    when(config.getInfraScan()).thenReturn(Optional.of(webscan));
    List<URI> uris = new ArrayList<>();
    uris.add(URI_1);
    uris.add(URI_2);
    uris.add(URI_3);
    when(webscan.getUris()).thenReturn(uris);
}
Also used : ArrayList(java.util.ArrayList) SecHubInfrastructureScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration) URI(java.net.URI)

Example 7 with SecHubInfrastructureScanConfiguration

use of com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration in project sechub by mercedes-benz.

the class NessusProductExecutorTest method nessus_resolves_ip_from_infrascan.

@Test
public void nessus_resolves_ip_from_infrascan() throws Exception {
    /* prepare */
    when(executorConfig.getProductIdentifier()).thenReturn(ProductIdentifier.NESSUS);
    SecHubInfrastructureScanConfiguration infraScan = mock(SecHubInfrastructureScanConfiguration.class);
    List<InetAddress> expectedIPList = new ArrayList<>();
    when(infraScan.getIps()).thenReturn(expectedIPList);
    when(config.getInfraScan()).thenReturn(Optional.of(infraScan));
    /* execute */
    List<InetAddress> result = executorToTest.resolveInetAdressForTarget(config);
    /* test */
    assertEquals(expectedIPList, result);
}
Also used : ArrayList(java.util.ArrayList) SecHubInfrastructureScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 8 with SecHubInfrastructureScanConfiguration

use of com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration in project sechub by mercedes-benz.

the class AbstractInfrastructureScanProductExecutor method resolveURIsForTarget.

@Override
protected List<URI> resolveURIsForTarget(SecHubConfiguration config) {
    /* assert INFRASCAN configuration available */
    Optional<SecHubInfrastructureScanConfiguration> infraScan = config.getInfraScan();
    if (!infraScan.isPresent()) {
        throw new IllegalStateException("At this state there must be a infrascan setup!");
    }
    /* Fetch URI */
    SecHubInfrastructureScanConfiguration infraScanConfiguration = infraScan.get();
    List<URI> uris = infraScanConfiguration.getUris();
    if (uris == null) {
        throw new IllegalStateException("At this state URIs must be set - validation failed!");
    }
    return uris;
}
Also used : SecHubInfrastructureScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration) URI(java.net.URI)

Aggregations

SecHubInfrastructureScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration)8 URI (java.net.URI)6 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 SecHubWebScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration)1 InetAddress (java.net.InetAddress)1