Exemple #1
0
    def test_bloom_filename(self):
        h = hashddcli(bloom=True, filename=self.TEST_FILENAME)
        self.assertIsNotNone(h)

        results = h.run()
        self.assertTrue(isfile('hashdd.bloom'))

        # Check the bloom filter we just created
        algorithms = [Algorithms.SHA256.value]  # Default
        features = [[Features.FILE_ABSOLUTE_PATH.value,
                     self.TEST_FILENAME]]  # Default

        h = hashddcli(bloom=True, filename=self.TEST_FILENAME)
        self.assertIsNotNone(h)

        results = h.run()
        self.check_compute_result(results, algorithms, features)
        self.assertIn('match_count', results[0])
        self.assertIn('matches', results[0])
        self.assertEqual(results[0]['match_count'], 1)
        self.assertEqual(results[0]['matches'][0], 'hashdd_sha256')

        # Recheck with nomatch
        h = hashddcli(bloom=True, filename=self.TEST_FILENAME, nomatch=True)
        self.assertIsNotNone(h)

        results = h.run()
        self.check_compute_result(results, algorithms, features)
        self.assertIn('match_count', results[0])
        self.assertIn('matches', results[0])
        self.assertEqual(results[0]['match_count'], 1)
        self.assertEqual(results[0]['matches'][0], 'hashdd_sha256')
Exemple #2
0
    def test_compute_directory(self):
        algorithms = [Algorithms.SHA256.value]  # Default
        features = [[
            Features.FILE_ABSOLUTE_PATH.value, self.TEST_RECURSIVE_FILENAME
        ]]  # Default

        h = hashddcli(compute=True, directory=self.TEST_RECURSIVE_DIRECTORY)
        self.assertIsNotNone(h)

        results = h.run()
        self.check_compute_result(results, algorithms, features)
Exemple #3
0
    def test_show(self):
        h = hashddcli(show=True)
        self.assertIsNotNone(h)

        results = h.run()
        self.assertIsInstance(results, list)

        available = hashdd.algorithms_available()

        for algo in results:
            self.assertTrue(algo.startswith('hashdd_'))
            self.assertIn(algo, available)
Exemple #4
0
    def test_compute_filename(self):
        algorithms = [Algorithms.SHA256.value]  # Default
        features = [[Features.FILE_ABSOLUTE_PATH.value,
                     self.TEST_FILENAME]]  # Default

        h = hashddcli(compute=True, filename=self.TEST_FILENAME)
        self.assertIsNotNone(h)

        results = h.run()
        self.check_compute_result(results, algorithms, features)

        # Test selected algorithms
        algorithms = ['md5', 'md5w', 'sha256']
        features = [[Features.FILE_ABSOLUTE_PATH.value, self.TEST_FILENAME]]

        h = hashddcli(compute=True,
                      filename=self.TEST_FILENAME,
                      algorithms=algorithms)
        self.assertIsNotNone(h)

        results = h.run()
        self.check_compute_result(results, algorithms, features)
Exemple #5
0
    def test_bloom_directory(self):
        h = hashddcli(bloom=True, directory=self.TEST_RECURSIVE_DIRECTORY)
        self.assertIsNotNone(h)

        results = h.run()
        self.assertTrue(isfile('hashdd.bloom'))

        # Check the bloom filter we just created
        algorithms = [Algorithms.SHA256.value]  # Default
        features = [[
            Features.FILE_ABSOLUTE_PATH.value, self.TEST_RECURSIVE_FILENAME
        ]]  # Default

        h = hashddcli(bloom=True, directory=self.TEST_RECURSIVE_DIRECTORY)
        self.assertIsNotNone(h)

        results = h.run()
        self.check_compute_result(results, algorithms, features)
        self.assertIn('match_count', results[0])
        self.assertIn('matches', results[0])
        self.assertEqual(results[0]['match_count'], 1)
        self.assertEqual(results[0]['matches'][0], 'hashdd_sha256')