

def testUserMergeLinux(self):
    'Check Linux users are accurately merged.'
    kb = rdf_client.KnowledgeBase()
    self.assertEqual(len(kb.users), 0)
    kb.MergeOrAddUser(rdf_client.User(username='blake', last_logon=1111))
    self.assertEqual(len(kb.users), 1)
    kb.MergeOrAddUser(rdf_client.User(uid='12', username='blake'))
    self.assertEqual(len(kb.users), 1)
    kb.MergeOrAddUser(rdf_client.User(username='blake', uid='13', desktop='/home/blake/Desktop'))
    self.assertEqual(len(kb.users), 2)
    kb.MergeOrAddUser(rdf_client.User(username='newblake', uid='14', desktop='/home/blake/Desktop'))
    self.assertEqual(len(kb.users), 3)
    (new_attrs, conflicts) = kb.MergeOrAddUser(rdf_client.User(username='newblake', desktop='/home/blakey/Desktop'))
    self.assertEqual(len(kb.users), 3)
    self.assertItemsEqual(new_attrs, ['users.username', 'users.desktop'])
    self.assertItemsEqual(conflicts, [('desktop', '/home/blake/Desktop', '/home/blakey/Desktop')])

dataset/ETHPy150Open google/grr/grr/lib/artifact_utils_test.py UserMergeTest.testUserMergeLinux/original