

def testUserMergeWindows(self):
    'Check Windows users are accurately merged.'
    kb = rdf_client.KnowledgeBase()
    self.assertEqual(len(kb.users), 0)
    kb.MergeOrAddUser(rdf_client.User(sid='1234'))
    self.assertEqual(len(kb.users), 1)
    kb.MergeOrAddUser(rdf_client.User(sid='5678', username='test1'))
    self.assertEqual(len(kb.users), 2)
    (_, conflicts) = conflicts.MergeOrAddUser(rdf_client.User(sid='5678', username='test2'))
    self.assertEqual(len(kb.users), 2)
    self.assertEqual(conflicts[0], ('username', 'test1', 'test2'))
    self.assertEqual(kb.GetUser(sid='5678').username, 'test2')
    kb.MergeOrAddUser(rdf_client.User(username='test2', homedir='a'))
    self.assertEqual(len(kb.users), 2)
    (new_attrs, conflicts) = kb.MergeOrAddUser(rdf_client.User(username='test2', sid='12345', temp='/blah'))
    self.assertEqual(len(kb.users), 3)
    self.assertItemsEqual(new_attrs, ['users.username', 'users.temp', 'users.sid'])
    self.assertEqual(conflicts, [])

dataset/ETHPy150Open google/grr/grr/lib/artifact_utils_test.py UserMergeTest.testUserMergeWindows/VarMisuse@100/142 `kb`->`conflicts`