[SSSD] [PATCH] SSSDConfigTest: Test real config without config_file_version

Lukas Slebodnik lslebodn at redhat.com
Fri Oct 16 08:05:10 UTC 2015


On (15/10/15 19:21), Michal Židek wrote:
>On 10/15/2015 11:16 AM, Lukas Slebodnik wrote:
>>ehlo,
>>
>>let's follow TDD :-)
>>
>>attached are unit tests for regression in
>>https://fedorahosted.org/sssd/ticket/2837
>>
>>LS
>>
>
>Thank you Lukas for the test.
>
>Conditional ACK.
>
>I will fully ack once the CI finishes
>and the original issue is solved in master.
>
I realised we already have test configuration file without config_file_version.
So I merged my file to the old one.

Updated patches are attached.

LS
-------------- next part --------------
>From 9faec696aaa80347af8a06e77e18246315c051f1 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Thu, 15 Oct 2015 10:32:09 +0200
Subject: [PATCH 1/2] SSSDConfigTest: Try load saved config

Python module SSSDConfig should be able to save configuration file
and later load the same configuration file without problem.

Unit test for:
https://fedorahosted.org/sssd/ticket/2837
---
 src/config/SSSDConfigTest.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py
index a850b8d2c5933c4c08b5b0e8f4db79f3c88fc5ee..8a4a2b30a8a5b2422075fd614626d14e6f803a18 100755
--- a/src/config/SSSDConfigTest.py
+++ b/src/config/SSSDConfigTest.py
@@ -157,10 +157,14 @@ class SSSDConfigTestValid(unittest.TestCase):
         #non-owners, and should not be executable by anyone
         self.assertFalse(S_IMODE(mode) & 0o177)
 
+        # try to import saved configuration file
+        config = SSSDConfig.SSSDConfig(srcdir + "/etc/sssd.api.conf",
+                                       srcdir + "/etc/sssd.api.d")
+        config.import_config(configfile=of)
+
         #Remove the output file
         os.unlink(of)
 
-
     def testCreateNewLDAPConfig(self):
         sssdconfig = SSSDConfig.SSSDConfig(srcdir + "/etc/sssd.api.conf",
                                 srcdir + "/etc/sssd.api.d")
@@ -191,9 +195,15 @@ class SSSDConfigTestValid(unittest.TestCase):
         #non-owners, and should not be executable by anyone
         self.assertFalse(S_IMODE(mode) & 0o177)
 
+        # try to import saved configuration file
+        config = SSSDConfig.SSSDConfig(srcdir + "/etc/sssd.api.conf",
+                                       srcdir + "/etc/sssd.api.d")
+        config.import_config(configfile=of)
+
         #Remove the output file
         os.unlink(of)
 
+
     def testModifyExistingConfig(self):
         sssdconfig = SSSDConfig.SSSDConfig(srcdir + "/etc/sssd.api.conf",
                                 srcdir + "/etc/sssd.api.d")
-- 
2.5.0

-------------- next part --------------
>From b940d5d450a9d8fbeb1d25e23285d5978df0d0eb Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Thu, 15 Oct 2015 11:04:06 +0200
Subject: [PATCH 2/2] SSSDConfigTest: Test real config without
 config_file_version

src/config/testconfigs/sssd-valid.conf explicitly contains
config_file_version. Recently we changed the default value to 2
and therefore it needn't be listed in configuration file.
This patch test real sssd.conf without config_file_version.
---
 src/config/SSSDConfigTest.py               | 85 ++++++++++++++++++++++++++++++
 src/config/testconfigs/sssd-noversion.conf | 22 ++++++++
 2 files changed, 107 insertions(+)

diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py
index 8a4a2b30a8a5b2422075fd614626d14e6f803a18..45562214da5d227b45914abbcb298e043048adf5 100755
--- a/src/config/SSSDConfigTest.py
+++ b/src/config/SSSDConfigTest.py
@@ -1243,6 +1243,91 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase):
         self.assertRaises(SSSDConfig.AlreadyInitializedError,
                           sssdconfig.import_config, srcdir + "/testconfigs/sssd-valid.conf")
 
