dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0140-TEST-Add-regression-test-for-ticket-3179.patch

b2d430
From d3e93eafcf3e484ee8ec092c59914018b42ea4ad Mon Sep 17 00:00:00 2001
b2d430
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzidek@redhat.com>
b2d430
Date: Wed, 7 Sep 2016 18:23:16 +0200
b2d430
Subject: [PATCH 140/140] TEST: Add regression test for ticket #3179
b2d430
MIME-Version: 1.0
b2d430
Content-Type: text/plain; charset=UTF-8
b2d430
Content-Transfer-Encoding: 8bit
b2d430
b2d430
Resolves:
b2d430
https://fedorahosted.org/sssd/ticket/3179
b2d430
b2d430
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
b2d430
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
b2d430
(cherry picked from commit 1c72723cde8bea0d390b928c7cd29e48e7a7deab)
b2d430
---
b2d430
 src/tests/intg/ldap_local_override_test.py | 126 ++++++++++++++++++++++++++---
b2d430
 1 file changed, 114 insertions(+), 12 deletions(-)
b2d430
b2d430
diff --git a/src/tests/intg/ldap_local_override_test.py b/src/tests/intg/ldap_local_override_test.py
b2d430
index 046535c7727d0f2271f4b974f68ba0722222982b..832849713e1185e836f3dd6decf2deac79ab98dd 100644
b2d430
--- a/src/tests/intg/ldap_local_override_test.py
b2d430
+++ b/src/tests/intg/ldap_local_override_test.py
b2d430
@@ -205,27 +205,38 @@ def assert_user_default():
b2d430
     ent.assert_passwd_by_name('user2@LDAP', user2)
b2d430
 
b2d430
 
b2d430
-def assert_user_overriden():
b2d430
+def assert_user_overriden(override_name=True):
b2d430
 
