python: move clean_file() to samba/tests/libsmb.py
authorRalph Boehme <slow@samba.org>
Thu, 9 Nov 2023 18:52:55 +0000 (19:52 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 13 Nov 2023 18:35:32 +0000 (18:35 +0000)
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>
python/samba/tests/libsmb.py
python/samba/tests/smb2symlink.py

index 85068b1caec6cbbe7c823f83f3e328340e0fb034..cb632d0e3a71a36cc9abdad98301599b1cc68516 100644 (file)
@@ -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
index 5fca138e82a055e05389b8f24d8947ca24cf89a5..83df78e8bb655b4e142be093b96e87827fd64bd5 100644 (file)
@@ -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()):