Search in sources :

Example 1 with ScanPaths

use of com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanPaths in project blackduck-common by blackducksoftware.

the class ScannerZipInstallerTest method testActualDownload.

@Test
void testActualDownload() throws Exception {
    String signatureScannerDownloadPath = TestingPropertyKey.TEST_BLACKDUCK_SIGNATURE_SCANNER_DOWNLOAD_PATH.fromEnvironment();
    String blackDuckUrl = TestingPropertyKey.TEST_BLACK_DUCK_SERVER_URL.fromEnvironment();
    String blackDuckUsername = TestingPropertyKey.TEST_USERNAME.fromEnvironment();
    String blackDuckPassword = TestingPropertyKey.TEST_PASSWORD.fromEnvironment();
    assertTrue(StringUtils.isNotBlank(signatureScannerDownloadPath));
    IntLogger logger = new BufferedIntLogger();
    BlackDuckServerConfigBuilder blackDuckServerConfigBuilder = BlackDuckServerConfig.newCredentialsBuilder();
    blackDuckServerConfigBuilder.setUrl(blackDuckUrl);
    blackDuckServerConfigBuilder.setUsername(blackDuckUsername);
    blackDuckServerConfigBuilder.setPassword(blackDuckPassword);
    blackDuckServerConfigBuilder.setTimeoutInSeconds(120);
    blackDuckServerConfigBuilder.setTrustCert(true);
    blackDuckServerConfigBuilder.setLogger(logger);
    BlackDuckServerConfig blackDuckServerConfig = blackDuckServerConfigBuilder.build();
    BlackDuckHttpClient blackDuckHttpClient = blackDuckServerConfig.createBlackDuckHttpClient(logger);
    BlackDuckServicesFactory blackDuckServicesFactory = blackDuckServerConfig.createBlackDuckServicesFactory(blackDuckHttpClient, logger);
    BlackDuckRegistrationService blackDuckRegistrationService = blackDuckServicesFactory.createBlackDuckRegistrationService();
    OperatingSystemType operatingSystemType = OperatingSystemType.determineFromSystem();
    ScanPathsUtility scanPathsUtility = new ScanPathsUtility(logger, IntEnvironmentVariables.includeSystemEnv(), operatingSystemType);
    CleanupZipExpander cleanupZipExpander = new CleanupZipExpander(logger);
    KeyStoreHelper keyStoreHelper = new KeyStoreHelper(logger);
    File downloadTarget = new File(signatureScannerDownloadPath);
    ScannerZipInstaller scannerZipInstaller = new ScannerZipInstaller(logger, new SignatureScannerClient(blackDuckHttpClient), blackDuckRegistrationService, cleanupZipExpander, scanPathsUtility, keyStoreHelper, new HttpUrl(blackDuckUrl), operatingSystemType, downloadTarget);
    scannerZipInstaller.installOrUpdateScanner();
    ScanPaths scanPaths = scanPathsUtility.searchForScanPaths(downloadTarget);
    assertTrue(scanPaths.isManagedByLibrary());
    assertTrue(StringUtils.isNotBlank(scanPaths.getPathToJavaExecutable()));
    assertTrue(StringUtils.isNotBlank(scanPaths.getPathToOneJar()));
    assertTrue(StringUtils.isNotBlank(scanPaths.getPathToScanExecutable()));
    assertTrue(new File(scanPaths.getPathToJavaExecutable()).canExecute());
    assertTrue(new File(scanPaths.getPathToOneJar()).canExecute());
    assertTrue(new File(scanPaths.getPathToScanExecutable()).canExecute());
}
Also used : BlackDuckServerConfigBuilder(com.synopsys.integration.blackduck.configuration.BlackDuckServerConfigBuilder) BlackDuckHttpClient(com.synopsys.integration.blackduck.http.client.BlackDuckHttpClient) KeyStoreHelper(com.synopsys.integration.blackduck.keystore.KeyStoreHelper) ScannerZipInstaller(com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScannerZipInstaller) IntLogger(com.synopsys.integration.log.IntLogger) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) HttpUrl(com.synopsys.integration.rest.HttpUrl) BlackDuckServerConfig(com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig) BlackDuckRegistrationService(com.synopsys.integration.blackduck.service.dataservice.BlackDuckRegistrationService) CleanupZipExpander(com.synopsys.integration.util.CleanupZipExpander) OperatingSystemType(com.synopsys.integration.util.OperatingSystemType) ScanPaths(com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanPaths) ScanPathsUtility(com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanPathsUtility) File(java.io.File) SignatureScannerClient(com.synopsys.integration.blackduck.http.client.SignatureScannerClient) Test(org.junit.jupiter.api.Test)

Example 2 with ScanPaths

use of com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanPaths in project blackduck-common by blackducksoftware.

the class ScanPathsTest method testJavaExecutablePathWithPackagedJre.

@Test
public void testJavaExecutablePathWithPackagedJre() throws Exception {
    intEnvironmentVariables.put(BDS_JAVA_HOME, null);
    ScanPaths macScanPaths = macScanPathsUtility.searchForScanPaths(macSetup);
    ScanPaths windowsScanPaths = windowsScanPathsUtility.searchForScanPaths(windowsSetup);
    ScanPaths linuxScanPaths = linuxScanPathsUtility.searchForScanPaths(linuxSetup);
    assertThat(macScanPaths.getPathToJavaExecutable(), startsWith(tempDirectory + File.separator + "mac_setup" + File.separator + getScannerPath()));
    assertThat(windowsScanPaths.getPathToJavaExecutable(), startsWith(tempDirectory + File.separator + "windows_setup" + File.separator + getScannerPath()));
    assertThat(linuxScanPaths.getPathToJavaExecutable(), startsWith(tempDirectory + File.separator + "linux_setup" + File.separator + getScannerPath()));
}
Also used : ScanPaths(com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanPaths) Test(org.junit.jupiter.api.Test)

Example 3 with ScanPaths

use of com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanPaths in project blackduck-common by blackducksoftware.

the class ScanPathsTest method testSignatureScannerPathsInstalledByThem.

@Test
public void testSignatureScannerPathsInstalledByThem() throws Exception {
    ScanPaths macScanPaths = macScanPathsUtility.searchForScanPaths(new File(macSetup, getScannerPath()));
    ScanPaths windowsScanPaths = windowsScanPathsUtility.searchForScanPaths(new File(windowsSetup, getScannerPath()));
    ScanPaths linuxScanPaths = linuxScanPathsUtility.searchForScanPaths(new File(linuxSetup, getScannerPath()));
    assertScanPathsOk(macScanPaths, false);
    assertScanPathsOk(windowsScanPaths, false);
    assertScanPathsOk(linuxScanPaths, false);
}
Also used : ScanPaths(com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanPaths) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 4 with ScanPaths

use of com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanPaths in project blackduck-common by blackducksoftware.

the class ScanPathsTest method testJavaExecutablePathWithBdsJavaHome.

@Test
public void testJavaExecutablePathWithBdsJavaHome() throws Exception {
    intEnvironmentVariables.put(BDS_JAVA_HOME, bdsJavaHomeDirectory.getAbsolutePath());
    ScanPaths macScanPaths = macScanPathsUtility.searchForScanPaths(macSetup);
    ScanPaths windowsScanPaths = windowsScanPathsUtility.searchForScanPaths(windowsSetup);
    ScanPaths linuxScanPaths = linuxScanPathsUtility.searchForScanPaths(linuxSetup);
    assertThat(macScanPaths.getPathToJavaExecutable(), is(bdsJavaHomeDirectory + File.separator + "bin" + File.separator + "java"));
    assertThat(windowsScanPaths.getPathToJavaExecutable(), is(bdsJavaHomeDirectory + File.separator + "bin" + File.separator + "java.exe"));
    assertThat(linuxScanPaths.getPathToJavaExecutable(), is(bdsJavaHomeDirectory + File.separator + "bin" + File.separator + "java"));
}
Also used : ScanPaths(com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanPaths) Test(org.junit.jupiter.api.Test)

Example 5 with ScanPaths

use of com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanPaths in project blackduck-common by blackducksoftware.

the class ScanPathsTest method testSignatureScannerPathsInstalledByUs.

@Test
public void testSignatureScannerPathsInstalledByUs() throws Exception {
    ScanPaths macScanPaths = macScanPathsUtility.searchForScanPaths(macSetup);
    ScanPaths windowsScanPaths = windowsScanPathsUtility.searchForScanPaths(windowsSetup);
    ScanPaths linuxScanPaths = linuxScanPathsUtility.searchForScanPaths(linuxSetup);
    assertScanPathsOk(macScanPaths, true);
    assertScanPathsOk(windowsScanPaths, true);
    assertScanPathsOk(linuxScanPaths, true);
}
Also used : ScanPaths(com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanPaths) Test(org.junit.jupiter.api.Test)

Aggregations

ScanPaths (com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanPaths)5 Test (org.junit.jupiter.api.Test)5 File (java.io.File)2 ScanPathsUtility (com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanPathsUtility)1 ScannerZipInstaller (com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScannerZipInstaller)1 BlackDuckServerConfig (com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig)1 BlackDuckServerConfigBuilder (com.synopsys.integration.blackduck.configuration.BlackDuckServerConfigBuilder)1 BlackDuckHttpClient (com.synopsys.integration.blackduck.http.client.BlackDuckHttpClient)1 SignatureScannerClient (com.synopsys.integration.blackduck.http.client.SignatureScannerClient)1 KeyStoreHelper (com.synopsys.integration.blackduck.keystore.KeyStoreHelper)1 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)1 BlackDuckRegistrationService (com.synopsys.integration.blackduck.service.dataservice.BlackDuckRegistrationService)1 BufferedIntLogger (com.synopsys.integration.log.BufferedIntLogger)1 IntLogger (com.synopsys.integration.log.IntLogger)1 HttpUrl (com.synopsys.integration.rest.HttpUrl)1 CleanupZipExpander (com.synopsys.integration.util.CleanupZipExpander)1 OperatingSystemType (com.synopsys.integration.util.OperatingSystemType)1