LEFT | RIGHT |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 """Tests for the MSIE Zone settings Windows Registry plugin.""" | 3 """Tests for the MSIE Zone settings 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 | 8 |
9 from dfwinreg import fake as dfwinreg_fake | |
10 | |
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 timelib | 10 from plaso.lib import timelib |
13 from plaso.parsers.winreg_plugins import msie_zones | 11 from plaso.parsers.winreg_plugins import msie_zones |
14 | 12 |
15 from tests import test_lib as shared_test_lib | 13 from tests import test_lib as shared_test_lib |
16 from tests.parsers.winreg_plugins import test_lib | 14 from tests.parsers.winreg_plugins import test_lib |
17 | 15 |
18 | 16 |
19 class MsieZoneSettingsPluginTest(test_lib.RegistryPluginTestCase): | 17 class MsieZoneSettingsPluginTest(test_lib.RegistryPluginTestCase): |
20 """Tests for Internet Settings Zones plugin.""" | 18 """Tests for Internet Settings Zones plugin.""" |
21 | 19 |
22 def testFilters(self): | 20 def testFilters(self): |
23 """Tests the FILTERS class attribute.""" | 21 """Tests the FILTERS class attribute.""" |
24 plugin = msie_zones.MsieZoneSettingsPlugin() | 22 plugin = msie_zones.MsieZoneSettingsPlugin() |
25 | 23 |
26 key_path = ( | 24 key_path = ( |
27 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' | 25 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' |
28 'Internet Settings\\Lockdown_Zones') | 26 'Internet Settings\\Lockdown_Zones') |
29 registry_key = dfwinreg_fake.FakeWinRegistryKey( | 27 self._AssertFiltersOnKeyPath(plugin, key_path) |
30 'Lockdown_Zones', key_path=key_path) | |
31 | |
32 result = self._CheckFiltersOnKeyPath(plugin, registry_key) | |
33 self.assertTrue(result) | |
34 | 28 |
35 key_path = ( | 29 key_path = ( |
36 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' | 30 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' |
37 'Internet Settings\\Zones') | 31 'Internet Settings\\Zones') |
38 registry_key = dfwinreg_fake.FakeWinRegistryKey( | 32 self._AssertFiltersOnKeyPath(plugin, key_path) |
39 'Lockdown_Zones', key_path=key_path) | |
40 | |
41 result = self._CheckFiltersOnKeyPath(plugin, registry_key) | |
42 self.assertTrue(result) | |
43 | 33 |
44 key_path = ( | 34 key_path = ( |
45 'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\' | 35 'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\' |
46 'Internet Settings\\Lockdown_Zones') | 36 'Internet Settings\\Lockdown_Zones') |
47 registry_key = dfwinreg_fake.FakeWinRegistryKey( | 37 self._AssertFiltersOnKeyPath(plugin, key_path) |
48 'Lockdown_Zones', key_path=key_path) | |
49 | |
50 result = self._CheckFiltersOnKeyPath(plugin, registry_key) | |
51 self.assertTrue(result) | |
52 | 38 |
53 key_path = ( | 39 key_path = ( |
54 'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\' | 40 'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\' |
55 'Internet Settings\\Zones') | 41 'Internet Settings\\Zones') |
56 registry_key = dfwinreg_fake.FakeWinRegistryKey( | 42 self._AssertFiltersOnKeyPath(plugin, key_path) |
57 'Lockdown_Zones', key_path=key_path) | 43 |
58 | 44 self._AssertNotFiltersOnKeyPath(plugin, 'HKEY_LOCAL_MACHINE\\Bogus') |
59 result = self._CheckFiltersOnKeyPath(plugin, registry_key) | |
60 self.assertTrue(result) | |
61 | |
62 key_path = 'HKEY_LOCAL_MACHINE\\Bogus' | |
63 registry_key = dfwinreg_fake.FakeWinRegistryKey('Bogus', key_path=key_path) | |
64 | |
65 result = self._CheckFiltersOnKeyPath(plugin, registry_key) | |
66 self.assertFalse(result) | |
67 | 45 |
68 @shared_test_lib.skipUnlessHasTestFile(['NTUSER-WIN7.DAT']) | 46 @shared_test_lib.skipUnlessHasTestFile(['NTUSER-WIN7.DAT']) |
69 def testProcessNtuserLockdownZones(self): | 47 def testProcessNtuserLockdownZones(self): |
70 """Tests the Process function on a Lockdown_Zones key.""" | 48 """Tests the Process function on a Lockdown_Zones key.""" |
71 test_file_entry = self._GetTestFileEntry(['NTUSER-WIN7.DAT']) | 49 test_file_entry = self._GetTestFileEntry(['NTUSER-WIN7.DAT']) |
72 key_path = ( | 50 key_path = ( |
73 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' | 51 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' |
74 'Internet Settings\\Lockdown_Zones') | 52 'Internet Settings\\Lockdown_Zones') |
75 | 53 |
76 win_registry = self._GetWinRegistryFromFileEntry(test_file_entry) | 54 win_registry = self._GetWinRegistryFromFileEntry(test_file_entry) |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 '[PMDisplayName]: Computer ' | 409 '[PMDisplayName]: Computer ' |
432 '[Protected Mode]').format(key_path) | 410 '[Protected Mode]').format(key_path) |
433 expected_short_message = '{0:s}...'.format(expected_message[:77]) | 411 expected_short_message = '{0:s}...'.format(expected_message[:77]) |
434 | 412 |
435 self._TestGetMessageStrings( | 413 self._TestGetMessageStrings( |
436 event, expected_message, expected_short_message) | 414 event, expected_message, expected_short_message) |
437 | 415 |
438 | 416 |
439 if __name__ == '__main__': | 417 if __name__ == '__main__': |
440 unittest.main() | 418 unittest.main() |
LEFT | RIGHT |