From 0d723176a0ae2e92975688e6cbe94e4b1235c779 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Fri, 3 Aug 2012 12:12:17 -0400
Subject: [PATCH] SSSDConfig: Fix nonfunctional SSSDDomain.remove_provider()

Also adds a regression test to the unit test suite.

https://fedorahosted.org/sssd/ticket/1388
---
 src/config/SSSDConfig/__init__.py.in | 5 +++++
 src/config/SSSDConfigTest.py         | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
index 1daa3907cff79ae552526c5b29d9e47e8ba06985..09ce5ea1094d4780f30aec76e461d3d50e8b7633 100644
--- a/src/config/SSSDConfig/__init__.py.in
+++ b/src/config/SSSDConfig/__init__.py.in
@@ -1248,6 +1248,11 @@ class SSSDDomain(SSSDConfigObject):
             if self.options.has_key(option):
                 del self.options[option]
 
+        # Remove this provider from the option list
+        option = '%s_provider' % provider_type
+        if self.options.has_key(option):
+            del self.options[option]
+
         self.providers.remove((provider, provider_type))
 
 class SSSDConfig(SSSDChangeConf):
diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py
index 9f77188bb1105a4379c8efe5eae97edc3084fcb2..417cea0f3c4a3235e3d51df7b9774be693f79938 100755
--- a/src/config/SSSDConfigTest.py
+++ b/src/config/SSSDConfigTest.py
@@ -950,6 +950,7 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase):
         # Remove the local ID provider and add an LDAP one
         # LDAP ID providers can also use the krb5_realm
         domain.remove_provider('id')
+        self.assertFalse(domain.options.has_key('id_provider'))
 
         domain.add_provider('ldap', 'id')
 
@@ -974,6 +975,7 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase):
         # Remove the auth domain and verify that the options
         # revert to the backup_list
         domain.remove_provider('auth')
+        self.assertFalse(domain.options.has_key('auth_provider'))
         options = domain.list_options()
 
         self.assertTrue(type(options) == dict,
@@ -996,14 +998,17 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase):
 
         # Test removing nonexistent provider - Real
         domain.remove_provider('id')
+        self.assertFalse(domain.options.has_key('id_provider'))
 
         # Test removing nonexistent provider - Bad backend type
         # Should pass without complaint
         domain.remove_provider('id')
+        self.assertFalse(domain.options.has_key('id_provider'))
 
         # Test removing nonexistent provider - Bad provider type
         # Should pass without complaint
         domain.remove_provider('nosuchprovider')
+        self.assertFalse(domain.options.has_key('nosuchprovider_provider'))
 
     def testGetOption(self):
         domain = SSSDConfig.SSSDDomain('sssd', self.schema)
-- 
1.7.11.2

