mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
tests/krb5/kdc_base_test.py: Create loadparm only when needed
Now the .conf file is only loaded on its first use, which means that SMB_CONF_PATH need not be defined for tests that don't make use of it. 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:
parent
364f1ce8d8
commit
210e544016
@ -66,7 +66,7 @@ class KDCBaseTest(RawKerberosTest):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cls.lp = cls.get_loadparm(cls)
|
cls._lp = None
|
||||||
cls.host = os.environ["SERVER"]
|
cls.host = os.environ["SERVER"]
|
||||||
|
|
||||||
cls._ldb = None
|
cls._ldb = None
|
||||||
@ -89,15 +89,22 @@ class KDCBaseTest(RawKerberosTest):
|
|||||||
self.do_asn1_print = global_asn1_print
|
self.do_asn1_print = global_asn1_print
|
||||||
self.do_hexdump = global_hexdump
|
self.do_hexdump = global_hexdump
|
||||||
|
|
||||||
|
def get_lp(self):
|
||||||
|
if self._lp is None:
|
||||||
|
type(self)._lp = self.get_loadparm()
|
||||||
|
|
||||||
|
return self._lp
|
||||||
|
|
||||||
def get_samdb(self):
|
def get_samdb(self):
|
||||||
if self._ldb is None:
|
if self._ldb is None:
|
||||||
creds = self.get_user_creds()
|
creds = self.get_user_creds()
|
||||||
|
lp = self.get_lp()
|
||||||
|
|
||||||
session = system_session()
|
session = system_session()
|
||||||
type(self)._ldb = SamDB(url="ldap://%s" % self.host,
|
type(self)._ldb = SamDB(url="ldap://%s" % self.host,
|
||||||
session_info=session,
|
session_info=session,
|
||||||
credentials=creds,
|
credentials=creds,
|
||||||
lp=self.lp)
|
lp=lp)
|
||||||
|
|
||||||
return self._ldb
|
return self._ldb
|
||||||
|
|
||||||
@ -137,7 +144,7 @@ class KDCBaseTest(RawKerberosTest):
|
|||||||
ldb.add(details)
|
ldb.add(details)
|
||||||
|
|
||||||
creds = Credentials()
|
creds = Credentials()
|
||||||
creds.guess(self.lp)
|
creds.guess(self.get_lp())
|
||||||
creds.set_realm(ldb.domain_dns_name().upper())
|
creds.set_realm(ldb.domain_dns_name().upper())
|
||||||
creds.set_domain(ldb.domain_netbios_name().upper())
|
creds.set_domain(ldb.domain_netbios_name().upper())
|
||||||
creds.set_password(password)
|
creds.set_password(password)
|
||||||
@ -607,7 +614,7 @@ class KDCBaseTest(RawKerberosTest):
|
|||||||
creds.set_kerberos_state(MUST_USE_KERBEROS)
|
creds.set_kerberos_state(MUST_USE_KERBEROS)
|
||||||
creds.set_username(user_name, SPECIFIED)
|
creds.set_username(user_name, SPECIFIED)
|
||||||
creds.set_realm(realm)
|
creds.set_realm(realm)
|
||||||
creds.set_named_ccache(cachefile.name, SPECIFIED, self.lp)
|
creds.set_named_ccache(cachefile.name, SPECIFIED, self.get_lp())
|
||||||
|
|
||||||
# Return the credentials along with the cache file.
|
# Return the credentials along with the cache file.
|
||||||
return (creds, cachefile)
|
return (creds, cachefile)
|
||||||
|
@ -71,8 +71,10 @@ class CcacheTests(KDCBaseTest):
|
|||||||
# Authenticate in-process to the machine account using the user's
|
# Authenticate in-process to the machine account using the user's
|
||||||
# cached credentials.
|
# cached credentials.
|
||||||
|
|
||||||
|
lp = self.get_lp()
|
||||||
|
|
||||||
settings = {}
|
settings = {}
|
||||||
settings["lp_ctx"] = self.lp
|
settings["lp_ctx"] = lp
|
||||||
settings["target_hostname"] = mach_name
|
settings["target_hostname"] = mach_name
|
||||||
|
|
||||||
gensec_client = gensec.Security.start_client(settings)
|
gensec_client = gensec.Security.start_client(settings)
|
||||||
@ -80,7 +82,7 @@ class CcacheTests(KDCBaseTest):
|
|||||||
gensec_client.want_feature(gensec.FEATURE_SEAL)
|
gensec_client.want_feature(gensec.FEATURE_SEAL)
|
||||||
gensec_client.start_mech_by_sasl_name("GSSAPI")
|
gensec_client.start_mech_by_sasl_name("GSSAPI")
|
||||||
|
|
||||||
auth_context = AuthContext(lp_ctx=self.lp, ldb=samdb, methods=[])
|
auth_context = AuthContext(lp_ctx=lp, ldb=samdb, methods=[])
|
||||||
|
|
||||||
gensec_server = gensec.Security.start_server(settings, auth_context)
|
gensec_server = gensec.Security.start_server(settings, auth_context)
|
||||||
gensec_server.set_credentials(mach_credentials)
|
gensec_server.set_credentials(mach_credentials)
|
||||||
|
@ -74,7 +74,7 @@ class LdapTests(KDCBaseTest):
|
|||||||
# Connect to the machine account and retrieve the user SID.
|
# Connect to the machine account and retrieve the user SID.
|
||||||
ldb_as_user = SamDB(url="ldap://%s" % mach_name,
|
ldb_as_user = SamDB(url="ldap://%s" % mach_name,
|
||||||
credentials=creds,
|
credentials=creds,
|
||||||
lp=self.lp)
|
lp=self.get_lp())
|
||||||
ldb_res = ldb_as_user.search('',
|
ldb_res = ldb_as_user.search('',
|
||||||
scope=SCOPE_BASE,
|
scope=SCOPE_BASE,
|
||||||
attrs=["tokenGroups"])
|
attrs=["tokenGroups"])
|
||||||
|
@ -62,7 +62,7 @@ class RpcTests(KDCBaseTest):
|
|||||||
# cached credentials.
|
# cached credentials.
|
||||||
|
|
||||||
binding_str = "ncacn_np:%s[\\pipe\\lsarpc]" % mach_name
|
binding_str = "ncacn_np:%s[\\pipe\\lsarpc]" % mach_name
|
||||||
conn = lsa.lsarpc(binding_str, self.lp, creds)
|
conn = lsa.lsarpc(binding_str, self.get_lp(), creds)
|
||||||
|
|
||||||
(account_name, _) = conn.GetUserName(None, None, None)
|
(account_name, _) = conn.GetUserName(None, None, None)
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class SmbTests(KDCBaseTest):
|
|||||||
|
|
||||||
# Connect to a share and retrieve the user SID.
|
# Connect to a share and retrieve the user SID.
|
||||||
s3_lp = s3param.get_context()
|
s3_lp = s3param.get_context()
|
||||||
s3_lp.load(self.lp.configfile)
|
s3_lp.load(self.get_lp().configfile)
|
||||||
|
|
||||||
min_protocol = s3_lp.get("client min protocol")
|
min_protocol = s3_lp.get("client min protocol")
|
||||||
self.addCleanup(s3_lp.set, "client min protocol", min_protocol)
|
self.addCleanup(s3_lp.set, "client min protocol", min_protocol)
|
||||||
|
Loading…
Reference in New Issue
Block a user