LEFT | RIGHT |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 """Tests for the Explorer ProgramsCache Windows Registry plugin.""" | 3 """Tests for the Explorer ProgramsCache Windows Registry plugin.""" |
4 | 4 |
5 from __future__ import unicode_literals | 5 from __future__ import unicode_literals |
6 | 6 |
7 import unittest | 7 import unittest |
8 | |
9 from dfwinreg import fake as dfwinreg_fake | |
10 | 8 |
11 from plaso.formatters import winreg # pylint: disable=unused-import | 9 from plaso.formatters import winreg # pylint: disable=unused-import |
12 from plaso.lib import definitions | 10 from plaso.lib import definitions |
13 from plaso.lib import timelib | 11 from plaso.lib import timelib |
14 from plaso.parsers.winreg_plugins import programscache | 12 from plaso.parsers.winreg_plugins import programscache |
15 | 13 |
16 from tests import test_lib as shared_test_lib | 14 from tests import test_lib as shared_test_lib |
17 from tests.parsers.winreg_plugins import test_lib | 15 from tests.parsers.winreg_plugins import test_lib |
18 | 16 |
19 | 17 |
20 class ExplorerProgramCachePluginTest(test_lib.RegistryPluginTestCase): | 18 class ExplorerProgramCachePluginTest(test_lib.RegistryPluginTestCase): |
21 """Tests for the Explorer ProgramsCache Windows Registry plugin.""" | 19 """Tests for the Explorer ProgramsCache Windows Registry plugin.""" |
22 | 20 |
23 def testFilters(self): | 21 def testFilters(self): |
24 """Tests the FILTERS class attribute.""" | 22 """Tests the FILTERS class attribute.""" |
25 plugin = programscache.ExplorerProgramsCachePlugin() | 23 plugin = programscache.ExplorerProgramsCachePlugin() |
26 | 24 |
27 key_path = ( | 25 key_path = ( |
28 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' | 26 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' |
29 'Explorer\\StartPage') | 27 'Explorer\\StartPage') |
30 registry_key = dfwinreg_fake.FakeWinRegistryKey( | 28 self._AssertFiltersOnKeyPath(plugin, key_path) |
31 'StartPage', key_path=key_path) | |
32 | |
33 result = self._CheckFiltersOnKeyPath(plugin, registry_key) | |
34 self.assertTrue(result) | |
35 | 29 |
36 key_path = ( | 30 key_path = ( |
37 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' | 31 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' |
38 'Explorer\\StartPage2') | 32 'Explorer\\StartPage2') |
39 registry_key = dfwinreg_fake.FakeWinRegistryKey( | 33 self._AssertFiltersOnKeyPath(plugin, key_path) |
40 'StartPage2', key_path=key_path) | |
41 | 34 |
42 result = self._CheckFiltersOnKeyPath(plugin, registry_key) | 35 self._AssertNotFiltersOnKeyPath(plugin, 'HKEY_LOCAL_MACHINE\\Bogus') |
43 self.assertTrue(result) | |
44 | |
45 key_path = 'HKEY_LOCAL_MACHINE\\Bogus' | |
46 registry_key = dfwinreg_fake.FakeWinRegistryKey('Bogus', key_path=key_path) | |
47 | |
48 result = self._CheckFiltersOnKeyPath(plugin, registry_key) | |
49 self.assertFalse(result) | |
50 | 36 |
51 @shared_test_lib.skipUnlessHasTestFile(['NTUSER.DAT']) | 37 @shared_test_lib.skipUnlessHasTestFile(['NTUSER.DAT']) |
52 def testProcessStartPage(self): | 38 def testProcessStartPage(self): |
53 """Tests the Process function on a StartPage key.""" | 39 """Tests the Process function on a StartPage key.""" |
54 test_file_entry = self._GetTestFileEntry(['NTUSER.DAT']) | 40 test_file_entry = self._GetTestFileEntry(['NTUSER.DAT']) |
55 key_path = ( | 41 key_path = ( |
56 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' | 42 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' |
57 'Explorer\\StartPage') | 43 'Explorer\\StartPage') |
58 | 44 |
59 win_registry = self._GetWinRegistryFromFileEntry(test_file_entry) | 45 win_registry = self._GetWinRegistryFromFileEntry(test_file_entry) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 expected_timestamp = timelib.Timestamp.CopyFromString( | 168 expected_timestamp = timelib.Timestamp.CopyFromString( |
183 '2010-11-10 07:50:38') | 169 '2010-11-10 07:50:38') |
184 self.assertEqual(event.timestamp, expected_timestamp) | 170 self.assertEqual(event.timestamp, expected_timestamp) |
185 | 171 |
186 expected_data_type = 'windows:shell_item:file_entry' | 172 expected_data_type = 'windows:shell_item:file_entry' |
187 self.assertEqual(event.data_type, expected_data_type) | 173 self.assertEqual(event.data_type, expected_data_type) |
188 | 174 |
189 | 175 |
190 if __name__ == '__main__': | 176 if __name__ == '__main__': |
191 unittest.main() | 177 unittest.main() |
LEFT | RIGHT |