diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py index 1b39745b5..7d87c8b22 100644 --- a/ipaserver/install/ldapupdate.py +++ b/ipaserver/install/ldapupdate.py @@ -921,20 +921,6 @@ class LDAPUpdate: return self.modified - def update_from_dict(self, updates): - """ - Apply updates internally as opposed to from a file. - updates is a dictionary containing the updates - """ - self.modified = False - try: - self.create_connection() - self._run_updates(updates) - finally: - self.close_connection() - - return self.modified - def close_connection(self): """Close ldap connection""" if self.conn: diff --git a/ipatests/test_install/test_updates.py b/ipatests/test_install/test_updates.py index 3fa2cd7e1..01e06ca2e 100644 --- a/ipatests/test_install/test_updates.py +++ b/ipatests/test_install/test_updates.py @@ -253,98 +253,3 @@ class test_update(unittest.TestCase): with self.assertRaises(BadSyntax): modified = self.updater.update( [os.path.join(self.testdir, "9_badsyntax.update")]) - - def test_from_dict(self): - """ - Test updating from a dict. - - This replicates what was done in test 1. - """ - - # First make sure we're clean - with self.assertRaises(errors.NotFound): - entries = self.ld.get_entries( - self.container_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*']) - - with self.assertRaises(errors.NotFound): - entries = self.ld.get_entries( - self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*']) - - - update = { - self.container_dn: - {'dn': self.container_dn, - 'updates': ['add:objectClass: top', - 'add:objectClass: nsContainer', - 'add:cn: test' - ], - }, - self.user_dn: - {'dn': self.user_dn, - 'updates': ['add:objectclass: top', - 'add:objectclass: person', - 'add:objectclass: posixaccount', - 'add:objectclass: krbprincipalaux', - 'add:objectclass: inetuser', - 'add:homedirectory: /home/tuser', - 'add:loginshell: /bin/bash', - 'add:sn: User', - 'add:uid: tuser', - 'add:uidnumber: 999', - 'add:gidnumber: 999', - 'add:cn: Test User', - ], - }, - } - - modified = self.updater.update_from_dict(update) - self.assertTrue(modified) - - entries = self.ld.get_entries( - self.container_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*']) - self.assertEqual(len(entries), 1) - entry = entries[0] - - objectclasses = entry.get('objectclass') - for item in ('top', 'nsContainer'): - self.assertTrue(item in objectclasses) - - self.assertEqual(entry.single_value['cn'], 'test') - - entries = self.ld.get_entries( - self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*']) - self.assertEqual(len(entries), 1) - entry = entries[0] - - objectclasses = entry.get('objectclass') - for item in ('top', 'person', 'posixaccount', 'krbprincipalaux', 'inetuser'): - self.assertTrue(item in objectclasses) - - self.assertEqual(entry.single_value['loginshell'], paths.BASH) - self.assertEqual(entry.single_value['sn'], 'User') - self.assertEqual(entry.single_value['uid'], 'tuser') - self.assertEqual(entry.single_value['cn'], 'Test User') - - # Now delete - - update = { - self.container_dn: - {'dn': self.container_dn, - 'deleteentry': None, - }, - self.user_dn: - {'dn': self.user_dn, - 'deleteentry': 'deleteentry: reset: nada', - }, - } - - modified = self.updater.update_from_dict(update) - self.assertTrue(modified) - - with self.assertRaises(errors.NotFound): - entries = self.ld.get_entries( - self.container_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*']) - - with self.assertRaises(errors.NotFound): - entries = self.ld.get_entries( - self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])