From: Samuel Cabrero Date: Fri, 31 Aug 2018 16:49:13 +0000 (+0200) Subject: tests/ntlm_auth: Port ntlm_auth tests to python: ntlm_auth ntlm-server-1 with fixed... X-Git-Tag: tdb-1.3.17~235 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28ea2f7220dfc4f90bc099f306c8a0e5324fee5a;p=thirdparty%2Fsamba.git tests/ntlm_auth: Port ntlm_auth tests to python: ntlm_auth ntlm-server-1 with fixed password Port ntlm_auth bash script tests to python Signed-off-by: Samuel Cabrero Reviewed-by: Noel Power Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/ntlm_auth.py b/python/samba/tests/ntlm_auth.py index 8235b30e697..1b407021dd9 100644 --- a/python/samba/tests/ntlm_auth.py +++ b/python/samba/tests/ntlm_auth.py @@ -205,3 +205,31 @@ class NTLMAuthHelpersTests(NTLMAuthTestCase): (out, err) = proc.communicate(input=creds.encode('utf-8')) self.assertEqual(proc.returncode, 0) self.assertTrue(out.startswith(b"ERR\n")) + + def test_ntlm_server_1_with_fixed_password(self): + """ ntlm_auth ntlm-server-1 with fixed password """ + + ntlm_cmds = [ + "LANMAN-Challenge: 0123456789abcdef", + "NT-Response: 25a98c1c31e81847466b29b2df4680f39958fb8c213a9cc6", + "NT-Domain: TEST", + "Username: testuser", + "Request-User-Session-Key: Yes", + ".\n" ] + + proc = Popen([self.ntlm_auth_path, + "--password", "SecREt01", + "--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), 4) + self.assertEquals(lines[0], b"Authenticated: Yes") + self.assertEquals( + lines[1], b"User-Session-Key: 3F373EA8E4AF954F14FAA506F8EEBDC4") + self.assertEquals(lines[2], b".") + self.assertEquals(lines[3], b"") diff --git a/source3/script/tests/test_ntlm_auth_s3.sh b/source3/script/tests/test_ntlm_auth_s3.sh index 56e327c8ec2..82aebfef39c 100755 --- a/source3/script/tests/test_ntlm_auth_s3.sh +++ b/source3/script/tests/test_ntlm_auth_s3.sh @@ -24,42 +24,6 @@ BADSID=`eval $BINDIR/wbinfo -n $USERNAME | cut -d ' ' -f1 | sed 's/..$//'` failed=0 -test_ntlm_server_1_check_output() -{ - tmpfile=$PREFIX/ntlm_commands - - cat > $tmpfile </dev/null 2>&1 - - if [ $? = 0 ] ; then - # authenticated .. succeed - true - else - echo failed to get successful authentication - false - fi -} - test_ntlm_server_1_check_output_fail() { tmpfile=$PREFIX/ntlm_commands @@ -207,7 +171,6 @@ EOF } # This should work even with NTLMv2 -testit "ntlm_auth ntlm-server-1 with fixed password" test_ntlm_server_1_check_output || failed=`expr $failed + 1` testit "ntlm_auth ntlm-server-1 with incorrect fixed password" test_ntlm_server_1_check_output_fail || failed=`expr $failed + 1` testit "ntlm_auth ntlm-server-1 with plaintext password against winbind" test_ntlm_server_1_check_winbind_output || failed=`expr $failed + 1` testit "ntlm_auth ntlm-server-1 with plaintext password against winbind but wrong sid" test_ntlm_server_1_check_winbind_output_wrong_sid || failed=`expr $failed + 1`