From: Volker Lendecke Date: Fri, 26 Aug 2022 12:00:28 +0000 (+0200) Subject: tests: Add smb3 posix negotiate tests X-Git-Tag: talloc-2.4.0~1224 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=887facd37384ba932a93393e135cf82af66cb058;p=thirdparty%2Fsamba.git tests: Add smb3 posix negotiate tests Make sure we do and don't announce posix depending on "smb3 unix extensions" parameter Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/python/samba/tests/smb3unix.py b/python/samba/tests/smb3unix.py new file mode 100644 index 00000000000..d45b77a7c26 --- /dev/null +++ b/python/samba/tests/smb3unix.py @@ -0,0 +1,70 @@ +# Unix SMB/CIFS implementation. +# Copyright Volker Lendecke 2022 +# +# 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 . +# + +from samba.samba3 import libsmb_samba_internal as libsmb +from samba.samba3 import param as s3param +from samba import (credentials,NTSTATUSError) +import samba.tests +import os + +class Smb3UnixTests(samba.tests.TestCase): + + def setUp(self): + self.lp = s3param.get_context() + self.lp.load(os.getenv("SMB_CONF_PATH")) + + self.creds = credentials.Credentials() + self.creds.guess(self.lp) + self.creds.set_username(os.getenv("USERNAME")) + self.creds.set_password(os.getenv("PASSWORD")) + + # Build the global inject file path + server_conf = os.getenv("SERVERCONFFILE") + server_conf_dir = os.path.dirname(server_conf) + self.global_inject = os.path.join(server_conf_dir, "global_inject.conf") + + def enable_smb3unix(self): + with open(self.global_inject, 'w') as f: + f.write("smb3 unix extensions = yes\n") + + def disable_smb3unix(self): + with open(self.global_inject, 'w') as f: + f.truncate() + + def test_negotiate_context_posix(self): + try: + self.enable_smb3unix() + + c = libsmb.Conn( + os.getenv("SERVER_IP"), + "tmp", + self.lp, + self.creds, + posix=True) + self.assertTrue(c.have_posix()) + + finally: + self.disable_smb3unix() + + def test_negotiate_context_noposix(self): + c = libsmb.Conn( + os.getenv("SERVER_IP"), + "tmp", + self.lp, + self.creds, + posix=True) + self.assertFalse(c.have_posix()) diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index a11b6d1d10b..25f8fa56c58 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -26,6 +26,7 @@ sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(__file__), "../ import selftesthelpers from selftesthelpers import bindir, srcdir, scriptdir, binpath from selftesthelpers import plantestsuite, samba3srcdir +from selftesthelpers import planpythontestsuite from selftesthelpers import smbtorture3, configuration, smbclient3, smbtorture4 from selftesthelpers import net, wbinfo, dbwrap_tool, rpcclient, python from selftesthelpers import smbget, smbcacls, smbcquotas, ntlm_auth3 @@ -1573,3 +1574,5 @@ for t in CLUSTERED_LOCAL_TESTS: '""', smbtorture3, "-N 1000 -o 2000"]) + +planpythontestsuite("fileserver", "samba.tests.smb3unix")