b2d430
-    user1 = dict(name='ov_user1', passwd='*', uid=10010, gid=20010,
b2d430
+    if override_name:
b2d430
+        name1 = "ov_user1"
b2d430
+        name2 = "ov_user2"
b2d430
+    else:
b2d430
+        name1 = "user1"
b2d430
+        name2 = "user2"
b2d430
+
b2d430
+    user1 = dict(name=name1, passwd='*', uid=10010, gid=20010,
b2d430
                  gecos='Overriden User 1',
b2d430
                  dir='/home/ov/user1',
b2d430
                  shell='/bin/ov_user1_shell')
b2d430
 
b2d430
-    user2 = dict(name='ov_user2', passwd='*', uid=10020, gid=20020,
b2d430
+    user2 = dict(name=name2, passwd='*', uid=10020, gid=20020,
b2d430
                  gecos='Overriden User 2',
b2d430
                  dir='/home/ov/user2',
b2d430
                  shell='/bin/ov_user2_shell')
b2d430
 
b2d430
     ent.assert_passwd_by_name('user1', user1)
b2d430
     ent.assert_passwd_by_name('user1@LDAP', user1)
b2d430
-    ent.assert_passwd_by_name('ov_user1', user1)
b2d430
-    ent.assert_passwd_by_name('ov_user1@LDAP', user1)
b2d430
+
b2d430
+    if override_name:
b2d430
+        ent.assert_passwd_by_name('ov_user1', user1)
b2d430
+        ent.assert_passwd_by_name('ov_user1@LDAP', user1)
b2d430
 
b2d430
     ent.assert_passwd_by_name('user2', user2)
b2d430
     ent.assert_passwd_by_name('user2@LDAP', user2)
b2d430
-    ent.assert_passwd_by_name('ov_user2', user2)
b2d430
-    ent.assert_passwd_by_name('ov_user2@LDAP', user2)
b2d430
+
b2d430
+    if override_name:
b2d430
+        ent.assert_passwd_by_name('ov_user2', user2)
b2d430
+        ent.assert_passwd_by_name('ov_user2@LDAP', user2)
b2d430
 
b2d430
 
b2d430
 #
b2d430
@@ -514,6 +525,54 @@ def test_imp_exp_user_override(ldap_conn, env_imp_exp_user_override):
b2d430
     assert_user_overriden()
b2d430
 
b2d430
 
b2d430
+# Regression test for bug 3179
b2d430
+
b2d430
+
b2d430
+def test_imp_exp_user_overrride_noname(ldap_conn,
b2d430
+                                       env_two_users_and_group):
b2d430
+
b2d430
+    # Override
b2d430
+    subprocess.check_call(["sss_override", "user-add", "user1",
b2d430
+                           "-u", "10010",
b2d430
+                           "-g", "20010",
b2d430
+                           "-c", "Overriden User 1",
b2d430
+                           "-h", "/home/ov/user1",
b2d430
+                           "-s", "/bin/ov_user1_shell"])
b2d430
+
b2d430
+    subprocess.check_call(["sss_override", "user-add", "user2@LDAP",
b2d430
+                           "-u", "10020",
b2d430
+                           "-g", "20020",
b2d430
+                           "-c", "Overriden User 2",
b2d430
+                           "-h", "/home/ov/user2",
b2d430
+                           "-s", "/bin/ov_user2_shell"])
b2d430
+
b2d430
+    # Restart SSSD so the override might take effect
b2d430
+    restart_sssd()
b2d430
+
b2d430
+    # Assert entries are overriden
b2d430
+    assert_user_overriden(override_name=False)
b2d430
+
b2d430
+    # Export overrides
b2d430
+    subprocess.check_call(["sss_override", "user-export", OVERRIDE_FILENAME])
b2d430
+
b2d430
+    # Drop all overrides
b2d430
+    subprocess.check_call(["sss_override", "user-del", "user1"])
b2d430
+    subprocess.check_call(["sss_override", "user-del", "user2@LDAP"])
b2d430
+
b2d430
+    # Avoid hitting memory cache
b2d430
+    time.sleep(2)
b2d430
+
b2d430
+    # Assert entries are not overridden
b2d430
+    assert_user_default()
b2d430
+
b2d430
+    # Import overrides
b2d430
+    subprocess.check_call(["sss_override", "user-import",
b2d430
+                           OVERRIDE_FILENAME])
b2d430
+    restart_sssd()
b2d430
+
b2d430
+    assert_user_overriden(override_name=False)
b2d430
+
b2d430
+
b2d430
 #
b2d430
 # Override user-show
b2d430
 #
b2d430
@@ -581,7 +640,7 @@ def test_find_user_override(ldap_conn, env_find_user_override):
b2d430
 # Common group asserts
b2d430
 #
b2d430
 
b2d430
-def assert_group_overriden():
b2d430
+def assert_group_overriden(override_name=True):
b2d430
 
b2d430
     # Assert entries are overridden
b2d430
     empty_group = dict(gid=3002, mem=ent.contains_only())
b2d430
@@ -589,13 +648,17 @@ def assert_group_overriden():
b2d430
 
b2d430
     ent.assert_group_by_name("group", group)
b2d430
     ent.assert_group_by_name("group@LDAP", group)
b2d430
-    ent.assert_group_by_name("ov_group", group)
b2d430
-    ent.assert_group_by_name("ov_group@LDAP", group)
b2d430
+
b2d430
+    if override_name:
b2d430
+        ent.assert_group_by_name("ov_group", group)
b2d430
+        ent.assert_group_by_name("ov_group@LDAP", group)
b2d430
 
b2d430
     ent.assert_group_by_name("empty_group", empty_group)
b2d430
     ent.assert_group_by_name("empty_group@LDAP", empty_group)
b2d430
-    ent.assert_group_by_name("ov_empty_group", empty_group)
b2d430
-    ent.assert_group_by_name("ov_empty_group@LDAP", empty_group)
b2d430
+
b2d430
+    if override_name:
b2d430
+        ent.assert_group_by_name("ov_empty_group", empty_group)
b2d430
+        ent.assert_group_by_name("ov_empty_group@LDAP", empty_group)
b2d430
 
b2d430
 
b2d430
 def assert_group_default():
b2d430
@@ -841,6 +904,45 @@ def test_imp_exp_group_override(ldap_conn, env_imp_exp_group_override):
b2d430
     assert_group_overriden()
b2d430
 
b2d430
 
b2d430
+# Regression test for bug 3179
b2d430
+
b2d430
+
b2d430
+def test_imp_exp_group_override_noname(ldap_conn, env_group_basic):
b2d430
+
b2d430
+    # Override - do not use -n here)
b2d430
+    subprocess.check_call(["sss_override", "group-add", "group",
b2d430
+                           "-g", "3001"])
b2d430
+
b2d430
+    subprocess.check_call(["sss_override", "group-add", "empty_group@LDAP",
b2d430
+                           "--gid", "3002"])
b2d430
+
b2d430
+    # Restart SSSD so the override might take effect
b2d430
+    restart_sssd()
b2d430
+
b2d430
+    # Assert entries are overridden
b2d430
+    assert_group_overriden(override_name=False)
b2d430
+
b2d430
+    # Export overrides
b2d430
+    subprocess.check_call(["sss_override", "group-export",
b2d430
+                           OVERRIDE_FILENAME])
b2d430
+
b2d430
+    # Drop all overrides
b2d430
+    subprocess.check_call(["sss_override", "group-del", "group"])
b2d430
+    subprocess.check_call(["sss_override", "group-del", "empty_group@LDAP"])
b2d430
+
b2d430
+    # Avoid hitting memory cache
b2d430
+    time.sleep(2)
b2d430
+
b2d430
+    assert_group_default()
b2d430
+
b2d430
+    # Import overrides
b2d430
+    subprocess.check_call(["sss_override", "group-import",
b2d430
+                           OVERRIDE_FILENAME])
b2d430
+    restart_sssd()
b2d430
+
b2d430
+    assert_group_overriden(override_name=False)
b2d430
+
b2d430
+
b2d430
 # Regression test for bug #2802
b2d430
 # sss_override segfaults when accidentally adding --help flag to some commands
b2d430
 
b2d430
-- 
b2d430
2.7.4
b2d430