From: Samuel Cabrero Date: Thu, 6 Sep 2018 10:58:42 +0000 (+0200) Subject: tests/ntlm_auth: Port ntlm_auth_krb5 tests to python X-Git-Tag: tdb-1.3.17~230 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=129ab34baf0b1554dea3d93506b95439bffcb30f;p=samba.git tests/ntlm_auth: Port ntlm_auth_krb5 tests to python Port ntlm_auth_krb5 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_krb5.py b/python/samba/tests/ntlm_auth_krb5.py new file mode 100644 index 00000000000..d1957d68a0b --- /dev/null +++ b/python/samba/tests/ntlm_auth_krb5.py @@ -0,0 +1,83 @@ +# 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 +import samba +from subprocess import Popen, PIPE +from samba.tests.ntlm_auth_base import NTLMAuthTestCase + +class NTLMAuthKerberosTests(NTLMAuthTestCase): + + def setUp(self): + super(NTLMAuthKerberosTests, self).setUp() + self.old_ccache = os.path.join(os.environ["SELFTEST_PREFIX"], + "ktest", "krb5_ccache-2") + self.ccache = os.path.join(os.environ["SELFTEST_PREFIX"], + "ktest", "krb5_ccache-3") + + def test_krb5_gss_spnego_client_gss_spnego_server(self): + """ ntlm_auth with krb5 gss-spnego-client and gss-spnego server """ + + os.environ["KRB5CCNAME"] = self.old_ccache + ret = self.run_helper(client_username="foo", + client_password="secret", + client_domain="FOO", + target_hostname=os.environ["SERVER"], + target_service="host", + client_helper="gss-spnego-client", + server_helper="gss-spnego", + server_use_winbind=True) + self.assertTrue(ret) + + os.environ["KRB5CCNAME"] = self.ccache + ret = self.run_helper(client_username="foo", + client_password="secret", + client_domain="FOO", + target_hostname=os.environ["SERVER"], + target_service="host", + client_helper="gss-spnego-client", + server_helper="gss-spnego", + server_use_winbind=True) + self.assertTrue(ret) + + def test_krb5_invalid_keytab(self): + """ ntlm_auth with krb5 and an invalid keytab """ + + dedicated_keytab = "FILE:%s.%s" % ( + self.old_ccache, "keytab-does-not-exists") + proc = Popen([self.ntlm_auth_path, + "--helper-protocol", "gss-spnego", + "--option", "security=ads", + "--option", "kerberosmethod=dedicatedkeytab", + "--option", "dedicatedkeytabfile=%s" % dedicated_keytab], + stdout=PIPE, stdin=PIPE, stderr=PIPE) + buf = "YR\n" + (out, err) = proc.communicate(input=buf.encode('utf-8')) + self.assertEqual(proc.returncode, 0) + + dedicated_keytab = "FILE:%s.%s" % ( + self.ccache, "keytab-does-not-exists") + proc = Popen([self.ntlm_auth_path, + "--helper-protocol", "gss-spnego", + "--option", "security=ads", + "--option", "kerberosmethod=dedicatedkeytab", + "--option", "dedicatedkeytabfile=%s" % dedicated_keytab], + stdout=PIPE, stdin=PIPE, stderr=PIPE) + buf = "YR\n" + (out, err) = proc.communicate(input=buf.encode('utf-8')) + self.assertEqual(proc.returncode, 0) diff --git a/source3/script/tests/test_ntlm_auth_krb5.sh b/source3/script/tests/test_ntlm_auth_krb5.sh deleted file mode 100755 index 773cb575811..00000000000 --- a/source3/script/tests/test_ntlm_auth_krb5.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -if [ $# -lt 2 ]; then -cat <