Skip to content
Permalink
Browse files

Add evidence path to metadata file (#501)

* add evidence path to metadata file

* fix tests
  • Loading branch information
aarontp committed Feb 10, 2020
1 parent 2d42191 commit 725412f52a0eddc52fc722b84637d9d82e5d44bc
Showing with 7 additions and 3 deletions.
  1. +1 −0 turbinia/output_manager.py
  2. +6 −3 turbinia/output_manager_test.py
@@ -143,6 +143,7 @@ def save_evidence(self, evidence_, result):

if evidence_.save_metadata:
metadata = evidence_.config.copy()
metadata['evidence_path'] = path
metadata_path = '{0:s}.metadata.json'.format(local_path)
try:
json_str = json.dumps(metadata)
@@ -16,6 +16,7 @@

from __future__ import unicode_literals

import json
import unittest
import os
import shutil
@@ -142,7 +143,8 @@ def testSaveEvidenceWithMetadata(self):
dst_file = os.path.join(local_dir, test_file)
test_evidence = evidence.Evidence()
test_evidence.save_metadata = True
test_evidence.config = {'foo': 'bar'}
config_input = {'foo': 'bar'}
test_evidence.config = config_input

with open(src_file, 'w') as fh:
fh.write(test_contents)
@@ -155,9 +157,10 @@ def testSaveEvidenceWithMetadata(self):
self.assertIsInstance(return_evidence, evidence.Evidence)
self.assertIn(dst_file, return_evidence.saved_path)
metadata_file = '{0:s}.metadata.json'.format(dst_file)
metadata_contents = b'{"foo": "bar"}'
self.assertTrue(os.path.exists(metadata_file))
self.assertEqual(open(metadata_file, 'rb').read(), metadata_contents)
config_input['evidence_path'] = dst_file
metadata_contents = json.loads(open(metadata_file, 'rb').read())
self.assertDictEqual(config_input, metadata_contents)


class TestLocalOutputWriter(unittest.TestCase):

0 comments on commit 725412f

Please sign in to comment.
You can’t perform that action at this time.