@Test public void when_support_says_infracan_uri_is_not_whitelisted_a_notacceptable_exception_is_thrown() throws Exception{ expectedException.expect(NotAcceptableException.class); whiteListFoundForProject.add(new ProjectWhitelistEntry(projectId, new URI(IP_ADRESS_2))); when(support.isWhitelisted(eq(IP_ADRESS_1), any())).thenReturn(false); serviceToTest.assertAllowedForProject(configureSecHub().projectId(projectId).infraConfig().addURI(IP_ADRESS_1).build()); }
public void assertAllowedForProject(SecHubConfiguration configuration) { List<URI> allowed = fetchAllowedUris(configuration); Optional<SecHubInfrastructureScanConfiguration> infrascanOpt = configuration.getInfraScan(); if (infrascanOpt.isPresent()) { SecHubInfrastructureScanConfiguration infraconf = infrascanOpt.get(); assertWhitelisted(allowed, infraconf.getUris()); assertWhitelisted(allowed, asUris(infraconf.getIps())); } Optional<SecHubWebScanConfiguration> webscanopt = configuration.getWebScan(); if (webscanopt.isPresent()) { SecHubWebScanConfiguration webconf = webscanopt.get(); assertWhitelisted(allowed, webconf.getUris()); } }
ProjectWhiteListSecHubConfigurationValidationService { public void assertAllowedForProject(SecHubConfiguration configuration) { List<URI> allowed = fetchAllowedUris(configuration); Optional<SecHubInfrastructureScanConfiguration> infrascanOpt = configuration.getInfraScan(); if (infrascanOpt.isPresent()) { SecHubInfrastructureScanConfiguration infraconf = infrascanOpt.get(); assertWhitelisted(allowed, infraconf.getUris()); assertWhitelisted(allowed, asUris(infraconf.getIps())); } Optional<SecHubWebScanConfiguration> webscanopt = configuration.getWebScan(); if (webscanopt.isPresent()) { SecHubWebScanConfiguration webconf = webscanopt.get(); assertWhitelisted(allowed, webconf.getUris()); } } }
ProjectWhiteListSecHubConfigurationValidationService { public void assertAllowedForProject(SecHubConfiguration configuration) { List<URI> allowed = fetchAllowedUris(configuration); Optional<SecHubInfrastructureScanConfiguration> infrascanOpt = configuration.getInfraScan(); if (infrascanOpt.isPresent()) { SecHubInfrastructureScanConfiguration infraconf = infrascanOpt.get(); assertWhitelisted(allowed, infraconf.getUris()); assertWhitelisted(allowed, asUris(infraconf.getIps())); } Optional<SecHubWebScanConfiguration> webscanopt = configuration.getWebScan(); if (webscanopt.isPresent()) { SecHubWebScanConfiguration webconf = webscanopt.get(); assertWhitelisted(allowed, webconf.getUris()); } }  }
ProjectWhiteListSecHubConfigurationValidationService { public void assertAllowedForProject(SecHubConfiguration configuration) { List<URI> allowed = fetchAllowedUris(configuration); Optional<SecHubInfrastructureScanConfiguration> infrascanOpt = configuration.getInfraScan(); if (infrascanOpt.isPresent()) { SecHubInfrastructureScanConfiguration infraconf = infrascanOpt.get(); assertWhitelisted(allowed, infraconf.getUris()); assertWhitelisted(allowed, asUris(infraconf.getIps())); } Optional<SecHubWebScanConfiguration> webscanopt = configuration.getWebScan(); if (webscanopt.isPresent()) { SecHubWebScanConfiguration webconf = webscanopt.get(); assertWhitelisted(allowed, webconf.getUris()); } }  void assertAllowedForProject(SecHubConfiguration configuration); }
ProjectWhiteListSecHubConfigurationValidationService { public void assertAllowedForProject(SecHubConfiguration configuration) { List<URI> allowed = fetchAllowedUris(configuration); Optional<SecHubInfrastructureScanConfiguration> infrascanOpt = configuration.getInfraScan(); if (infrascanOpt.isPresent()) { SecHubInfrastructureScanConfiguration infraconf = infrascanOpt.get(); assertWhitelisted(allowed, infraconf.getUris()); assertWhitelisted(allowed, asUris(infraconf.getIps())); } Optional<SecHubWebScanConfiguration> webscanopt = configuration.getWebScan(); if (webscanopt.isPresent()) { SecHubWebScanConfiguration webconf = webscanopt.get(); assertWhitelisted(allowed, webconf.getUris()); } }  void assertAllowedForProject(SecHubConfiguration configuration);  }