From 126c7c6932bba62342eefdc910877df1075e4a70 Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka Date: Sep 22 2016 11:02:57 +0000 Subject: Remove update_from_dict() method update_from_dict() method is not used anywhere in the project, it only makes the tests fail. Removed it and its tests. https://fedorahosted.org/freeipa/ticket/6311 Reviewed-By: Alexander Bokovoy --- diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py index fe2fe10..f332ec8 100644 --- a/ipaserver/install/ldapupdate.py +++ b/ipaserver/install/ldapupdate.py @@ -922,20 +922,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 3fa2cd7..01e06ca 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=*', ['*'])