mirror of
https://github.com/samba-team/samba.git
synced 2025-12-23 00:23:53 +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>
This commit is contained in:
committed by
Stefan Metzmacher
parent
6a77c2b933
commit
22a90aea82
@@ -75,6 +75,7 @@ class KDCBaseTest(RawKerberosTest):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
super().setUpClass()
|
||||||
cls._lp = None
|
cls._lp = None
|
||||||
cls.host = os.environ["SERVER"]
|
cls.host = os.environ["SERVER"]
|
||||||
|
|
||||||
|
|||||||
@@ -371,6 +371,14 @@ class RawKerberosTest(TestCaseInTempDir):
|
|||||||
e = self.etype_test_permutations[idx]
|
e = self.etype_test_permutations[idx]
|
||||||
return (e['name'], e['etypes'])
|
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):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.do_asn1_print = False
|
self.do_asn1_print = False
|
||||||
@@ -441,11 +449,11 @@ class RawKerberosTest(TestCaseInTempDir):
|
|||||||
allow_missing=allow_missing)
|
allow_missing=allow_missing)
|
||||||
return val
|
return val
|
||||||
|
|
||||||
def _get_krb5_creds(self, prefix,
|
def _get_krb5_creds_from_env(self, prefix,
|
||||||
default_username=None,
|
default_username=None,
|
||||||
allow_missing_password=False,
|
allow_missing_password=False,
|
||||||
allow_missing_keys=True,
|
allow_missing_keys=True,
|
||||||
require_strongest_key=False):
|
require_strongest_key=False):
|
||||||
c = KerberosCredentials()
|
c = KerberosCredentials()
|
||||||
c.guess()
|
c.guess()
|
||||||
|
|
||||||
@@ -515,6 +523,26 @@ class RawKerberosTest(TestCaseInTempDir):
|
|||||||
|
|
||||||
return c
|
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,
|
def get_user_creds(self,
|
||||||
allow_missing_password=False,
|
allow_missing_password=False,
|
||||||
allow_missing_keys=True):
|
allow_missing_keys=True):
|
||||||
|
|||||||
Reference in New Issue
Block a user