tests: Work out DOMSID via samdb rather than environs
authorTim Beale <timbeale@catalyst.net.nz>
Thu, 22 Nov 2018 20:46:38 +0000 (09:46 +1300)
committerTim Beale <timbeale@samba.org>
Tue, 27 Nov 2018 02:43:17 +0000 (03:43 +0100)
Not all testenvs have the DOMSID set as an environment variable.
However, it's easy enough to work out from querying the samdb.

This is a slight change in that we use a source4-generated loadparm
to connect to the DB (self.lp is source3-generated, presumably for
some SMB connection dependency).

This change is so we can run the ntacls_backup tests against a DC with
SMBv1 disabled (the restoredc). Note that currently the tests fail in
the smb.SMB() connection in the setUp(), so we can't run them as part
of autobuild just yet (because we can't known-fail test errors).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/ntacls_backup.py

index bb1bc97..0ee044f 100644 (file)
@@ -25,9 +25,8 @@ from samba import samdb
 from samba import ntacls
 
 from samba.auth import system_session
-from samba.param import LoadParm
 from samba.dcerpc import security
-from samba.tests import TestCaseInTempDir
+from samba.tests import TestCaseInTempDir, env_loadparm
 
 
 class NtaclsBackupRestoreTests(TestCaseInTempDir):
@@ -47,21 +46,20 @@ class NtaclsBackupRestoreTests(TestCaseInTempDir):
             os.environ["LOCAL_PATH"], self.service)
 
         self.smb_conf_path = os.environ['SMB_CONF_PATH']
-        self.dom_sid = security.dom_sid(os.environ['DOMSID'])
-
         self.creds = self.insta_creds(template=self.get_credentials())
 
+        self.samdb_conn = samdb.SamDB(
+            url=samdb_url, session_info=system_session(),
+            credentials=self.creds, lp=env_loadparm())
+
+        self.dom_sid = security.dom_sid(self.samdb_conn.get_domain_sid())
+
         # helper will load conf into lp, that's how smbd can find services.
         self.ntacls_helper = ntacls.NtaclsHelper(self.service,
                                                  self.smb_conf_path,
                                                  self.dom_sid)
-
         self.lp = self.ntacls_helper.lp
 
-        self.samdb_conn = samdb.SamDB(
-            url=samdb_url, session_info=system_session(),
-            credentials=self.creds, lp=self.lp)
-
         self.smb_conn = smb.SMB(
             self.server, self.service, lp=self.lp, creds=self.creds)