mirror of
https://github.com/samba-team/samba.git
synced 2025-03-20 22:50:26 +03:00
tests/krb5/raw_testcase.py: Cache obtained credentials
If credentials are used more than once, we can now use the credentials that we already obtained and so avoid fetching them again. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> BUG: https://bugzilla.samba.org/show_bug.cgi?id=14817 (cherry picked from commit 22a90aea82ba6ef86bde835f2369daa6e23ed2fd)
This commit is contained in:
parent
4d72aa9e09
commit
47b6072624
@ -75,6 +75,7 @@ class KDCBaseTest(RawKerberosTest):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls._lp = None
|
||||
cls.host = os.environ["SERVER"]
|
||||
|
||||
|
@ -371,6 +371,14 @@ class RawKerberosTest(TestCaseInTempDir):
|
||||
e = self.etype_test_permutations[idx]
|
||||
return (e['name'], e['etypes'])
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
|
||||
# A dictionary containing credentials that have already been
|
||||
# obtained.
|
||||
cls.creds_dict = {}
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.do_asn1_print = False
|
||||
@ -441,11 +449,11 @@ class RawKerberosTest(TestCaseInTempDir):
|
||||
allow_missing=allow_missing)
|
||||
return val
|
||||
|
||||
def _get_krb5_creds(self, prefix,
|
||||
default_username=None,
|
||||
allow_missing_password=False,
|
||||
allow_missing_keys=True,
|
||||
require_strongest_key=False):
|
||||
def _get_krb5_creds_from_env(self, prefix,
|
||||
default_username=None,
|
||||
allow_missing_password=False,
|
||||
allow_missing_keys=True,
|
||||
require_strongest_key=False):
|
||||
c = KerberosCredentials()
|
||||
c.guess()
|
||||
|
||||
@ -515,6 +523,26 @@ class RawKerberosTest(TestCaseInTempDir):
|
||||
|
||||
return c
|
||||
|
||||
def _get_krb5_creds(self,
|
||||
prefix,
|
||||
default_username=None,
|
||||
allow_missing_password=False,
|
||||
allow_missing_keys=True,
|
||||
require_strongest_key=False):
|
||||
if prefix not in self.creds_dict:
|
||||
# We don't have the credentials already
|
||||
creds = self._get_krb5_creds_from_env(prefix,
|
||||
default_username=default_username,
|
||||
allow_missing_password=allow_missing_password,
|
||||
allow_missing_keys=allow_missing_keys,
|
||||
require_strongest_key=require_strongest_key)
|
||||
self.assertIsNotNone(creds)
|
||||
|
||||
# Save the obtained credentials
|
||||
self.creds_dict[prefix] = creds
|
||||
|
||||
return self.creds_dict[prefix]
|
||||
|
||||
def get_user_creds(self,
|
||||
allow_missing_password=False,
|
||||
allow_missing_keys=True):
|
||||
|
Loading…
x
Reference in New Issue
Block a user