def testRun(self): """Tests the Run function.""" test_file_path = self._GetTestFilePath(['nobody.plist']) self._SkipIfPathNotExists(test_file_path) file_system_builder = fake_file_system_builder.FakeFileSystemBuilder() file_system_builder.AddFileReadData( '/private/var/db/dslocal/nodes/Default/users/nobody.plist', test_file_path) mount_point = fake_path_spec.FakePathSpec(location='/') plugin = macos.MacOSUserAccountsPlugin() knowledge_base = self._RunPreprocessorPluginOnFileSystem( file_system_builder.file_system, mount_point, plugin) users = sorted(knowledge_base.user_accounts, key=lambda user_account: user_account.identifier) self.assertEqual(len(users), 1) user_account = users[0] self.assertEqual(user_account.identifier, '-2') self.assertEqual(user_account.full_name, 'Unprivileged User') self.assertEqual(user_account.user_directory, '/var/empty') self.assertEqual(user_account.username, 'nobody')
def testRun(self): """Tests the Run function.""" test_file_path = self._GetTestFilePath(['nobody.plist']) self._SkipIfPathNotExists(test_file_path) file_system_builder = fake_file_system_builder.FakeFileSystemBuilder() file_system_builder.AddFileReadData( '/private/var/db/dslocal/nodes/Default/users/nobody.plist', test_file_path) mount_point = fake_path_spec.FakePathSpec(location='/') storage_writer = self._CreateTestStorageWriter() plugin = macos.MacOSUserAccountsPlugin() test_mediator = self._RunPreprocessorPluginOnFileSystem( file_system_builder.file_system, mount_point, storage_writer, plugin) number_of_warnings = storage_writer.GetNumberOfAttributeContainers( 'preprocessing_warning') self.assertEqual(number_of_warnings, 0) users = sorted(test_mediator.knowledge_base.user_accounts, key=lambda user_account: user_account.identifier) self.assertEqual(len(users), 1) user_account = users[0] self.assertEqual(user_account.identifier, '-2') self.assertEqual(user_account.full_name, 'Unprivileged User') self.assertEqual(user_account.user_directory, '/var/empty') self.assertEqual(user_account.username, 'nobody')
def testRunWithTruncatedFile(self): """Tests the Run function on a truncated plist file.""" test_file_path = self._GetTestFilePath(['truncated.plist']) self._SkipIfPathNotExists(test_file_path) file_system_builder = fake_file_system_builder.FakeFileSystemBuilder() file_system_builder.AddFileReadData( '/private/var/db/dslocal/nodes/Default/users/nobody.plist', test_file_path) mount_point = fake_path_spec.FakePathSpec(location='/') storage_writer = self._CreateTestStorageWriter() plugin = macos.MacOSUserAccountsPlugin() self._RunPreprocessorPluginOnFileSystem( file_system_builder.file_system, mount_point, storage_writer, plugin) self.assertEqual(storage_writer.number_of_preprocessing_warnings, 1)