Search in sources :

Example 6 with SecHubExecutionContext

use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext in project sechub by mercedes-benz.

the class WebConfigBuilderStrategyTest method includes_no_slash_infront_single.

@Test
public void includes_no_slash_infront_single() {
    /* prepare */
    List<String> includes = new LinkedList<>();
    includes.add("contact.html");
    String json = createIncludesJson(includes);
    SecHubConfiguration configuration = SECHUB_CONFIG.fromJSON(json);
    SecHubExecutionContext context = new SecHubExecutionContext(UUID.randomUUID(), configuration, "test");
    WebConfigBuilderStrategy strategyToTest = new WebConfigBuilderStrategy(context);
    TestAbstractWebScanAdapterConfigBuilder configBuilder = new TestAbstractWebScanAdapterConfigBuilder();
    /* execute */
    IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> {
        strategyToTest.configure(configBuilder);
    });
    /* test */
    assertEquals("The URL does not start with a slash '/'. URL: contact.html", exception.getMessage());
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) LinkedList(java.util.LinkedList) Test(org.junit.jupiter.api.Test)

Example 7 with SecHubExecutionContext

use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext in project sechub by mercedes-benz.

the class WebConfigBuilderStrategyTest method excludes_no_slash_infront_single.

@Test
public void excludes_no_slash_infront_single() {
    /* prepare */
    List<String> excludes = new LinkedList<>();
    excludes.add("contact.html");
    String json = createExcludesJson(excludes);
    SecHubConfiguration configuration = SECHUB_CONFIG.fromJSON(json);
    SecHubExecutionContext context = new SecHubExecutionContext(UUID.randomUUID(), configuration, "test");
    WebConfigBuilderStrategy strategyToTest = new WebConfigBuilderStrategy(context);
    TestAbstractWebScanAdapterConfigBuilder configBuilder = new TestAbstractWebScanAdapterConfigBuilder();
    /* execute */
    IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> {
        strategyToTest.configure(configBuilder);
    });
    /* test */
    assertEquals("The URL does not start with a slash '/'. URL: contact.html", exception.getMessage());
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) LinkedList(java.util.LinkedList) Test(org.junit.jupiter.api.Test)

Example 8 with SecHubExecutionContext

use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext in project sechub by mercedes-benz.

the class WebConfigBuilderStrategyTest method createContext.

private SecHubExecutionContext createContext(String pathToTestConfig) {
    String json = ScanDomainTestFileSupport.getTestfileSupport().loadTestFile(pathToTestConfig);
    SecHubConfiguration configuration = SECHUB_CONFIG.fromJSON(json);
    return new SecHubExecutionContext(UUID.randomUUID(), configuration, "test");
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)

Example 9 with SecHubExecutionContext

use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext in project sechub by mercedes-benz.

the class WebConfigBuilderStrategyTest method excludes_no_slash_infront_multiple.

@Test
public void excludes_no_slash_infront_multiple() {
    /* prepare */
    List<String> excludes = new LinkedList<>();
    excludes.add("/abc");
    excludes.add("contact.html");
    excludes.add("/bca");
    excludes.add("ccb/bca");
    String json = createExcludesJson(excludes);
    SecHubConfiguration configuration = SECHUB_CONFIG.fromJSON(json);
    SecHubExecutionContext context = new SecHubExecutionContext(UUID.randomUUID(), configuration, "test");
    WebConfigBuilderStrategy strategyToTest = new WebConfigBuilderStrategy(context);
    TestAbstractWebScanAdapterConfigBuilder configBuilder = new TestAbstractWebScanAdapterConfigBuilder();
    /* execute */
    IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> {
        strategyToTest.configure(configBuilder);
    });
    /* test */
    assertEquals("The URL does not start with a slash '/'. URL: contact.html", exception.getMessage());
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) LinkedList(java.util.LinkedList) Test(org.junit.jupiter.api.Test)

Example 10 with SecHubExecutionContext

use of com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext in project sechub by mercedes-benz.

the class LicenseScanProductExecutionServiceImplTest method isExecutionNecessary_necessary.

@Test
void isExecutionNecessary_necessary() {
    /* prepare */
    UUIDTraceLogID traceId = UUIDTraceLogID.traceLogID(UUID.randomUUID());
    SecHubExecutionContext context = mock(SecHubExecutionContext.class);
    SecHubConfiguration configuration = new SecHubConfiguration();
    SecHubLicenseScanConfiguration licenseScanConfig = new SecHubLicenseScanConfiguration();
    configuration.setLicenseScan(licenseScanConfig);
    /* execute + test */
    assertTrue(licenseScanServiceToTest.isExecutionNecessary(context, traceId, configuration));
}
Also used : UUIDTraceLogID(com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubLicenseScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubLicenseScanConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

SecHubExecutionContext (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)24 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)14 Test (org.junit.jupiter.api.Test)10 LinkedList (java.util.LinkedList)8 ProductExecutorContext (com.mercedesbenz.sechub.domain.scan.product.ProductExecutorContext)6 ProductResult (com.mercedesbenz.sechub.domain.scan.product.ProductResult)6 InputStream (java.io.InputStream)3 Test (org.junit.Test)3 AdapterException (com.mercedesbenz.sechub.adapter.AdapterException)2 AdapterLogId (com.mercedesbenz.sechub.adapter.AdapterLogId)2 NetworkTargetProductServerDataAdapterConfigurationStrategy (com.mercedesbenz.sechub.domain.scan.NetworkTargetProductServerDataAdapterConfigurationStrategy)2 NetworkTargetInfo (com.mercedesbenz.sechub.domain.scan.NetworkTargetRegistry.NetworkTargetInfo)2 NetworkTargetType (com.mercedesbenz.sechub.domain.scan.NetworkTargetType)2 ProductExecutorCallback (com.mercedesbenz.sechub.domain.scan.product.ProductExecutorCallback)2 ProductExecutorConfig (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig)2 ProductExecutorConfigSetup (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup)2 ScanMockData (com.mercedesbenz.sechub.domain.scan.project.ScanMockData)2 ScanProjectMockDataConfiguration (com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration)2 UUIDTraceLogID (com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID)2 SecHubExecutionException (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException)2