diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-12-09 07:33:51 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-12-09 10:05:18 -0500 |
commit | 2de0208d7499603c78d232361030f9a73fa6adda (patch) | |
tree | 16edb0d8b6015ef05a43a869234ed49d6ed806f3 | |
parent | 59264f7e1c1d750cba249aada3696c25ec20bcc4 (diff) | |
download | sssd-2de0208d7499603c78d232361030f9a73fa6adda.tar.gz sssd-2de0208d7499603c78d232361030f9a73fa6adda.tar.bz2 sssd-2de0208d7499603c78d232361030f9a73fa6adda.zip |
SSSDConfig.get_domain() should properly detect active state
-rw-r--r-- | server/config/SSSDConfig.py | 29 | ||||
-rw-r--r-- | server/config/SSSDConfigTest.py | 1 |
2 files changed, 30 insertions, 0 deletions
diff --git a/server/config/SSSDConfig.py b/server/config/SSSDConfig.py index f00824d5..10d2f02a 100644 --- a/server/config/SSSDConfig.py +++ b/server/config/SSSDConfig.py @@ -1238,6 +1238,9 @@ class SSSDConfig(SSSDChangeConf): for opt in self.strip_comments_empty(self.options('domain/%s' % name)) if opt not in providers] + # Determine if this domain is currently active + domain.active = self.is_domain_active(name) + return domain def new_domain(self, name): @@ -1266,6 +1269,32 @@ class SSSDConfig(SSSDChangeConf): self.save_domain(domain) return domain + def is_domain_active(self, name): + """ + Is a particular domain set active + + name: + The name of the configured domain to check + + === Returns === + True if the domain is active, False if it is inactive + + === Errors === + NotInitializedError: + This SSSDConfig object has not had import_config() or new_config() + run on it yet. + NoDomainError: + No domain by this name is configured + """ + + if not self.initialized: + raise NotInitializedError + + if name not in self.list_domains(): + raise NoDomainError + + return name in self.list_active_domains() + def activate_domain(self, name): """ Activate a configured domain diff --git a/server/config/SSSDConfigTest.py b/server/config/SSSDConfigTest.py index 0d42d8a6..abb2b071 100644 --- a/server/config/SSSDConfigTest.py +++ b/server/config/SSSDConfigTest.py @@ -1103,6 +1103,7 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase): domain = sssdconfig.get_domain('IPA') self.assertTrue(isinstance(domain, SSSDConfig.SSSDDomain)) + self.assertTrue(domain.active) # TODO verify the contents of this domain |