From 038484ca385f5b293d687be1706a0f1fc4299f86 Mon Sep 17 00:00:00 2001 From: "U-BASIS\\dsmyda" Date: Sun, 15 Nov 2020 22:26:30 -0500 Subject: [PATCH] Tested automated testing changes with localhost --- .../datamodel/CentralRepoDbManager.java | 4 ++-- .../eventlisteners/Installer.java | 4 +++- .../sleuthkit/autopsy/testing/RegressionTest.java | 15 ++++++++++++++- test/script/regression_utils.py | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbManager.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbManager.java index fbdb4ea51e..094ce20c1a 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbManager.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbManager.java @@ -383,10 +383,10 @@ public class CentralRepoDbManager { saveNewCentralRepo(); } - public void setupDefaultPostgresDb() throws CentralRepoException { + public void setupPostgresDb(CentralRepoDbChoice choice) throws CentralRepoException { assert UserPreferences.getIsMultiUserModeEnabled(); - selectedDbChoice = CentralRepoDbChoice.POSTGRESQL_MULTIUSER; + selectedDbChoice = choice; DatabaseTestResult curStatus = testStatus(); if (curStatus == DatabaseTestResult.DB_DOES_NOT_EXIST) { createDb(); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java index 5662199181..b2ef0d437e 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java @@ -25,6 +25,7 @@ import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import org.openide.modules.ModuleInstall; import org.openide.util.NbBundle; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbChoice; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbManager; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.core.RuntimeProperties; @@ -128,7 +129,8 @@ public class Installer extends ModuleInstall { try { CentralRepoDbManager manager = new CentralRepoDbManager(); if (UserPreferences.getIsMultiUserModeEnabled()) { - manager.setupDefaultPostgresDb(); + // Set up using existing multi-user settings. + manager.setupPostgresDb(CentralRepoDbChoice.POSTGRESQL_MULTIUSER); } else { manager.setupDefaultSqliteDb(); } diff --git a/Testing/test/qa-functional/src/org/sleuthkit/autopsy/testing/RegressionTest.java b/Testing/test/qa-functional/src/org/sleuthkit/autopsy/testing/RegressionTest.java index 6f6e04d7bd..ebc7668a39 100644 --- a/Testing/test/qa-functional/src/org/sleuthkit/autopsy/testing/RegressionTest.java +++ b/Testing/test/qa-functional/src/org/sleuthkit/autopsy/testing/RegressionTest.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2018 Basis Technology Corp. + * Copyright 2011-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,6 +25,9 @@ import junit.framework.Test; import junit.framework.TestCase; import org.netbeans.jemmy.Timeouts; import org.netbeans.junit.NbModuleSuite; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbChoice; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbManager; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; /** * This test expects the following system properties to be set: img_path: The @@ -100,6 +103,16 @@ public class RegressionTest extends TestCase { public void setUp() { logger.info("######## " + AutopsyTestCases.getEscapedPath(System.getProperty("img_path")) + " #######"); Timeouts.setDefault("ComponentOperator.WaitComponentTimeout", 1000000); + + try { + CentralRepoDbManager manager = new CentralRepoDbManager(); + manager.getDbSettingsPostgres().setHost("localhost"); + manager.getDbSettingsPostgres().setUserName("postgres"); + manager.getDbSettingsPostgres().setPassword("password"); + manager.setupPostgresDb(CentralRepoDbChoice.POSTGRESQL_CUSTOM); + } catch (CentralRepoException ex) { + throw new RuntimeException(ex); + } } /** diff --git a/test/script/regression_utils.py b/test/script/regression_utils.py index 51fa3eb1c4..0c0229beb2 100644 --- a/test/script/regression_utils.py +++ b/test/script/regression_utils.py @@ -27,7 +27,7 @@ def make_os_path(platform, *dirs): path += str(dir).replace('\\', '/') + '/' return path_fix(path) elif platform == "win32": - return make_path(dirs) + return make_path(*dirs) else: print("Couldn't make path, because we only support Windows and Cygwin at this time.") sys.exit(1)