Exemplo n.º 1
0
    def testProcess(self):
        """Tests the Process function."""
        plist_name = 'InstallHistory.plist'

        plugin = install_history.InstallHistoryPlugin()
        storage_writer = self._ParsePlistFileWithPlugin(
            plugin, [plist_name], plist_name)

        number_of_events = storage_writer.GetNumberOfAttributeContainers(
            'event')
        self.assertEqual(number_of_events, 7)

        number_of_warnings = storage_writer.GetNumberOfAttributeContainers(
            'extraction_warning')
        self.assertEqual(number_of_warnings, 0)

        number_of_warnings = storage_writer.GetNumberOfAttributeContainers(
            'recovery_warning')
        self.assertEqual(number_of_warnings, 0)

        # The order in which PlistParser generates events is nondeterministic
        # hence we sort the events.
        events = list(storage_writer.GetSortedEvents())

        expected_timestamps = [
            1384225175000000, 1388205491000000, 1388232883000000,
            1388232883000000, 1388232883000000, 1388232883000000,
            1390941528000000
        ]
        timestamps = sorted([event.timestamp for event in events])

        self.assertEqual(timestamps, expected_timestamps)

        expected_event_values = {
            'data_type':
            'plist:key',
            'desc':
            ('Installation of [OS X 10.9 (13A603)] using [OS X Installer]. '
             'Packages: com.apple.pkg.BaseSystemBinaries, '
             'com.apple.pkg.BaseSystemResources, '
             'com.apple.pkg.Essentials, com.apple.pkg.BSD, '
             'com.apple.pkg.JavaTools, com.apple.pkg.AdditionalEssentials, '
             'com.apple.pkg.AdditionalSpeechVoices, '
             'com.apple.pkg.AsianLanguagesSupport, com.apple.pkg.MediaFiles, '
             'com.apple.pkg.JavaEssentials, com.apple.pkg.OxfordDictionaries, '
             'com.apple.pkg.X11redirect, com.apple.pkg.OSInstall, '
             'com.apple.pkg.update.compatibility.2013.001.'),
            'key':
            '',
            'root':
            '/item'
        }

        self.CheckEventValues(storage_writer, events[0], expected_event_values)
Exemplo n.º 2
0
    def testProcess(self):
        """Tests the Process function."""
        plist_name = 'InstallHistory.plist'

        plugin = install_history.InstallHistoryPlugin()
        storage_writer = self._ParsePlistFileWithPlugin(
            plugin, [plist_name], plist_name)

        self.assertEqual(storage_writer.number_of_warnings, 0)
        self.assertEqual(storage_writer.number_of_events, 7)

        # The order in which PlistParser generates events is nondeterministic
        # hence we sort the events.
        events = list(storage_writer.GetSortedEvents())

        expected_timestamps = [
            1384225175000000, 1388205491000000, 1388232883000000,
            1388232883000000, 1388232883000000, 1388232883000000,
            1390941528000000
        ]
        timestamps = sorted([event.timestamp for event in events])

        self.assertEqual(timestamps, expected_timestamps)

        expected_description = (
            'Installation of [OS X 10.9 (13A603)] using [OS X Installer]. '
            'Packages: com.apple.pkg.BaseSystemBinaries, '
            'com.apple.pkg.BaseSystemResources, '
            'com.apple.pkg.Essentials, com.apple.pkg.BSD, '
            'com.apple.pkg.JavaTools, com.apple.pkg.AdditionalEssentials, '
            'com.apple.pkg.AdditionalSpeechVoices, '
            'com.apple.pkg.AsianLanguagesSupport, com.apple.pkg.MediaFiles, '
            'com.apple.pkg.JavaEssentials, com.apple.pkg.OxfordDictionaries, '
            'com.apple.pkg.X11redirect, com.apple.pkg.OSInstall, '
            'com.apple.pkg.update.compatibility.2013.001.')

        expected_event_values = {
            'desc': expected_description,
            'key': '',
            'root': '/item'
        }

        self.CheckEventValues(storage_writer, events[0], expected_event_values)

        expected_message = '/item/ {0:s}'.format(expected_description)
        expected_short_message = '{0:s}...'.format(expected_message[:77])

        event_data = self._GetEventDataOfEvent(storage_writer, events[0])
        self._TestGetMessageStrings(event_data, expected_message,
                                    expected_short_message)
Exemplo n.º 3
0
    def testProcess(self):
        """Tests the Process function."""
        plist_name = u'InstallHistory.plist'

        plugin_object = install_history.InstallHistoryPlugin()
        storage_writer = self._ParsePlistFileWithPlugin(
            plugin_object, [plist_name], plist_name)

        self.assertEqual(len(storage_writer.events), 7)

        # The order in which PlistParser generates events is nondeterministic
        # hence we sort the events.
        events = self._GetSortedEvents(storage_writer.events)

        expected_timestamps = [
            1384225175000000, 1388205491000000, 1388232883000000,
            1388232883000000, 1388232883000000, 1388232883000000,
            1390941528000000
        ]
        timestamps = sorted(
            [event_object.timestamp for event_object in events])

        self.assertEqual(timestamps, expected_timestamps)

        event_object = events[0]
        self.assertEqual(event_object.key, u'')
        self.assertEqual(event_object.root, u'/item')

        expected_description = (
            u'Installation of [OS X 10.9 (13A603)] using [OS X Installer]. '
            u'Packages: com.apple.pkg.BaseSystemBinaries, '
            u'com.apple.pkg.BaseSystemResources, '
            u'com.apple.pkg.Essentials, com.apple.pkg.BSD, '
            u'com.apple.pkg.JavaTools, com.apple.pkg.AdditionalEssentials, '
            u'com.apple.pkg.AdditionalSpeechVoices, '
            u'com.apple.pkg.AsianLanguagesSupport, com.apple.pkg.MediaFiles, '
            u'com.apple.pkg.JavaEssentials, com.apple.pkg.OxfordDictionaries, '
            u'com.apple.pkg.X11redirect, com.apple.pkg.OSInstall, '
            u'com.apple.pkg.update.compatibility.2013.001.')
        self.assertEqual(event_object.desc, expected_description)

        expected_message = u'/item/ {0:s}'.format(expected_description)
        expected_message_short = u'{0:s}...'.format(expected_message[:77])
        self._TestGetMessageStrings(event_object, expected_message,
                                    expected_message_short)
Exemplo n.º 4
0
 def setUp(self):
     """Makes preparations before running an individual test."""
     self._plugin = install_history.InstallHistoryPlugin()
     self._parser = plist.PlistParser()
Exemplo n.º 5
0
 def setUp(self):
   """Sets up the needed objects used throughout the test."""
   self._plugin = install_history.InstallHistoryPlugin(None)
   self._parser = plist.PlistParser(event.PreprocessObject(), None)
Exemplo n.º 6
0
 def setUp(self):
     """Sets up the needed objects used throughout the test."""
     self._plugin = install_history.InstallHistoryPlugin()
     self._parser = plist.PlistParser()