diff options
author | Volker Lendecke <vl@samba.org> | 2022-10-19 11:34:40 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2022-10-27 18:18:36 +0000 |
commit | ab2c3859d62eb46aab1465e928f46aeb4c84b1b7 (patch) | |
tree | fc67a4d896a4e98b418d17ad8ac5edb6cab0ec5c /python | |
parent | 6be2d465704b5c41863d490310735dccc3465b1c (diff) | |
download | samba-ab2c3859d62eb46aab1465e928f46aeb4c84b1b7.tar.gz |
tests: Use samba.tests.libsmb.LibsmbTests in libsmb-basic.py
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/samba/tests/libsmb-basic.py | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/python/samba/tests/libsmb-basic.py b/python/samba/tests/libsmb-basic.py index 2fe4386340f..36566436e87 100644 --- a/python/samba/tests/libsmb-basic.py +++ b/python/samba/tests/libsmb-basic.py @@ -19,18 +19,16 @@ from samba.samba3 import libsmb_samba_internal as libsmb from samba.dcerpc import security -from samba.samba3 import param as s3param -from samba import (credentials,NTSTATUSError) +from samba import NTSTATUSError from samba.ntstatus import NT_STATUS_DELETE_PENDING from samba.credentials import SMB_ENCRYPTION_REQUIRED -import samba.tests +import samba.tests.libsmb import threading import sys -import os import random -class LibsmbTestCase(samba.tests.TestCase): +class LibsmbTestCase(samba.tests.libsmb.LibsmbTests): class OpenClose(threading.Thread): @@ -52,23 +50,15 @@ class LibsmbTestCase(samba.tests.TestCase): except Exception: self.exc = sys.exc_info() - def prep_creds(self): - lp = s3param.get_context() - lp.load(os.getenv("SMB_CONF_PATH")) - - creds = credentials.Credentials() - creds.guess(lp) - creds.set_username(os.getenv("USERNAME")) - creds.set_password(os.getenv("PASSWORD")) - - return (lp,creds) - def test_OpenClose(self): - (lp,creds) = self.prep_creds() - c = libsmb.Conn(os.getenv("SERVER_IP"), "tmp", - lp, creds, multi_threaded=True, - force_smb1=True) + c = libsmb.Conn( + self.server_ip, + "tmp", + self.lp, + self.creds, + multi_threaded=True, + force_smb1=True) mythreads = [] @@ -87,11 +77,9 @@ class LibsmbTestCase(samba.tests.TestCase): def test_SMB3EncryptionRequired(self): test_dir = 'testing_%d' % random.randint(0, 0xFFFF) - (lp,creds) = self.prep_creds() - creds.set_smb_encryption(SMB_ENCRYPTION_REQUIRED) + self.creds.set_smb_encryption(SMB_ENCRYPTION_REQUIRED) - c = libsmb.Conn(os.getenv("SERVER_IP"), "tmp", - lp, creds) + c = libsmb.Conn(self.server_ip, "tmp", self.lp, self.creds) c.mkdir(test_dir) c.rmdir(test_dir) @@ -99,22 +87,24 @@ class LibsmbTestCase(samba.tests.TestCase): def test_SMB1EncryptionRequired(self): test_dir = 'testing_%d' % random.randint(0, 0xFFFF) - (lp,creds) = self.prep_creds() - creds.set_smb_encryption(SMB_ENCRYPTION_REQUIRED) + self.creds.set_smb_encryption(SMB_ENCRYPTION_REQUIRED) - c = libsmb.Conn(os.getenv("SERVER_IP"), "tmp", - lp, creds, force_smb1=True) + c = libsmb.Conn( + self.server_ip, + "tmp", + self.lp, + self.creds, + force_smb1=True) c.mkdir(test_dir) c.rmdir(test_dir) def test_RenameDstDelOnClose(self): - (lp,creds) = self.prep_creds() dstdir = "\\dst-subdir" - c1 = libsmb.Conn(os.getenv("SERVER_IP"), "tmp", lp, creds) - c2 = libsmb.Conn(os.getenv("SERVER_IP"), "tmp", lp, creds) + c1 = libsmb.Conn(self.server_ip, "tmp", self.lp, self.creds) + c2 = libsmb.Conn(self.server_ip, "tmp", self.lp, self.creds) try: c1.deltree(dstdir) @@ -141,8 +131,7 @@ class LibsmbTestCase(samba.tests.TestCase): pass def test_libsmb_CreateContexts(self): - (lp,creds) = self.prep_creds() - c = libsmb.Conn(os.getenv("SERVER_IP"), "tmp", lp, creds) + c = libsmb.Conn(self.server_ip, "tmp", self.lp, self.creds) cc_in = [(libsmb.SMB2_CREATE_TAG_MXAC, b'')] fnum,cr,cc = c.create_ex("",CreateContexts=cc_in) self.assertEqual( |