prompts (e.g. Password + Token) - Resolves: rhbz#1313041 - ssh with sssd proxy fails with "Connection closed by remote host" if locale not available
166 lines
5.0 KiB
Diff
166 lines
5.0 KiB
Diff
From 30bb28a7d8bea694fda7b745607eb1aacfa0af90 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzidek@redhat.com>
|
|
Date: Tue, 20 Oct 2015 15:03:22 +0200
|
|
Subject: [PATCH 097/108] tests: Regression test with wrong LC_ALL
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Ticket:
|
|
https://fedorahosted.org/sssd/ticket/2785
|
|
|
|
Test local domain tool with wrong LC_ALL
|
|
environment variable value.
|
|
|
|
NOTE: The memory cache files are not deleted
|
|
properly in the test teardown to work around the
|
|
problem described in ticket
|
|
https://fedorahosted.org/sssd/ticket/2726
|
|
|
|
Once the ticket above is solved, the teardown
|
|
will be updated to remove the memory cache
|
|
files.
|
|
|
|
Reviewed-by: Michal Židek <mzidek@redhat.com>
|
|
(cherry picked from commit 586f512ab8b6e5a03349598846141f43c1d505b8)
|
|
(cherry picked from commit 03f6667741bf111f0e50c8f2c4323e45ce53f707)
|
|
---
|
|
src/tests/intg/Makefile.am | 1 +
|
|
src/tests/intg/test_local_domain.py | 112 ++++++++++++++++++++++++++++++++++++
|
|
2 files changed, 113 insertions(+)
|
|
create mode 100644 src/tests/intg/test_local_domain.py
|
|
|
|
diff --git a/src/tests/intg/Makefile.am b/src/tests/intg/Makefile.am
|
|
index f21880b61bfb07ac1dca65deda70fc50b4943586..7394997319142d581237ab8a37270bfd7bc974ca 100644
|
|
--- a/src/tests/intg/Makefile.am
|
|
+++ b/src/tests/intg/Makefile.am
|
|
@@ -8,6 +8,7 @@ dist_noinst_DATA = \
|
|
ldap_ent.py \
|
|
ldap_local_override_test.py \
|
|
ldap_test.py \
|
|
+ test_local_domain.py \
|
|
util.py \
|
|
test_memory_cache.py \
|
|
$(NULL)
|
|
diff --git a/src/tests/intg/test_local_domain.py b/src/tests/intg/test_local_domain.py
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..c62de16ce04b640503250c926d6eb3d199ed0728
|
|
--- /dev/null
|
|
+++ b/src/tests/intg/test_local_domain.py
|
|
@@ -0,0 +1,112 @@
|
|
+#
|
|
+# SSSD LOCAL domain tests
|
|
+#
|
|
+# Copyright (c) 2015 Red Hat, Inc.
|
|
+# Author: Michal Zidek <mzidek@redhat.com>
|
|
+#
|
|
+# This is free software; you can redistribute it and/or modify it
|
|
+# under the terms of the GNU General Public License as published by
|
|
+# the Free Software Foundation; version 2 only
|
|
+#
|
|
+# This program is distributed in the hope that it will be useful, but
|
|
+# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
+# General Public License for more details.
|
|
+#
|
|
+# You should have received a copy of the GNU General Public License
|
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
+#
|
|
+import os
|
|
+import stat
|
|
+import pwd
|
|
+import time
|
|
+import config
|
|
+import signal
|
|
+import subprocess
|
|
+import pytest
|
|
+from util import unindent
|
|
+
|
|
+
|
|
+def stop_sssd():
|
|
+ pid_file = open(config.PIDFILE_PATH, "r")
|
|
+ pid = int(pid_file.read())
|
|
+ os.kill(pid, signal.SIGTERM)
|
|
+ while True:
|
|
+ try:
|
|
+ os.kill(pid, signal.SIGCONT)
|
|
+ except:
|
|
+ break
|
|
+ time.sleep(1)
|
|
+
|
|
+
|
|
+def create_conf_fixture(request, contents):
|
|
+ """Generate sssd.conf and add teardown for removing it"""
|
|
+ conf = open(config.CONF_PATH, "w")
|
|
+ conf.write(contents)
|
|
+ conf.close()
|
|
+ os.chmod(config.CONF_PATH, stat.S_IRUSR | stat.S_IWUSR)
|
|
+ request.addfinalizer(lambda: os.unlink(config.CONF_PATH))
|
|
+
|
|
+
|
|
+def create_sssd_fixture(request):
|
|
+ """Start sssd and add teardown for stopping it and removing state"""
|
|
+ if subprocess.call(["sssd", "-D", "-f"]) != 0:
|
|
+ raise Exception("sssd start failed")
|
|
+
|
|
+ def teardown():
|
|
+ try:
|
|
+ stop_sssd()
|
|
+ except:
|
|
+ pass
|
|
+ subprocess.call(["sss_cache", "-E"])
|
|
+ for path in os.listdir(config.DB_PATH):
|
|
+ os.unlink(config.DB_PATH + "/" + path)
|
|
+ # FIXME: Uncomment this when ticket #2726 is solved
|
|
+ # https://fedorahosted.org/sssd/ticket/2726
|
|
+ # for path in os.listdir(config.MCACHE_PATH):
|
|
+ # os.unlink(config.MCACHE_PATH + "/" + path)
|
|
+ request.addfinalizer(teardown)
|
|
+
|
|
+
|
|
+@pytest.fixture
|
|
+def local_domain_only(request):
|
|
+ conf = unindent("""\
|
|
+ [sssd]
|
|
+ domains = LOCAL
|
|
+ services = nss
|
|
+
|
|
+ [nss]
|
|
+ memcache_timeout = 0
|
|
+
|
|
+ [domain/LOCAL]
|
|
+ id_provider = local
|
|
+ min_id = 10000
|
|
+ max_id = 20000
|
|
+ """).format(**locals())
|
|
+ create_conf_fixture(request, conf)
|
|
+ create_sssd_fixture(request)
|
|
+ return None
|
|
+
|
|
+
|
|
+def assert_nonexistent_user(name):
|
|
+ with pytest.raises(KeyError):
|
|
+ pwd.getpwnam(name)
|
|
+
|
|
+
|
|
+def test_wrong_LC_ALL(local_domain_only):
|
|
+ """
|
|
+ Regression test for ticket
|
|
+ https://fedorahosted.org/sssd/ticket/2785
|
|
+
|
|
+ """
|
|
+ subprocess.check_call(["sss_useradd", "foo", "-M"])
|
|
+ pwd.getpwnam("foo")
|
|
+
|
|
+ # Change the LC_ALL variable to nonexistent locale
|
|
+ oldvalue = os.environ.get("LC_ALL", "")
|
|
+ os.environ["LC_ALL"] = "nonexistent_locale"
|
|
+
|
|
+ # sss_userdel must remove the user despite wrong LC_ALL
|
|
+ subprocess.check_call(["sss_userdel", "foo", "-R"])
|
|
+ assert_nonexistent_user("foo")
|
|
+ os.environ["LC_LOCAL"] = oldvalue
|
|
--
|
|
2.7.3
|
|
|