diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-12-08 23:27:52 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-12-08 23:35:30 -0500 |
commit | 2ec2a11ffb8b0c27bcf66d3913ca4ad1b5a47999 (patch) | |
tree | 4bef29700aede2339e5ce83da06105f9d360cae0 /server/config/SSSDConfigTest.py | |
parent | e860d5338239bfc1970347180a4902018871a11e (diff) | |
download | sssd-2ec2a11ffb8b0c27bcf66d3913ca4ad1b5a47999.tar.gz sssd-2ec2a11ffb8b0c27bcf66d3913ca4ad1b5a47999.tar.xz sssd-2ec2a11ffb8b0c27bcf66d3913ca4ad1b5a47999.zip |
Add SSSDDomain.set_name() function to SSSDConfig API
This function will change the name of an existing domain
Diffstat (limited to 'server/config/SSSDConfigTest.py')
-rw-r--r-- | server/config/SSSDConfigTest.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/server/config/SSSDConfigTest.py b/server/config/SSSDConfigTest.py index 3d8b596ac..41cd270e3 100644 --- a/server/config/SSSDConfigTest.py +++ b/server/config/SSSDConfigTest.py @@ -780,6 +780,23 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase): domain.remove_option('nosuchoption') self.assertFalse('nosuchoption' in domain.get_all_options().keys()) + def testSetName(self): + domain = SSSDConfig.SSSDDomain('sssd', self.schema) + + # Positive test - Change the name once + domain.set_name('sssd2'); + self.assertEqual(domain.get_name(), 'sssd2') + self.assertEqual(domain.oldname, 'sssd') + + # Positive test - Change the name a second time + domain.set_name('sssd3') + self.assertEqual(domain.get_name(), 'sssd3') + self.assertEqual(domain.oldname, 'sssd') + + # Negative test - try setting the name to a non-string + self.assertRaises(TypeError, + domain.set_name, 4) + class SSSDConfigTestSSSDConfig(unittest.TestCase): def setUp(self): pass @@ -1122,9 +1139,11 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase): self.assertTrue('IPA' in sssdconfig.list_domains()) self.assertTrue('IPA' in sssdconfig.list_active_domains()) + self.assertTrue(sssdconfig.has_section('domain/IPA')) sssdconfig.delete_domain('IPA') self.assertFalse('IPA' in sssdconfig.list_domains()) self.assertFalse('IPA' in sssdconfig.list_active_domains()) + self.assertFalse(sssdconfig.has_section('domain/IPA')) def testSaveDomain(self): sssdconfig = SSSDConfig.SSSDConfig("etc/sssd.api.conf", @@ -1148,6 +1167,23 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase): # Negative Test - Type Error self.assertRaises(TypeError, sssdconfig.save_domain, self) + # Positive test - Change the domain name and save it + domain.set_name('example.com2') + self.assertEqual(domain.name,'example.com2') + self.assertEqual(domain.oldname,'example.com') + sssdconfig.save_domain(domain) + + self.assertTrue('example.com2' in sssdconfig.list_domains()) + self.assertTrue('example.com2' in sssdconfig.list_active_domains()) + self.assertTrue(sssdconfig.has_section('domain/example.com2')) + self.assertEqual(sssdconfig.get('domain/example.com2', + 'ldap_uri'), + 'ldap://ldap.example.com') + self.assertFalse('example.com' in sssdconfig.list_domains()) + self.assertFalse('example.com' in sssdconfig.list_active_domains()) + self.assertFalse('example.com' in sssdconfig.list_inactive_domains()) + self.assertFalse(sssdconfig.has_section('domain/example.com')) + if __name__ == "__main__": error = 0 |