LEFT | RIGHT |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 """Tests for the preprocess plugins manager.""" | 3 """Tests for the preprocess plugins manager.""" |
4 | 4 |
5 import unittest | 5 import unittest |
6 | 6 |
7 from artifacts import reader as artifacts_reader | 7 from artifacts import reader as artifacts_reader |
8 from artifacts import registry as artifacts_registry | 8 from artifacts import registry as artifacts_registry |
9 | 9 |
10 from plaso.engine import knowledge_base | 10 from plaso.engine import knowledge_base |
11 from plaso.preprocessors import interface | 11 from plaso.preprocessors import interface |
12 from plaso.preprocessors import manager | 12 from plaso.preprocessors import manager |
13 | 13 |
14 from tests import test_lib as shared_test_lib | 14 from tests import test_lib as shared_test_lib |
15 | 15 |
16 | 16 |
17 class TestArtifactMapping(interface.ArtifactMapping): | 17 class TestArtifactPreprocessorPlugin(interface.ArtifactPreprocessorPlugin): |
18 """Test artifact mapping.""" | 18 """Test artifact preprocessor plugin.""" |
19 | 19 |
20 ARTIFACT_DEFINTION_NAME = u'TestArtifactDefinition' | 20 ARTIFACT_DEFINITION_NAME = u'TestArtifactDefinition' |
21 | 21 |
22 def ParseValueData(self, unused_knowledge_base, unused_value_data): | 22 def ParseValueData(self, unused_knowledge_base, unused_value_data): |
23 """Parses artifact value data for a preprocessing attribute. | 23 """Parses artifact value data for a preprocessing attribute. |
24 | 24 |
25 Args: | 25 Args: |
26 knowledge_base (KnowledgeBase): to fill with preprocessing information. | 26 knowledge_base (KnowledgeBase): to fill with preprocessing information. |
27 value_data (object): artifact value data. | 27 value_data (object): artifact value data. |
28 """ | 28 """ |
29 return | 29 return |
30 | 30 |
(...skipping 13 matching lines...) Expand all Loading... |
44 | 44 |
45 knowledge_base_object = knowledge_base.KnowledgeBase() | 45 knowledge_base_object = knowledge_base.KnowledgeBase() |
46 | 46 |
47 _ = knowledge_base_object | 47 _ = knowledge_base_object |
48 | 48 |
49 # TODO: implement. | 49 # TODO: implement. |
50 # manager.PreprocessPluginsManager.CollectFromFileSystem( | 50 # manager.PreprocessPluginsManager.CollectFromFileSystem( |
51 # registry, knowledge_base_object, None, None) | 51 # registry, knowledge_base_object, None, None) |
52 | 52 |
53 # TODO: add tests for CollectFromWindowsRegistry | 53 # TODO: add tests for CollectFromWindowsRegistry |
| 54 # TODO: add tests for GetNames |
54 | 55 |
55 def testRegistrationArtifactMapping(self): | 56 def testRegistrationPlugin(self): |
56 """Tests RegisterArtifactMapping and DeregisterArtifactMapping functions.""" | 57 """Tests RegisterPlugin and DeregisterPlugin functions.""" |
57 number_of_mappings = len( | 58 number_of_plugins = len(manager.PreprocessPluginsManager._plugins) |
58 manager.PreprocessPluginsManager._artifact_mappings) | |
59 | 59 |
60 manager.PreprocessPluginsManager.RegisterArtifactMapping( | 60 manager.PreprocessPluginsManager.RegisterPlugin( |
61 TestArtifactMapping) | 61 TestArtifactPreprocessorPlugin) |
62 self.assertEqual( | 62 self.assertEqual( |
63 len(manager.PreprocessPluginsManager._artifact_mappings), | 63 len(manager.PreprocessPluginsManager._plugins), number_of_plugins + 1) |
64 number_of_mappings + 1) | |
65 | 64 |
66 with self.assertRaises(KeyError): | 65 with self.assertRaises(KeyError): |
67 manager.PreprocessPluginsManager.RegisterArtifactMapping( | 66 manager.PreprocessPluginsManager.RegisterPlugin( |
68 TestArtifactMapping) | 67 TestArtifactPreprocessorPlugin) |
69 | 68 |
70 manager.PreprocessPluginsManager.DeregisterArtifactMapping( | 69 manager.PreprocessPluginsManager.DeregisterPlugin( |
71 TestArtifactMapping) | 70 TestArtifactPreprocessorPlugin) |
72 self.assertEqual( | 71 self.assertEqual( |
73 len(manager.PreprocessPluginsManager._artifact_mappings), | 72 len(manager.PreprocessPluginsManager._plugins), number_of_plugins) |
74 number_of_mappings) | |
75 | 73 |
76 # TODO: add tests for RegisterArtifactMappings | 74 # TODO: add tests for RegisterPlugins |
77 | 75 |
78 # TODO: add tests for RunPlugins | 76 # TODO: add tests for RunPlugins |
79 | 77 |
80 | 78 |
81 if __name__ == '__main__': | 79 if __name__ == '__main__': |
82 unittest.main() | 80 unittest.main() |
LEFT | RIGHT |