summaryrefslogtreecommitdiff
path: root/python/samba
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2023-11-09 19:52:55 +0100
committerJeremy Allison <jra@samba.org>2023-11-13 18:35:32 +0000
commitf09c5a3dcbb15bb138b6a11eadc04f1bd1d9e3fa (patch)
tree097b0cf99c03e6af96344c6b3970d41f0589255a /python/samba
parent29bb93d03a48c789e71a434eea65f286bd0029bd (diff)
downloadsamba-f09c5a3dcbb15bb138b6a11eadc04f1bd1d9e3fa.tar.gz
samba-f09c5a3dcbb15bb138b6a11eadc04f1bd1d9e3fa.tar.bz2
samba-f09c5a3dcbb15bb138b6a11eadc04f1bd1d9e3fa.zip
python: move clean_file() to samba/tests/libsmb.py
BUG:https://bugzilla.samba.org/show_bug.cgi?id=15517 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'python/samba')
-rw-r--r--python/samba/tests/libsmb.py11
-rw-r--r--python/samba/tests/smb2symlink.py10
2 files changed, 11 insertions, 10 deletions
diff --git a/python/samba/tests/libsmb.py b/python/samba/tests/libsmb.py
index 85068b1caec..cb632d0e3a7 100644
--- a/python/samba/tests/libsmb.py
+++ b/python/samba/tests/libsmb.py
@@ -21,6 +21,7 @@ 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
+from samba import (ntstatus,NTSTATUSError)
import samba.tests
import os
@@ -42,3 +43,13 @@ class LibsmbTests(samba.tests.TestCase):
self.global_inject = os.path.join(server_conf_dir, "global_inject.conf")
self.server_ip = samba.tests.env_get_var_value("SERVER_IP")
+
+ def clean_file(self, conn, filename):
+ try:
+ conn.unlink(filename)
+ except NTSTATUSError as e:
+ if e.args[0] == ntstatus.NT_STATUS_FILE_IS_A_DIRECTORY:
+ conn.rmdir(filename)
+ elif not (e.args[0] == ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND or
+ e.args[0] == ntstatus.NT_STATUS_OBJECT_PATH_NOT_FOUND):
+ raise
diff --git a/python/samba/tests/smb2symlink.py b/python/samba/tests/smb2symlink.py
index 5fca138e82a..83df78e8bb6 100644
--- a/python/samba/tests/smb2symlink.py
+++ b/python/samba/tests/smb2symlink.py
@@ -55,16 +55,6 @@ class Smb2SymlinkTests(samba.tests.libsmb.LibsmbTests):
self.creds)
return (smb1, smb2)
- def clean_file(self, conn, filename):
- try:
- conn.unlink(filename)
- except NTSTATUSError as e:
- if e.args[0] == ntstatus.NT_STATUS_FILE_IS_A_DIRECTORY:
- conn.rmdir(filename)
- elif not (e.args[0] == ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND or
- e.args[0] == ntstatus.NT_STATUS_OBJECT_PATH_NOT_FOUND):
- raise
-
def create_symlink(self, conn, target, symlink):
self.clean_file(conn, symlink)
if (conn.protocol() < libsmb.PROTOCOL_SMB2_02 and conn.have_posix()):