summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/samba/tests/pam_winbind.py39
-rwxr-xr-xpython/samba/tests/test_pam_winbind.sh35
-rw-r--r--selftest/tests.py4
3 files changed, 78 insertions, 0 deletions
diff --git a/python/samba/tests/pam_winbind.py b/python/samba/tests/pam_winbind.py
new file mode 100644
index 00000000000..21ea2fbed7e
--- /dev/null
+++ b/python/samba/tests/pam_winbind.py
@@ -0,0 +1,39 @@
+# Unix SMB/CIFS implementation.
+#
+# Copyright (C) 2017 Andreas Schneider <asn@samba.org>
+#
+# This program 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; either version 3 of the License, or
+# (at your option) any later version.
+#
+# 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 samba.tests
+import pypamtest
+
+class SimplePamTests(samba.tests.TestCase):
+ def test_authenticate(self):
+ alice_password = "Secret007"
+ expected_rc = 0 # PAM_SUCCESS
+
+ tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc)
+ res = pypamtest.run_pamtest("SAMBADOMAIN/alice", "samba", [tc], [alice_password])
+
+ self.assertTrue(res != None)
+
+ def test_authenticate_error(self):
+ alice_password = "WrongPassword"
+ expected_rc = 7 # PAM_AUTH_ERR
+
+ tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc)
+ res = pypamtest.run_pamtest("SAMBADOMAIN/alice", "samba", [tc], [alice_password])
+
+ self.assertTrue(res != None)
diff --git a/python/samba/tests/test_pam_winbind.sh b/python/samba/tests/test_pam_winbind.sh
new file mode 100755
index 00000000000..bf59296b732
--- /dev/null
+++ b/python/samba/tests/test_pam_winbind.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+PYTHON="$1"
+PAM_WRAPPER_SO_PATH="$2"
+shift 2
+
+PAM_WRAPPER_PATH="$BINDIR/default/lib/pam_wrapper"
+
+pam_winbind="$BINDIR/shared/pam_winbind.so"
+service_dir="$SELFTEST_TMPDIR/pam_services"
+service_file="$service_dir/samba"
+
+mkdir $service_dir
+echo "auth required $pam_winbind debug debug_state" > $service_file
+echo "account required $pam_winbind debug debug_state" >> $service_file
+echo "password required $pam_winbind debug debug_state" >> $service_file
+echo "session required $pam_winbind debug debug_state" >> $service_file
+
+PAM_WRAPPER="1"
+export PAM_WRAPPER
+PAM_WRAPPER_SERVICE_DIR="$service_dir"
+export PAM_WRAPPER_SERVICE_DIR
+LD_PRELOAD="$LD_PRELOAD:$PAM_WRAPPER_SO_PATH"
+export LD_PRELOAD
+
+PAM_WRAPPER_DEBUGLEVEL=${PAM_WRAPPER_DEBUGLEVEL:="2"}
+export PAM_WRAPPER_DEBUGLEVEL
+
+PYTHONPATH="$PYTHONPATH:$PAM_WRAPPER_PATH:$(dirname $0)" $PYTHON -m samba.subunit.run samba.tests.pam_winbind
+exit_code=$?
+
+rm -rf $service_dir
+
+exit_code=0
+exit $exit_code
diff --git a/selftest/tests.py b/selftest/tests.py
index b32b6de9b5c..d962a66f4e6 100644
--- a/selftest/tests.py
+++ b/selftest/tests.py
@@ -39,6 +39,7 @@ finally:
have_man_pages_support = ("XSLTPROC_MANPAGES" in config_hash)
with_cmocka = ("HAVE_CMOCKA" in config_hash)
+pam_wrapper_so_path=config_hash["LIBPAM_WRAPPER_SO_PATH"]
planpythontestsuite("none", "samba.tests.source")
if have_man_pages_support:
@@ -136,6 +137,9 @@ plantestsuite(
configuration])
planpythontestsuite("none", "samba.tests.glue", py3_compatible=True)
+plantestsuite("samba.tests.pam_winbind", "ad_member",
+ [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind.sh"), valgrindify(python), pam_wrapper_so_path])
+
if with_cmocka:
plantestsuite("samba.unittests.krb5samba", "none",
[os.path.join(bindir(), "default/testsuite/unittests/test_krb5samba")])