From: Jo Sutton Date: Fri, 8 Mar 2024 03:34:49 +0000 (+1300) Subject: tests/krb5: Allow specifying SamDB to use when creating an account X-Git-Tag: tdb-1.4.11~1385 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67457394e423598af7b8aa654628af9b7ecea5ee;p=thirdparty%2Fsamba.git tests/krb5: Allow specifying SamDB to use when creating an account Signed-off-by: Jo Sutton Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/krb5/kdc_base_test.py b/python/samba/tests/krb5/kdc_base_test.py index f7301f4c235..fa3ee15d8d0 100644 --- a/python/samba/tests/krb5/kdc_base_test.py +++ b/python/samba/tests/krb5/kdc_base_test.py @@ -1968,6 +1968,7 @@ class KDCBaseTest(TestCaseInTempDir, RawKerberosTest): def get_cached_creds(self, *, account_type: AccountType, opts: Optional[dict]=None, + samdb: Optional[SamDB]=None, use_cache=True) -> KerberosCredentials: if opts is None: opts = {} @@ -2013,18 +2014,22 @@ class KDCBaseTest(TestCaseInTempDir, RawKerberosTest): } if use_cache: + self.assertIsNone(samdb) cache_key = tuple(sorted(account_opts.items())) creds = self.account_cache.get(cache_key) if creds is not None: return creds - creds = self.create_account_opts(use_cache, **account_opts) + creds = self.create_account_opts(samdb, use_cache, **account_opts) if use_cache: self.account_cache[cache_key] = creds return creds - def create_account_opts(self, use_cache, *, + def create_account_opts(self, + samdb: Optional[SamDB], + use_cache, + *, account_type, name_prefix, name_suffix, @@ -2064,7 +2069,8 @@ class KDCBaseTest(TestCaseInTempDir, RawKerberosTest): else: self.assertFalse(not_delegated) - samdb = self.get_samdb() + if samdb is None: + samdb = self.get_samdb() user_name = self.get_new_username() if name_prefix is not None: