use of com.synopsys.integration.util.OperatingSystemType in project blackduck-common by blackducksoftware.
the class InstallAndRunSignatureScannerTestIT method testInstallingAndRunningSignatureScanner.
@Test
void testInstallingAndRunningSignatureScanner() throws IOException, InterruptedException, IntegrationException {
// here, we do not want to automatically trust the server's certificate
BlackDuckServerConfigBuilder blackDuckServerConfigBuilder = intHttpClientTestHelper.getBlackDuckServerConfigBuilder();
blackDuckServerConfigBuilder.setTrustCert(false);
BlackDuckServerConfig blackDuckServerConfig = blackDuckServerConfigBuilder.build();
File installDirectory = new File(scannerDirectoryPath, "scanner_install");
File outputDirectory = new File(scannerDirectoryPath, "scanner_output");
ScanBatch scanBatch = createScanBatch(blackDuckServerConfig, outputDirectory);
BufferedIntLogger logger = new BufferedIntLogger();
BlackDuckServicesFactory blackDuckServicesFactory = blackDuckServerConfig.createBlackDuckServicesFactory(logger);
IntEnvironmentVariables environmentVariables = blackDuckServicesFactory.getEnvironmentVariables();
OperatingSystemType operatingSystemType = OperatingSystemType.determineFromSystem();
ExecutorService executorService = BlackDuckServicesFactory.NO_THREAD_EXECUTOR_SERVICE;
BlackDuckHttpClient blackDuckHttpClient = blackDuckServicesFactory.getBlackDuckHttpClient();
BlackDuckRegistrationService blackDuckRegistrationService = blackDuckServicesFactory.createBlackDuckRegistrationService();
CleanupZipExpander cleanupZipExpander = new CleanupZipExpander(logger);
HttpUrl blackDuckServerUrl = blackDuckHttpClient.getBlackDuckUrl();
ScanPathsUtility scanPathsUtility = new ScanPathsUtility(logger, environmentVariables, operatingSystemType);
ScanCommandRunner scanCommandRunner = new ScanCommandRunner(logger, environmentVariables, scanPathsUtility, executorService);
// first, run a scan with an install that will NOT update the embedded keystore, which should fail
KeyStoreHelper noOpKeyStoreHelper = new NoOpKeyStoreHelper();
ScannerZipInstaller installerWithoutKeyStoreManagement = new ScannerZipInstaller(logger, new SignatureScannerClient(blackDuckHttpClient), blackDuckRegistrationService, cleanupZipExpander, scanPathsUtility, noOpKeyStoreHelper, blackDuckServerUrl, operatingSystemType, installDirectory);
ScanBatchRunner scanBatchRunnerWithout = ScanBatchRunner.createComplete(environmentVariables, scanPathsUtility, scanCommandRunner, installerWithoutKeyStoreManagement);
SignatureScannerService signatureScannerServiceWithout = blackDuckServicesFactory.createSignatureScannerService(scanBatchRunnerWithout);
assertScanFailure(logger, blackDuckRegistrationService, signatureScannerServiceWithout, scanBatch);
// now, delete the failed installation
FileUtils.deleteDirectory(installDirectory);
// second, run a scan with an install that DOES update the embedded keystore, which should succeed
logger.resetAllLogs();
KeyStoreHelper keyStoreHelper = new KeyStoreHelper(logger);
ScannerZipInstaller installerWithKeyStoreManagement = new ScannerZipInstaller(logger, new SignatureScannerClient(blackDuckHttpClient), blackDuckRegistrationService, cleanupZipExpander, scanPathsUtility, keyStoreHelper, blackDuckServerUrl, operatingSystemType, installDirectory);
ScanBatchRunner scanBatchRunnerWith = ScanBatchRunner.createComplete(environmentVariables, scanPathsUtility, scanCommandRunner, installerWithKeyStoreManagement);
SignatureScannerService signatureScannerServiceWith = blackDuckServicesFactory.createSignatureScannerService(scanBatchRunnerWith);
assertScanSuccess(logger, signatureScannerServiceWith, scanBatch);
// finally, verify the code location exists and then delete it to clean up
CodeLocationService codeLocationService = blackDuckServicesFactory.createCodeLocationService();
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
ResilientJobConfig jobConfig = new ResilientJobConfig(logger, 120, System.currentTimeMillis(), 10);
WaitJob.waitFor(jobConfig, () -> codeLocationService.getCodeLocationByName(CODE_LOCATION_NAME).isPresent(), "codeLocationTest");
Optional<CodeLocationView> codeLocationViewOptional = codeLocationService.getCodeLocationByName(CODE_LOCATION_NAME);
assertTrue(codeLocationViewOptional.isPresent());
blackDuckApiClient.delete(codeLocationViewOptional.get());
}
use of com.synopsys.integration.util.OperatingSystemType 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());
}
use of com.synopsys.integration.util.OperatingSystemType in project synopsys-detect by blackducksoftware.
the class DetectInfoUtility method createDetectInfo.
public DetectInfo createDetectInfo() {
List<String> detectVersionFileContents = readDetectVersionFile();
String versionText = parseValueFromVersionFileContents(detectVersionFileContents, "version");
String buildDateText = parseValueFromVersionFileContents(detectVersionFileContents, "builddate");
OperatingSystemType os = findOperatingSystemType();
logger.debug(String.format("You seem to be running in a %s operating system.", os));
logger.debug(String.format("You seem to be using %s architecture.", StringUtils.join(findArchitectures(), ", ")));
return new DetectInfo(versionText, os, buildDateText);
}
use of com.synopsys.integration.util.OperatingSystemType in project blackduck-common by blackducksoftware.
the class ScanBatchRunner method createDefault.
public static ScanBatchRunner createDefault(IntLogger logger, BlackDuckHttpClient blackDuckHttpClient, BlackDuckRegistrationService blackDuckRegistrationService, IntEnvironmentVariables intEnvironmentVariables, ExecutorService executorService, File signatureScannerInstallDirectory) {
OperatingSystemType operatingSystemType = OperatingSystemType.determineFromSystem();
ScanPathsUtility scanPathsUtility = new ScanPathsUtility(logger, intEnvironmentVariables, operatingSystemType);
ScanCommandRunner scanCommandRunner = new ScanCommandRunner(logger, intEnvironmentVariables, scanPathsUtility, executorService);
return ScanBatchRunner.createDefault(logger, blackDuckHttpClient, blackDuckRegistrationService, intEnvironmentVariables, scanPathsUtility, operatingSystemType, scanCommandRunner, signatureScannerInstallDirectory);
}
Aggregations