diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-12-07 14:50:48 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-12-08 23:35:29 -0500 |
commit | afa260fcc56bde83e4b77282c7b3b22cfb4eca47 (patch) | |
tree | 48fb986e0e32629b198919e19c4fc26cb985ac70 /server | |
parent | 62bbadfe0aaa9348e3a05b5ce960e8c4e5a8d44b (diff) | |
download | sssd-afa260fcc56bde83e4b77282c7b3b22cfb4eca47.tar.gz sssd-afa260fcc56bde83e4b77282c7b3b22cfb4eca47.tar.bz2 sssd-afa260fcc56bde83e4b77282c7b3b22cfb4eca47.zip |
SSSDDomain.remove_provider() requires only the provider type
There was no valid reason to require the backend type when
specifying a provider to remove.
Diffstat (limited to 'server')
-rw-r--r-- | server/config/SSSDConfig.py | 18 | ||||
-rw-r--r-- | server/config/SSSDConfigTest.py | 12 |
2 files changed, 18 insertions, 12 deletions
diff --git a/server/config/SSSDConfig.py b/server/config/SSSDConfig.py index 1cbf1a84..1992a940 100644 --- a/server/config/SSSDConfig.py +++ b/server/config/SSSDConfig.py @@ -787,14 +787,12 @@ class SSSDDomain(SSSDConfigObject): provider_type))) - def remove_provider(self, provider, provider_type): + def remove_provider(self, provider_type): """ Remove a provider from the domain. If the provider is not present, it is ignored. - type: - Provider backend type. (e.g. local, ldap, krb5, etc.) - subtype: + provider_type: Subtype of the backend type. (e.g. id, auth, chpass) === Returns === @@ -803,7 +801,15 @@ class SSSDDomain(SSSDConfigObject): === Errors === No Errors """ - if (provider,provider_type) not in self.providers: + + provider = None + for (provider, ptype) in self.providers: + if ptype == provider_type: + break + provider = None + + # Check whether the provider_type was found + if not provider: return # TODO: safely remove any unused options when removing @@ -811,7 +817,7 @@ class SSSDDomain(SSSDConfigObject): # to account for multiple providers making use of the # same options (such ask krb5_realm) - self.providers.remove((provider,provider_type)) + self.providers.remove((provider, provider_type)) class SSSDConfig(SSSDChangeConf): """ diff --git a/server/config/SSSDConfigTest.py b/server/config/SSSDConfigTest.py index ac37aec9..fa111819 100644 --- a/server/config/SSSDConfigTest.py +++ b/server/config/SSSDConfigTest.py @@ -142,7 +142,7 @@ class SSSDConfigTestValid(unittest.TestCase): ldap_domain = sssdconfig.get_domain('LDAP') ldap_domain.set_option('debug_level', 3) - ldap_domain.remove_provider('ldap', 'auth') + ldap_domain.remove_provider('auth') ldap_domain.add_provider('krb5', 'auth') ldap_domain.set_active(True) sssdconfig.save_domain(ldap_domain) @@ -455,7 +455,7 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase): # Remove the auth domain and verify that the options # revert to the backup_list - domain.remove_provider('krb5', 'auth') + domain.remove_provider('auth') options = domain.list_options() self.assertTrue(type(options) == dict, @@ -666,7 +666,7 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase): # Remove the auth domain and verify that the options # revert to the backup_list - domain.remove_provider('krb5', 'auth') + domain.remove_provider('auth') options = domain.list_options() self.assertTrue(type(options) == dict, @@ -685,15 +685,15 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase): option) # Test removing nonexistent provider - Real - domain.remove_provider('ldap', 'id') + domain.remove_provider('id') # Test removing nonexistent provider - Bad backend type # Should pass without complaint - domain.remove_provider('nosuchbackend', 'id') + domain.remove_provider('id') # Test removing nonexistent provider - Bad provider type # Should pass without complaint - domain.remove_provider('ldap', 'nosuchprovider') + domain.remove_provider('nosuchprovider') def testGetOption(self): domain = SSSDConfig.SSSDDomain('sssd', self.schema) |