summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJoseph Sutton <josephsutton@catalyst.net.nz>2021-03-18 10:52:52 +1300
committerAndrew Bartlett <abartlet@samba.org>2021-03-23 23:38:38 +0000
commitf52e6e5345bd7cf35abe49eb67e9e4ea969493fd (patch)
tree5a3d61d9fafe755c37bbc2eef84109bbc5124729 /python
parent542678908ac9869bca53b83db7c61d53d898c69c (diff)
downloadsamba-f52e6e5345bd7cf35abe49eb67e9e4ea969493fd.tar.gz
netcmd: Add test for an offline backup of nested directories
This test verifies that when performing an offline backup of a domain where one of the directories to be backed up is nested inside another, the contained files are only included once in the backup. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14027 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/domain_backup_offline.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/python/samba/tests/domain_backup_offline.py b/python/samba/tests/domain_backup_offline.py
index 80ccf3bb93b..16d3e7c36f4 100644
--- a/python/samba/tests/domain_backup_offline.py
+++ b/python/samba/tests/domain_backup_offline.py
@@ -21,6 +21,7 @@ import shutil
import tempfile
from samba.tests import BlackboxTestCase
from samba.netcmd import CommandError
+from samba.param import LoadParm
# The backup tests require that a completely clean LoadParm object gets used
# for the restore. Otherwise the same global LP gets re-used, and the LP
@@ -31,6 +32,36 @@ from samba.netcmd import CommandError
# so that we never inadvertently use .runcmd() by accident.
class DomainBackupOfflineCmp(BlackboxTestCase):
+ def test_domain_backup_offline_nested_tdb(self):
+ self.nested_testcase('tdb')
+
+ def test_domain_backup_offline_nested_mdb(self):
+ self.nested_testcase('mdb')
+
+ def nested_testcase(self, backend):
+ self.prov_dir = self.provision(backend)
+ self.extract_dir = None
+
+ src = os.path.join(self.prov_dir, "private")
+ dst = os.path.join(self.prov_dir, "state", "private")
+
+ # Move private directory inside state directory
+ shutil.move(src, dst)
+
+ smbconf = os.path.join(self.prov_dir, "etc", "smb.conf")
+
+ # Update the conf file
+ lp = LoadParm(filename_for_non_global_lp=smbconf)
+ lp.set("private dir", dst)
+ lp.dump(False, smbconf)
+
+ backup_file = self.backup(self.prov_dir)
+
+ # Ensure each file is only present once in the tar file
+ tf = tarfile.open(backup_file)
+ names = tf.getnames()
+ self.assertEqual(len(names), len(set(names)))
+
def test_domain_backup_offline_hard_link_tdb(self):
self.hard_link_testcase('tdb')