From: Samuel Cabrero Date: Fri, 31 Aug 2018 17:15:05 +0000 (+0200) Subject: tests/ntlm_auth: Port ntlm_auth tests to python: ntlm_auth ntlm-server-1 with plainte... X-Git-Tag: tdb-1.3.17~233 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d4258f43dea153cc60a6b9dbd36f0ca0b5abf0e;p=thirdparty%2Fsamba.git tests/ntlm_auth: Port ntlm_auth tests to python: ntlm_auth ntlm-server-1 with plaintext password against winbind 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 ff8310d08d4..357afdb5c59 100644 --- a/python/samba/tests/ntlm_auth.py +++ b/python/samba/tests/ntlm_auth.py @@ -248,3 +248,28 @@ class NTLMAuthHelpersTests(NTLMAuthTestCase): lines = out.split(b"\n") self.assertEqual(len(lines), 5) self.assertEquals(lines[0], b"Authenticated: No") + + def test_ntlm_server_1_with_plaintext_winbind(self): + """ ntlm_auth ntlm-server-1 with plaintext password against winbind """ + + ntlm_cmds = [ + "Password: %s" % self.password, + "NT-Domain: %s" % self.domain, + "Username: %s" % self.username, + "Request-User-Session-Key: Yes", + ".\n" ] + + proc = Popen([self.ntlm_auth_path, + "--require-membership-of", self.group_sid, + "--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), 3) + self.assertEquals(lines[0], b"Authenticated: Yes") + self.assertEquals(lines[1], b".") + self.assertEquals(lines[2], b"") diff --git a/source3/script/tests/test_ntlm_auth_s3.sh b/source3/script/tests/test_ntlm_auth_s3.sh index b41368c4e3b..4048b804be2 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_winbind_output() -{ - tmpfile=$PREFIX/ntlm_commands - - # This isn't the correct password - cat > $tmpfile </dev/null 2>&1 - - if [ $? = 0 ] ; then - # authenticated .. success - true - else - echo "Failed to authenticate the user or match with SID $SID" - false - fi -} - test_ntlm_server_1_check_winbind_output_wrong_sid() { tmpfile=$PREFIX/ntlm_commands @@ -134,7 +98,6 @@ EOF } # This should work even with NTLMv2 -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` testit "ntlm_auth ntlm-server-1 with incorrect fixed password against winbind" test_ntlm_server_1_check_winbind_output_fail || failed=`expr $failed + 1`