From 70a1c423966a01812dd75218c36fc61cbd89d3f0 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro <gregd@basistech.com> Date: Fri, 30 Oct 2020 09:58:33 -0400 Subject: [PATCH] fixed tests and remove warning in RecentFilesSummaryTests --- .../datamodel/CentralRepoDatamodelTest.java | 9 ++++++--- .../InterCaseTestUtils.java | 18 ++++++++++-------- .../autopsy/ingest/IngestFileFiltersTest.java | 2 +- .../datamodel/RecentFilesSummaryTest.java | 8 ++++---- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java index 357d5e0641..65907e8e87 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java @@ -1256,7 +1256,8 @@ public void testCorrelationTypes() { List<CorrelationAttributeInstance.Type> types = CentralRepository.getInstance().getDefinedCorrelationTypes(); // We expect 11 total - 10 default and the custom one made earlier - assertTrue("getDefinedCorrelationTypes returned " + types.size() + " entries - expected 11", types.size() == 11); + // Note: this test will need to be updated based on the current default items defined in the correlation_types table + assertTrue("getDefinedCorrelationTypes returned " + types.size() + " entries - expected 28", types.size() == 28); } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); @@ -1267,7 +1268,8 @@ public void testCorrelationTypes() { List<CorrelationAttributeInstance.Type> types = CentralRepository.getInstance().getEnabledCorrelationTypes(); // We expect 10 - the custom type is disabled - assertTrue("getDefinedCorrelationTypes returned " + types.size() + " enabled entries - expected 10", types.size() == 10); + // Note: this test will need to be updated based on the current default items defined in the correlation_types table + assertTrue("getDefinedCorrelationTypes returned " + types.size() + " enabled entries - expected 27", types.size() == 27); } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); @@ -1278,7 +1280,8 @@ public void testCorrelationTypes() { List<CorrelationAttributeInstance.Type> types = CentralRepository.getInstance().getSupportedCorrelationTypes(); // We expect 10 - the custom type is not supported - assertTrue("getDefinedCorrelationTypes returned " + types.size() + " supported entries - expected 10", types.size() == 10); + // Note: this test will need to be updated based on the current default items defined in the correlation_types table + assertTrue("getDefinedCorrelationTypes returned " + types.size() + " supported entries - expected 27", types.size() == 27); } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseTestUtils.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseTestUtils.java index 014b08fe84..f76676cd25 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseTestUtils.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseTestUtils.java @@ -218,7 +218,9 @@ class InterCaseTestUtils { // kitchenSink.add(keywordSearchTemplate); this.kitchenShink = new IngestJobSettings(InterCaseTestUtils.class.getCanonicalName(), IngestType.ALL_MODULES, kitchenSink); + } + void setupCorrelationTypes() { try { Collection<CorrelationAttributeInstance.Type> types = CentralRepository.getInstance().getDefinedCorrelationTypes(); @@ -254,16 +256,16 @@ void clearTestDir() { } } } - + Map<Long, String> getDataSourceMap() throws NoCurrentCaseException, TskCoreException, SQLException { return DataSourceLoader.getAllDataSources(); - } + } Map<String, Integer> getCaseMap() throws CentralRepoException { if (CentralRepository.isEnabled()) { Map<String, Integer> mapOfCaseIdsToCase = new HashMap<>(); - + for (CorrelationCase correlationCase : CentralRepository.getInstance().getCases()) { mapOfCaseIdsToCase.put(correlationCase.getDisplayName(), correlationCase.getID()); } @@ -300,7 +302,7 @@ void enableCentralRepo() throws CentralRepoException { RdbmsCentralRepoFactory centralRepoSchemaFactory = new RdbmsCentralRepoFactory(CentralRepoPlatforms.SQLITE, crSettings); centralRepoSchemaFactory.initializeDatabaseSchema(); centralRepoSchemaFactory.insertDefaultDatabaseContent(); - + crSettings.saveSettings(); CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.SQLITE); } @@ -313,10 +315,10 @@ void enableCentralRepo() throws CentralRepoException { * The length of caseNames and caseDataSourcePaths should be the same, and * cases should appear in the same order. * - * @param caseNames list case names - * @param caseDataSourcePaths two dimensional array listing the datasources - * in each case - * @param ingestJobSettings HashLookup FileType etc... + * @param caseNames list case names + * @param caseDataSourcePaths two dimensional array listing the datasources + * in each case + * @param ingestJobSettings HashLookup FileType etc... * @param caseReferenceToStore */ Case createCases(String[] caseNames, Path[][] caseDataSourcePaths, IngestJobSettings ingestJobSettings, String caseReferenceToStore) throws TskCoreException { diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestFileFiltersTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestFileFiltersTest.java index 262e54774f..ce0ffb1526 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestFileFiltersTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestFileFiltersTest.java @@ -253,7 +253,7 @@ public void testCarvingWithExtRuleAndUnallocSpace() { IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); FileManager fileManager = currentCase.getServices().getFileManager(); List<AbstractFile> results = fileManager.findFiles("%%"); - assertEquals(70, results.size()); + assertEquals(71, results.size()); int carvedJpgGifFiles = 0; for (AbstractFile file : results) { if (file.getNameExtension().equalsIgnoreCase("jpg") || file.getNameExtension().equalsIgnoreCase("gif")) { //Unalloc file and .jpg files in dir1, dir2, $CarvedFiles, root directory should have MIME type diff --git a/Core/test/unit/src/org/sleuthkit/autopsy/datasourcesummary/datamodel/RecentFilesSummaryTest.java b/Core/test/unit/src/org/sleuthkit/autopsy/datasourcesummary/datamodel/RecentFilesSummaryTest.java index 95871dae2e..068f0c3904 100644 --- a/Core/test/unit/src/org/sleuthkit/autopsy/datasourcesummary/datamodel/RecentFilesSummaryTest.java +++ b/Core/test/unit/src/org/sleuthkit/autopsy/datasourcesummary/datamodel/RecentFilesSummaryTest.java @@ -308,7 +308,7 @@ public void getRecentlyOpenedDocuments_filtersMissingData() throws SleuthkitCase // verify results (only successItem) Assert.assertNotNull(results); Assert.assertEquals(1, results.size()); - Assert.assertEquals((Long) DAY_SECONDS, (Long) results.get(0).getDateAsLong()); + Assert.assertEquals((Long) DAY_SECONDS, results.get(0).getDateAsLong()); Assert.assertTrue("/a/path".equalsIgnoreCase(results.get(0).getPath())); } @@ -386,7 +386,7 @@ public void getRecentDownloads_filtersMissingData() throws SleuthkitCaseProvider // verify results Assert.assertNotNull(results); Assert.assertEquals(1, results.size()); - Assert.assertEquals((Long) DAY_SECONDS, (Long) results.get(0).getDateAsLong()); + Assert.assertEquals((Long) DAY_SECONDS, results.get(0).getDateAsLong()); Assert.assertTrue("/a/path1".equalsIgnoreCase(results.get(0).getPath())); } @@ -668,12 +668,12 @@ public void getRecentAttachments_filterData() throws SleuthkitCaseProviderExcept RecentAttachmentDetails successItem2Details = results.get(0); RecentAttachmentDetails successItemDetails = results.get(1); - Assert.assertEquals((Long) successItemDetails.getDateAsLong(), (Long) DAY_SECONDS); + Assert.assertEquals(successItemDetails.getDateAsLong(), (Long) DAY_SECONDS); Assert.assertTrue(Paths.get(successItem.getFileParentPath(), successItem.getFileName()) .toString().equalsIgnoreCase(successItemDetails.getPath())); Assert.assertTrue(successItem.getEmailFrom().equalsIgnoreCase(successItemDetails.getSender())); - Assert.assertEquals((Long) successItem2Details.getDateAsLong(), (Long) (DAY_SECONDS + 1)); + Assert.assertEquals(successItem2Details.getDateAsLong(), (Long) (DAY_SECONDS + 1)); Assert.assertTrue(Paths.get(successItem2.getFileParentPath(), successItem2.getFileName()) .toString().equalsIgnoreCase(successItem2Details.getPath())); Assert.assertTrue(successItem2.getEmailFrom().equalsIgnoreCase(successItem2Details.getSender())); -- GitLab