LEFT | RIGHT |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 """Tests for the MRUList Windows Registry plugin.""" | 3 """Tests for the MRUList 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 dfdatetime import filetime as dfdatetime_filetime | 9 from dfdatetime import filetime as dfdatetime_filetime |
10 from dfwinreg import definitions as dfwinreg_definitions | 10 from dfwinreg import definitions as dfwinreg_definitions |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 registry_value = dfwinreg_fake.FakeWinRegistryValue('MRUList') | 78 registry_value = dfwinreg_fake.FakeWinRegistryValue('MRUList') |
79 registry_key.AddValue(registry_value) | 79 registry_key.AddValue(registry_value) |
80 | 80 |
81 registry_value = dfwinreg_fake.FakeWinRegistryValue('a') | 81 registry_value = dfwinreg_fake.FakeWinRegistryValue('a') |
82 registry_key.AddValue(registry_value) | 82 registry_key.AddValue(registry_value) |
83 | 83 |
84 result = self._CheckFiltersOnKeyPath(plugin, registry_key) | 84 result = self._CheckFiltersOnKeyPath(plugin, registry_key) |
85 self.assertTrue(result) | 85 self.assertTrue(result) |
86 | 86 |
87 key_path = 'HKEY_LOCAL_MACHINE\\Bogus' | 87 self._AssertNotFiltersOnKeyPath(plugin, 'HKEY_LOCAL_MACHINE\\Bogus') |
88 registry_key = dfwinreg_fake.FakeWinRegistryKey('Bogus', key_path=key_path) | |
89 | |
90 result = self._CheckFiltersOnKeyPath(plugin, registry_key) | |
91 self.assertFalse(result) | |
92 | 88 |
93 key_path = ( | 89 key_path = ( |
94 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' | 90 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' |
95 'Explorer\\DesktopStreamMRU') | 91 'Explorer\\DesktopStreamMRU') |
96 registry_key = dfwinreg_fake.FakeWinRegistryKey( | 92 self._AssertNotFiltersOnKeyPath(plugin, key_path) |
97 'DesktopStreamMRU', key_path=key_path) | |
98 | |
99 result = self._CheckFiltersOnKeyPath(plugin, registry_key) | |
100 self.assertFalse(result) | |
101 | 93 |
102 def testProcess(self): | 94 def testProcess(self): |
103 """Tests the Process function.""" | 95 """Tests the Process function.""" |
104 key_path = ( | 96 key_path = ( |
105 'HKEY_CURRENT_USER\\Software\\Microsoft\\Some Windows\\' | 97 'HKEY_CURRENT_USER\\Software\\Microsoft\\Some Windows\\' |
106 'InterestingApp\\MRU') | 98 'InterestingApp\\MRU') |
107 time_string = '2012-08-28 09:23:49.002031' | 99 time_string = '2012-08-28 09:23:49.002031' |
108 registry_key = self._CreateTestKey(key_path, time_string) | 100 registry_key = self._CreateTestKey(key_path, time_string) |
109 | 101 |
110 plugin = mrulist.MRUListStringPlugin() | 102 plugin = mrulist.MRUListStringPlugin() |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 172 |
181 return registry_key | 173 return registry_key |
182 | 174 |
183 def testFilters(self): | 175 def testFilters(self): |
184 """Tests the FILTERS class attribute.""" | 176 """Tests the FILTERS class attribute.""" |
185 plugin = mrulist.MRUListShellItemListPlugin() | 177 plugin = mrulist.MRUListShellItemListPlugin() |
186 | 178 |
187 key_path = ( | 179 key_path = ( |
188 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' | 180 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' |
189 'Explorer\\DesktopStreamMRU') | 181 'Explorer\\DesktopStreamMRU') |
190 registry_key = dfwinreg_fake.FakeWinRegistryKey( | 182 self._AssertFiltersOnKeyPath(plugin, key_path) |
191 'DesktopStreamMRU', key_path=key_path) | 183 |
192 | 184 self._AssertNotFiltersOnKeyPath(plugin, 'HKEY_LOCAL_MACHINE\\Bogus') |
193 result = self._CheckFiltersOnKeyPath(plugin, registry_key) | |
194 self.assertTrue(result) | |
195 | |
196 key_path = 'HKEY_LOCAL_MACHINE\\Bogus' | |
197 registry_key = dfwinreg_fake.FakeWinRegistryKey('Bogus', key_path=key_path) | |
198 | |
199 result = self._CheckFiltersOnKeyPath(plugin, registry_key) | |
200 self.assertFalse(result) | |
201 | 185 |
202 def testProcess(self): | 186 def testProcess(self): |
203 """Tests the Process function.""" | 187 """Tests the Process function.""" |
204 key_path = ( | 188 key_path = ( |
205 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' | 189 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\' |
206 'Explorer\\DesktopStreamMRU') | 190 'Explorer\\DesktopStreamMRU') |
207 time_string = '2012-08-28 09:23:49.002031' | 191 time_string = '2012-08-28 09:23:49.002031' |
208 registry_key = self._CreateTestKey(key_path, time_string) | 192 registry_key = self._CreateTestKey(key_path, time_string) |
209 | 193 |
210 plugin = mrulist.MRUListShellItemListPlugin() | 194 plugin = mrulist.MRUListShellItemListPlugin() |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 expected_short_message = ( | 231 expected_short_message = ( |
248 'Name: Winnt ' | 232 'Name: Winnt ' |
249 'Origin: HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\' | 233 'Origin: HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\' |
250 'CurrentVersi...') | 234 'CurrentVersi...') |
251 | 235 |
252 self._TestGetMessageStrings(event, expected_message, expected_short_message) | 236 self._TestGetMessageStrings(event, expected_message, expected_short_message) |
253 | 237 |
254 | 238 |
255 if __name__ == '__main__': | 239 if __name__ == '__main__': |
256 unittest.main() | 240 unittest.main() |
LEFT | RIGHT |