mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
python: Add a simple pam_winbind test
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Fri Apr 7 14:19:23 CEST 2017 on sn-devel-144
This commit is contained in:
parent
a46566ea5e
commit
0641653c30
39
python/samba/tests/pam_winbind.py
Normal file
39
python/samba/tests/pam_winbind.py
Normal file
@ -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)
|
35
python/samba/tests/test_pam_winbind.sh
Executable file
35
python/samba/tests/test_pam_winbind.sh
Executable file
@ -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
|
@ -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")])
|
||||
|
Loading…
x
Reference in New Issue
Block a user