+    def testImportConfigNoVersion(self):
+        # Positive Test
+        sssdconfig = SSSDConfig.SSSDConfig(srcdir + "/etc/sssd.api.conf",
+                                           srcdir + "/etc/sssd.api.d")
+        sssdconfig.import_config(
+            srcdir + "/testconfigs/sssd-noversion.conf"
+        )
+
+        # Validate services
+        services = sssdconfig.list_services()
+        self.assertTrue('sssd' in services)
+        self.assertTrue('nss' in services)
+        self.assertTrue('pam' in services)
+        self.assertTrue('dp' in services)
+
+        #Verify service attributes
+        sssd_service = sssdconfig.get_service('sssd')
+        service_opts = sssd_service.list_options()
+
+        self.assertTrue('services' in service_opts.keys())
+        service_list = sssd_service.get_option('services')
+        self.assertTrue('nss' in service_list)
+        self.assertTrue('pam' in service_list)
+        self.assertTrue('reconnection_retries' in service_opts)
+
+        #Validate domain list
+        domains = sssdconfig.list_domains()
+        self.assertTrue('LOCAL' in domains)
+        self.assertTrue('LDAP' in domains)
+        self.assertTrue('PROXY' in domains)
+        self.assertTrue('IPA' in domains)
+
+        # Verify domain attributes
+        ipa_domain = sssdconfig.get_domain('IPA')
+        domain_opts = ipa_domain.list_options()
+        self.assertTrue('debug_level' in domain_opts.keys())
+        self.assertTrue('id_provider' in domain_opts.keys())
+        self.assertTrue('auth_provider' in domain_opts.keys())
+
+        # Verify domain attributes
+        proxy_domain = sssdconfig.get_domain('PROXY')
+        domain_opts = proxy_domain.list_options()
+        self.assertTrue('debug_level' in domain_opts.keys())
+        self.assertTrue('id_provider' in domain_opts.keys())
+        self.assertTrue('auth_provider' in domain_opts.keys())
+
+        # Verify domain attributes
+        local_domain = sssdconfig.get_domain('LOCAL')
+        domain_opts = local_domain.list_options()
+        self.assertTrue('debug_level' in domain_opts.keys())
+        self.assertTrue('id_provider' in domain_opts.keys())
+        self.assertTrue('auth_provider' in domain_opts.keys())
+
+        # Verify domain attributes
+        ldap_domain = sssdconfig.get_domain('LDAP')
+        domain_opts = ldap_domain.list_options()
+        self.assertTrue('debug_level' in domain_opts.keys())
+        self.assertTrue('id_provider' in domain_opts.keys())
+        self.assertTrue('auth_provider' in domain_opts.keys())
+
+        domain_control_list = [
+            'cache_credentials',
+            'id_provider',
+            'auth_provider',
+            'access_provider',
+            'default_shell',
+            'fallback_homedir',
+            'cache_credentials',
+            'use_fully_qualified_names',
+        ]
+
+        ad_domain = sssdconfig.get_domain("ad.example.com")
+
+        for option in ad_domain.get_all_options():
+            self.assertTrue(option in domain_control_list)
+
+        negative_domain_control_list = [
+            'ad_server',
+            'ldap_id_mapping',
+            'ldap_sasl_authid',
+        ]
+
+        for option in ad_domain.get_all_options():
+            self.assertFalse(option in negative_domain_control_list)
+
     def testNewConfig(self):
         # Positive Test
         sssdconfig = SSSDConfig.SSSDConfig(srcdir + "/etc/sssd.api.conf",
diff --git a/src/config/testconfigs/sssd-noversion.conf b/src/config/testconfigs/sssd-noversion.conf
index 71af85cc07e87ab96372fb91ea52ce36faf21a1e..d5f524d268dd43825364a4b464909cf1b9441646 100644
--- a/src/config/testconfigs/sssd-noversion.conf
+++ b/src/config/testconfigs/sssd-noversion.conf
@@ -39,3 +39,25 @@ debug_level = 0
 [dp]
 debug_level = 0
 
+[domain/ad.example.com]
+cache_credentials = true
+
+id_provider = ad
+auth_provider = ad
+access_provider = ad
+
+# Uncomment if service discovery is not working
+# ad_server = server.ad.example.com
+
+# Uncomment if you want to use POSIX UIDs and GIDs set on the AD side
+# ldap_id_mapping = False
+
+# Comment out if the users have the shell and home dir set on the AD side
+default_shell = /bin/bash
+fallback_homedir = /home/%d/%u
+
+# Uncomment and adjust if the default principal SHORTNAME$@REALM is not available
+# ldap_sasl_authid = host/client.ad.example.com at AD.EXAMPLE.COM
+
+# Comment out if you prefer to user shortnames.
+use_fully_qualified_names = True
-- 
2.5.0



More information about the sssd-devel mailing list