summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorTim Beale <timbeale@catalyst.net.nz>2018-09-18 17:23:48 +1200
committerKarolin Seeger <kseeger@samba.org>2018-11-05 12:44:29 +0100
commitc077dfaa6066ea0131ff50e514759fbdbba311cb (patch)
tree4c7787e18bd23b38c5c77cb3cb7a31fe1fa75972 /python
parent1e7520f4e50ab369769d11b7d65a3752d6aeeda5 (diff)
downloadsamba-c077dfaa6066ea0131ff50e514759fbdbba311cb.tar.gz
tests: Add test-case for restore into non-default site
Add a test-case that exercises the new '--site' restore option and ensures the restored DC gets added to the correct site. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13621 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> (cherry picked from commit ad69aaf7e13435111fc990954ff0bc81ed5325c5)
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/domain_backup.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/python/samba/tests/domain_backup.py b/python/samba/tests/domain_backup.py
index 2df360f594d..9ea0106fa90 100644
--- a/python/samba/tests/domain_backup.py
+++ b/python/samba/tests/domain_backup.py
@@ -27,6 +27,7 @@ from samba.auth import system_session
from samba import Ldb, dn_from_dns_name
from samba.netcmd.fsmo import get_fsmo_roleowner
import re
+from samba import sites
def get_prim_dom(secrets_path, lp):
@@ -148,6 +149,32 @@ class DomainBackupBase(SambaToolCmdTest, TestCaseInTempDir):
# assert that we don't find user secrets in the DB
self.check_restored_database(lp, expect_secrets=False)
+ def _test_backup_restore_into_site(self):
+ """Does a backup and restores into a non-default site"""
+
+ # create a new non-default site
+ sitename = "Test-Site-For-Backups"
+ sites.create_site(self.ldb, self.ldb.get_config_basedn(), sitename)
+ self.addCleanup(sites.delete_site, self.ldb,
+ self.ldb.get_config_basedn(), sitename)
+
+ # restore the backup DC into the site we just created
+ backup_file = self.create_backup()
+ self.restore_backup(backup_file, ["--site=" + sitename])
+
+ lp = self.check_restored_smbconf()
+ restored_ldb = self.check_restored_database(lp)
+
+ # check the restored DC was added to the site we created, i.e. there's
+ # an entry matching the new DC sitting underneath the site DN
+ site_dn = "CN={0},CN=Sites,{1}".format(sitename,
+ restored_ldb.get_config_basedn())
+ match_server = "(&(objectClass=server)(cn={0}))".format(self.new_server)
+ res = restored_ldb.search(site_dn, scope=ldb.SCOPE_SUBTREE,
+ expression=match_server)
+ self.assertTrue(len(res) == 1,
+ "Failed to find new DC under site")
+
def create_smbconf(self, settings):
"""Creates a very basic smb.conf to pass to the restore tool"""
@@ -372,6 +399,9 @@ class DomainBackupOnline(DomainBackupBase):
def test_backup_restore_no_secrets(self):
self._test_backup_restore_no_secrets()
+ def test_backup_restore_into_site(self):
+ self._test_backup_restore_into_site()
+
class DomainBackupRename(DomainBackupBase):
@@ -399,6 +429,9 @@ class DomainBackupRename(DomainBackupBase):
def test_backup_restore_no_secrets(self):
self._test_backup_restore_no_secrets()
+ def test_backup_restore_into_site(self):
+ self._test_backup_restore_into_site()
+
def test_backup_invalid_args(self):
"""Checks that rename commands with invalid args are rejected"""