OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*_ coding: utf-8 -*- | 2 # -*_ coding: utf-8 -*- |
3 """Tests for the SCCM Logs Parser.""" | 3 """Tests for the SCCM Logs Parser.""" |
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 plaso.formatters import sccm as _ # pylint: disable=unused-import | 9 from plaso.formatters import sccm as _ # pylint: disable=unused-import |
10 from plaso.lib import timelib | 10 from plaso.lib import timelib |
(...skipping 11 matching lines...) Expand all Loading... |
22 """Tests for the Parse function.""" | 22 """Tests for the Parse function.""" |
23 parser = sccm.SCCMParser() | 23 parser = sccm.SCCMParser() |
24 storage_writer = self._ParseFile(['sccm_various.log'], parser) | 24 storage_writer = self._ParseFile(['sccm_various.log'], parser) |
25 | 25 |
26 self.assertEqual(storage_writer.number_of_events, 10) | 26 self.assertEqual(storage_writer.number_of_events, 10) |
27 | 27 |
28 events = list(storage_writer.GetEvents()) | 28 events = list(storage_writer.GetEvents()) |
29 | 29 |
30 event = events[0] | 30 event = events[0] |
31 expected_timestamp = timelib.Timestamp.CopyFromString( | 31 expected_timestamp = timelib.Timestamp.CopyFromString( |
32 '2014-11-28 14:03:19.766') | 32 '2014-11-29 01:03:19.766') |
33 self.assertEqual(event.timestamp, expected_timestamp) | 33 self.assertEqual(event.timestamp, expected_timestamp) |
34 | 34 |
35 # Test timestamps with seven digits after seconds. | 35 # Test timestamps with seven digits after seconds. |
36 event = events[3] | 36 event = events[3] |
37 expected_timestamp = timelib.Timestamp.CopyFromString( | 37 expected_timestamp = timelib.Timestamp.CopyFromString( |
38 '2015-01-02 10:22:50.873496') | 38 '2015-01-02 10:22:50.873496') |
39 self.assertEqual(event.timestamp, expected_timestamp) | 39 self.assertEqual(event.timestamp, expected_timestamp) |
40 | 40 |
41 # Test timestamps with '-' in microseconds. | 41 # Test timestamps with '-' in microseconds. |
42 event = events[7] | 42 event = events[7] |
43 expected_timestamp = timelib.Timestamp.CopyFromString( | 43 expected_timestamp = timelib.Timestamp.CopyFromString( |
44 '2014-12-28 07:59:43.373') | 44 '2014-12-28 18:59:43.373') |
45 self.assertEqual(event.timestamp, expected_timestamp) | 45 self.assertEqual(event.timestamp, expected_timestamp) |
46 | 46 |
47 # Test timestamps with '+' in microseconds. | 47 # Test timestamps with '+' in microseconds. |
48 event = events[9] | 48 event = events[9] |
49 expected_timestamp = timelib.Timestamp.CopyFromString( | 49 expected_timestamp = timelib.Timestamp.CopyFromString( |
50 '2014-11-24 09:52:13.827') | 50 '2014-11-23 17:52:13.827') |
51 self.assertEqual(event.timestamp, expected_timestamp) | 51 self.assertEqual(event.timestamp, expected_timestamp) |
52 | 52 |
53 # Test full and short message formats. | 53 # Test full and short message formats. |
54 event = events[4] | 54 event = events[4] |
55 expected_message = ( | 55 expected_message = ( |
56 'ContentAccess Releasing content request ' | 56 'ContentAccess Releasing content request ' |
57 '{4EA97AD6-E7E2-4583-92B9-21F532501337}') | 57 '{4EA97AD6-E7E2-4583-92B9-21F532501337}') |
58 | 58 |
59 expected_short_message = ( | 59 expected_short_message = ( |
60 'Releasing content request ' | 60 'Releasing content request ' |
61 '{4EA97AD6-E7E2-4583-92B9-21F532501337}') | 61 '{4EA97AD6-E7E2-4583-92B9-21F532501337}') |
62 | 62 |
63 self._TestGetMessageStrings(event, expected_message, expected_short_message) | 63 self._TestGetMessageStrings(event, expected_message, expected_short_message) |
64 | 64 |
65 | 65 |
66 if __name__ == '__main__': | 66 if __name__ == '__main__': |
67 unittest.main() | 67 unittest.main() |
OLD | NEW |