summaryrefslogtreecommitdiffstats
path: root/server/config/SSSDConfigTest.py
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-12-08 23:27:52 -0500
committerStephen Gallagher <sgallagh@redhat.com>2009-12-08 23:35:25 -0500
commite51458f89be94b86d6b5dab0c8ebe0e7ba197003 (patch)
treea0f1a1b1e70acc6a8b7ae47e4b90ebc9cff158c9 /server/config/SSSDConfigTest.py
parentcb58da00f547c5a78718ec35ec27ae83d2b59099 (diff)
downloadsssd-e51458f89be94b86d6b5dab0c8ebe0e7ba197003.tar.gz
sssd-e51458f89be94b86d6b5dab0c8ebe0e7ba197003.tar.xz
sssd-e51458f89be94b86d6b5dab0c8ebe0e7ba197003.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.py36
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