From 91c4f2603607a917c1f1006b2f9f83232ac489c4 Mon Sep 17 00:00:00 2001 From: Samuel Cabrero Date: Fri, 31 Aug 2018 19:28:06 +0200 Subject: [PATCH] tests/ntlm_auth: Port ntlm_auth tests to python: ntlm_auth ntlm-server-1 with incorrect fixed password against winbind Port ntlm_auth bash script tests to python and remove bash test script Signed-off-by: Samuel Cabrero Reviewed-by: Noel Power Reviewed-by: Andrew Bartlett --- python/samba/tests/ntlm_auth.py | 24 ++++++++ source3/script/tests/test_ntlm_auth_s3.sh | 67 ----------------------- source4/selftest/tests.py | 2 - 3 files changed, 24 insertions(+), 69 deletions(-) delete mode 100755 source3/script/tests/test_ntlm_auth_s3.sh diff --git a/python/samba/tests/ntlm_auth.py b/python/samba/tests/ntlm_auth.py index 4edd9460119..5073184e72e 100644 --- a/python/samba/tests/ntlm_auth.py +++ b/python/samba/tests/ntlm_auth.py @@ -290,3 +290,27 @@ class NTLMAuthHelpersTests(NTLMAuthTestCase): self.assertEquals(lines[0], b"Authenticated: No") self.assertEquals(lines[1], b".") self.assertEquals(lines[2], b"") + + def test_ntlm_server_1_with_incorrect_password_winbind(self): + """ ntlm_auth ntlm-server-1 with incorrect fixed password against + winbind """ + + ntlm_cmds = [ + "LANMAN-Challenge: 0123456789abcdef", + "NT-Response: 25a98c1c31e81847466b29b2df4680f39958fb8c213a9cc6", + "NT-Domain: %s" % self.domain, + "Username: %s" % self.username, + "Request-User-Session-Key: Yes", + ".\n" ] + + proc = Popen([self.ntlm_auth_path, + "--helper-protocol", "ntlm-server-1"], + stdout=PIPE, stdin=PIPE, stderr=PIPE) + buf = "\n".join(ntlm_cmds) + (out, err) = proc.communicate(input=buf.encode('utf-8')) + self.assertEqual(proc.returncode, 0) + + lines = out.split(b"\n") + + self.assertEqual(len(lines), 5) + self.assertEquals(lines[0], b"Authenticated: No") diff --git a/source3/script/tests/test_ntlm_auth_s3.sh b/source3/script/tests/test_ntlm_auth_s3.sh deleted file mode 100755 index 041cb7d9cb8..00000000000 --- a/source3/script/tests/test_ntlm_auth_s3.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -if [ $# -lt 2 ]; then -cat < $tmpfile </dev/null 2>&1 - - if [ $? = 0 ] ; then - # failed to authenticate .. success - true - else - echo "incorrectly gave a successful authentication" - false - fi -} - -# This should work even with NTLMv2 -testit "ntlm_auth ntlm-server-1 with incorrect fixed password against winbind" test_ntlm_server_1_check_winbind_output_fail || failed=`expr $failed + 1` - -testok $0 $failed diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index 73356b5d8eb..64dd580b82b 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -590,8 +590,6 @@ for env in ["nt4_dc", "nt4_member", "ad_dc", "ad_member", "s4member", "chgdcpass "samba.ntlm_auth.diagnostics(%s:local)" % env, "%s:local" % env, [os.path.join(samba3srcdir, "script/tests/test_ntlm_auth_diagnostics.sh"), ntlm_auth3, '$DOMAIN', '$DC_USERNAME', '$DC_PASSWORD', configuration]) - 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"]: