From 247592f7162d0e22e8edb889adce1eac5a4cf5f1 Mon Sep 17 00:00:00 2001 From: Samuel Cabrero Date: Fri, 31 Aug 2018 12:47:11 +0200 Subject: [PATCH] tests/ntlm_auth: Port ntlm_auth tests to python: ntlm_auth and ntlm_auth with specified domain Port ntlm_auth bash script tests to python Signed-off-by: Samuel Cabrero Reviewed-by: Noel Power Reviewed-by: Andrew Bartlett --- python/samba/tests/ntlm_auth.py | 53 +++++++++++++++++++++++ source3/script/tests/test_ntlm_auth_s3.sh | 2 - source4/selftest/tests.py | 2 + 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 python/samba/tests/ntlm_auth.py diff --git a/python/samba/tests/ntlm_auth.py b/python/samba/tests/ntlm_auth.py new file mode 100644 index 00000000000..97e4b979c17 --- /dev/null +++ b/python/samba/tests/ntlm_auth.py @@ -0,0 +1,53 @@ +# Unix SMB/CIFS implementation. +# +# Copyright (C) Samuel Cabrero 2018 +# +# 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 . +# + +import os +from subprocess import Popen, PIPE +from samba.tests.ntlm_auth_base import NTLMAuthTestCase +from samba.compat import get_string + +class NTLMAuthHelpersTests(NTLMAuthTestCase): + + def test_specified_domain(self): + """ ntlm_auth with specified domain """ + + username = "foo" + password = "secret" + domain = "FOO" + + ret = self.run_helper(client_username=username, + client_password=password, + client_domain=domain, + server_username=username, + server_password=password, + server_domain=domain, + server_use_winbind=False) + self.assertTrue(ret) + + username = "foo" + password = "secret" + domain = "fOo" + + ret = self.run_helper(client_username=username, + client_password=password, + client_domain=domain, + server_username=username, + server_password=password, + server_domain=domain, + server_use_winbind=False) + self.assertTrue(ret) diff --git a/source3/script/tests/test_ntlm_auth_s3.sh b/source3/script/tests/test_ntlm_auth_s3.sh index 2b5e4353557..3d3d9f98048 100755 --- a/source3/script/tests/test_ntlm_auth_s3.sh +++ b/source3/script/tests/test_ntlm_auth_s3.sh @@ -268,9 +268,7 @@ EOF fi } -testit "ntlm_auth" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS || failed=`expr $failed + 1` # This should work even with NTLMv2 -testit "ntlm_auth with specified domain" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS --client-domain=fOo --server-domain=fOo || failed=`expr $failed + 1` testit "ntlm_auth against winbindd" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH --client-username=$USERNAME --client-domain=$DOMAIN --client-password=$PASSWORD --server-use-winbindd $ADDARGS || failed=`expr $failed + 1` testit "ntlm_auth with NTLMSSP client and gss-spnego server" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS --client-domain=fOo --server-domain=fOo --client-helper=ntlmssp-client-1 --server-helper=gss-spnego || failed=`expr $failed + 1` testit "ntlm_auth with NTLMSSP gss-spnego-client and gss-spnego server" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS --client-domain=fOo --server-domain=fOo --client-helper=gss-spnego-client --server-helper=gss-spnego || failed=`expr $failed + 1` diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index cc7427486c9..73356b5d8eb 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -592,6 +592,8 @@ for env in ["nt4_dc", "nt4_member", "ad_dc", "ad_member", "s4member", "chgdcpass plantestsuite("samba.ntlm_auth.(%s:local)" % env, "%s:local" % env, [os.path.join(samba3srcdir, "script/tests/test_ntlm_auth_s3.sh"), valgrindify(python), samba3srcdir, ntlm_auth3, '$DOMAIN', '$DC_USERNAME', '$DC_PASSWORD', configuration]) + planpythontestsuite(env + ":local", "samba.tests.ntlm_auth", py3_compatible=True) + for env in ["s4member_dflt_domain", "s4member"]: for cmd in ["id", "getent"]: users = ["$DC_USERNAME", "$DC_USERNAME@$REALM"]