OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 """Tests for the Less Frequently Used (LFU) Windows Registry plugin.""" | 3 """Tests for the Less Frequently Used (LFU) 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 registry_key.AddValue(registry_value) | 85 registry_key.AddValue(registry_value) |
86 | 86 |
87 value_data = '2'.encode('utf_16_le') | 87 value_data = '2'.encode('utf_16_le') |
88 registry_value = dfwinreg_fake.FakeWinRegistryValue( | 88 registry_value = dfwinreg_fake.FakeWinRegistryValue( |
89 'NumberOfInitialSessions', data=value_data, | 89 'NumberOfInitialSessions', data=value_data, |
90 data_type=dfwinreg_definitions.REG_SZ, offset=243) | 90 data_type=dfwinreg_definitions.REG_SZ, offset=243) |
91 registry_key.AddValue(registry_value) | 91 registry_key.AddValue(registry_value) |
92 | 92 |
93 return registry_key | 93 return registry_key |
94 | 94 |
| 95 def testFilters(self): |
| 96 """Tests the FILTERS class attribute.""" |
| 97 plugin = lfu.BootExecutePlugin() |
| 98 |
| 99 key_path = ( |
| 100 'HKEY_LOCAL_MACHINE\\System\\ControlSet001\\Control\\Session Manager') |
| 101 self._AssertFiltersOnKeyPath(plugin, key_path) |
| 102 |
| 103 self._AssertNotFiltersOnKeyPath(plugin, 'HKEY_LOCAL_MACHINE\\Bogus') |
| 104 |
95 def testProcess(self): | 105 def testProcess(self): |
96 """Tests the Process function.""" | 106 """Tests the Process function.""" |
97 key_path = ( | 107 key_path = ( |
98 'HKEY_LOCAL_MACHINE\\System\\ControlSet001\\Control\\Session Manager') | 108 'HKEY_LOCAL_MACHINE\\System\\ControlSet001\\Control\\Session Manager') |
99 time_string = '2012-08-31 20:45:29' | 109 time_string = '2012-08-31 20:45:29' |
100 registry_key = self._CreateTestKey(key_path, time_string) | 110 registry_key = self._CreateTestKey(key_path, time_string) |
101 | 111 |
102 plugin = lfu.BootExecutePlugin() | 112 plugin = lfu.BootExecutePlugin() |
103 storage_writer = self._ParseKeyWithPlugin(registry_key, plugin) | 113 storage_writer = self._ParseKeyWithPlugin(registry_key, plugin) |
104 | 114 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 169 |
160 value_data = 'C:\\WINDOWS\\system32\\googleupdater.exe'.encode( | 170 value_data = 'C:\\WINDOWS\\system32\\googleupdater.exe'.encode( |
161 'utf_16_le') | 171 'utf_16_le') |
162 registry_value = dfwinreg_fake.FakeWinRegistryValue( | 172 registry_value = dfwinreg_fake.FakeWinRegistryValue( |
163 'ImagePath', data=value_data, data_type=dfwinreg_definitions.REG_SZ, | 173 'ImagePath', data=value_data, data_type=dfwinreg_definitions.REG_SZ, |
164 offset=123) | 174 offset=123) |
165 registry_key.AddValue(registry_value) | 175 registry_key.AddValue(registry_value) |
166 | 176 |
167 return registry_key | 177 return registry_key |
168 | 178 |
| 179 def testFilters(self): |
| 180 """Tests the FILTERS class attribute.""" |
| 181 plugin = lfu.BootVerificationPlugin() |
| 182 |
| 183 key_path = ( |
| 184 'HKEY_LOCAL_MACHINE\\System\\ControlSet001\\Control\\' |
| 185 'BootVerificationProgram') |
| 186 self._AssertFiltersOnKeyPath(plugin, key_path) |
| 187 |
| 188 self._AssertNotFiltersOnKeyPath(plugin, 'HKEY_LOCAL_MACHINE\\Bogus') |
| 189 |
169 def testProcess(self): | 190 def testProcess(self): |
170 """Tests the Process function.""" | 191 """Tests the Process function.""" |
171 key_path = '\\ControlSet001\\Control\\BootVerificationProgram' | 192 key_path = '\\ControlSet001\\Control\\BootVerificationProgram' |
172 time_string = '2012-08-31 20:45:29' | 193 time_string = '2012-08-31 20:45:29' |
173 registry_key = self._CreateTestKey(key_path, time_string) | 194 registry_key = self._CreateTestKey(key_path, time_string) |
174 | 195 |
175 plugin = lfu.BootVerificationPlugin() | 196 plugin = lfu.BootVerificationPlugin() |
176 storage_writer = self._ParseKeyWithPlugin(registry_key, plugin) | 197 storage_writer = self._ParseKeyWithPlugin(registry_key, plugin) |
177 | 198 |
178 self.assertEqual(storage_writer.number_of_events, 1) | 199 self.assertEqual(storage_writer.number_of_events, 1) |
(...skipping 13 matching lines...) Expand all Loading... |
192 '[{0:s}] ' | 213 '[{0:s}] ' |
193 'ImagePath: C:\\WINDOWS\\system32\\googleupdater.exe').format( | 214 'ImagePath: C:\\WINDOWS\\system32\\googleupdater.exe').format( |
194 key_path) | 215 key_path) |
195 expected_short_message = '{0:s}...'.format(expected_message[:77]) | 216 expected_short_message = '{0:s}...'.format(expected_message[:77]) |
196 | 217 |
197 self._TestGetMessageStrings(event, expected_message, expected_short_message) | 218 self._TestGetMessageStrings(event, expected_message, expected_short_message) |
198 | 219 |
199 | 220 |
200 if __name__ == '__main__': | 221 if __name__ == '__main__': |
201 unittest.main() | 222 unittest.main() |
OLD | NEW |