svn rev #23794: trunk/src/ util/
ghudson@MIT.EDU
ghudson at MIT.EDU
Sun Mar 7 23:39:08 EST 2010
http://src.mit.edu/fisheye/changelog/krb5/?cs=23794
Commit By: ghudson
Log Message:
Add a "make testrealm" target using the Python test framework. As
part of this, expose the environments in K5Realm as attributes so
that test scripts can modify them.
Changed Files:
U trunk/src/Makefile.in
U trunk/src/util/k5test.py
A trunk/src/util/testrealm.py
Modified: trunk/src/Makefile.in
===================================================================
--- trunk/src/Makefile.in 2010-03-08 03:45:06 UTC (rev 23793)
+++ trunk/src/Makefile.in 2010-03-08 04:39:08 UTC (rev 23794)
@@ -624,6 +624,10 @@
$(SHELL) $(srcdir)/t_krbconf
check-prerecurse: fake-install
+# Create a test realm and spawn a shell in an environment pointing to it.
+testrealm: fake-install
+ PYTHONPATH=$(top_srcdir)/util $(PYTHON) $(srcdir)/util/testrealm.py
+
COV_BUILD= cov-build
COV_ANALYZE= cov-analyze
COV_COMMIT= cov-commit-defects --product "$(COV_PRODUCT)" --user "$(COV_USER)" --target "$(COV_TARGET)" --description "$(COV_DESC)"
Modified: trunk/src/util/k5test.py
===================================================================
--- trunk/src/util/k5test.py 2010-03-08 03:45:06 UTC (rev 23793)
+++ trunk/src/util/k5test.py 2010-03-08 04:39:08 UTC (rev 23794)
@@ -281,6 +281,13 @@
credentials for user unless disabled by the realm construction
options.
+* Attributes for the client, server, master, and slave environments.
+ These environments are extensions of os.environ.
+ - realm.env_client
+ - realm.env_server
+ - realm.env_master
+ - realm.env_slave
+
When the test script is run, its behavior can be modified with
command-line flags. These are documented in the --help output.
@@ -654,10 +661,10 @@
self._create_acl()
self._create_dictfile()
- self._env_client = self._make_env('client', False)
- self._env_server = self._make_env('server', False)
- self._env_master = self._make_env('master', True)
- self._env_slave = self._make_env('slave', True)
+ self.env_client = self._make_env('client', False)
+ self.env_server = self._make_env('server', False)
+ self.env_master = self._make_env('master', True)
+ self.env_slave = self._make_env('slave', True)
if create_kdb:
self.create_kdb()
@@ -771,28 +778,28 @@
return env
def run_as_client(self, args, **keywords):
- return _run_cmd(args, self._env_client, **keywords)
+ return _run_cmd(args, self.env_client, **keywords)
def run_as_server(self, args, **keywords):
- return _run_cmd(args, self._env_server, **keywords)
+ return _run_cmd(args, self.env_server, **keywords)
def run_as_master(self, args, **keywords):
- return _run_cmd(args, self._env_master, **keywords)
+ return _run_cmd(args, self.env_master, **keywords)
def run_as_slave(self, args, **keywords):
- return _run_cmd(args, self._env_slave, **keywords)
+ return _run_cmd(args, self.env_slave, **keywords)
def server_port(self):
return self.portbase + 3
def start_server(self, args, sentinel):
- return _start_daemon(args, self._env_server, sentinel)
+ return _start_daemon(args, self.env_server, sentinel)
def start_in_inetd(self, args, port=None):
if not port:
port = self.server_port()
inetd_args = [t_inetd, str(port)] + args
- return _start_daemon(inetd_args, self._env_server, 'Ready!')
+ return _start_daemon(inetd_args, self.env_server, 'Ready!')
def create_kdb(self):
global kdb5_util
@@ -801,7 +808,7 @@
def start_kdc(self):
global krb5kdc
assert(self._kdc_proc is None)
- self._kdc_proc = _start_daemon([krb5kdc, '-n'], self._env_master,
+ self._kdc_proc = _start_daemon([krb5kdc, '-n'], self.env_master,
'starting...')
def stop_kdc(self):
@@ -813,7 +820,7 @@
global krb5kdc
assert(self._kadmind_proc is None)
self._kadmind_proc = _start_daemon([kadmind, '-nofork', '-W'],
- self._env_master, 'starting...')
+ self.env_master, 'starting...')
def stop_kadmind(self):
assert(self._kadmind_proc is not None)
Added: trunk/src/util/testrealm.py
===================================================================
--- trunk/src/util/testrealm.py (rev 0)
+++ trunk/src/util/testrealm.py 2010-03-08 04:39:08 UTC (rev 23794)
@@ -0,0 +1,69 @@
+# Copyright (C) 2010 by the Massachusetts Institute of Technology.
+# All rights reserved.
+
+# Export of this software from the United States of America may
+# require a specific license from the United States Government.
+# It is the responsibility of any person or organization contemplating
+# export to obtain such a license before exporting.
+#
+# WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+# distribute this software and its documentation for any purpose and
+# without fee is hereby granted, provided that the above copyright
+# notice appear in all copies and that both that copyright notice and
+# this permission notice appear in supporting documentation, and that
+# the name of M.I.T. not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Furthermore if you modify this software you must label
+# your software as modified software and not distribute it in such a
+# fashion that it might be confused with the original M.I.T. software.
+# M.I.T. makes no representations about the suitability of
+# this software for any purpose. It is provided "as is" without express
+# or implied warranty.
+
+# Invoked by the testrealm target in the top-level Makefile. Creates
+# a test realm and spawns a shell pointing at it, for convenience of
+# manual testing.
+
+from k5test import *
+
+# A list of directories containing programs in the build tree.
+progpaths = [
+ 'kdc',
+ os.path.join('kadmin', 'server'),
+ os.path.join('kadmin', 'cli'),
+ os.path.join('kadmin', 'dbutil'),
+ os.path.join('kadmin', 'ktutil'),
+ os.path.join('clients', 'kinit'),
+ os.path.join('clients', 'klist'),
+ os.path.join('clients', 'kdestroy'),
+ os.path.join('clients', 'kpasswd'),
+ 'slave'
+]
+
+# Add program directories to the beginning of PATH.
+def supplement_path(env):
+ # Construct prefixes; these will end in a trailing separator.
+ path_prefix = manpath_prefix = ''
+ for dir in progpaths:
+ path_prefix += os.path.join(buildtop, dir) + os.pathsep
+
+ # Assume PATH exists in env for simplicity.
+ env['PATH'] = path_prefix + env['PATH']
+
+realm = K5Realm()
+env = realm.env_master.copy()
+supplement_path(env)
+
+print
+print 'Realm files are in %s' % realm.testdir
+print 'KRB5_CONFIG is %s' % env['KRB5_CONFIG']
+print 'KRB5_KDC_PROFILE is %s' % env['KRB5_KDC_PROFILE']
+print 'KRB5CCNAME is %s' % env['KRB5CCNAME']
+print 'KRB5_KTNAME is %s' % env['KRB5_KTNAME']
+print 'KRB5RCACHEDIR is %s' % env['KRB5RCACHEDIR']
+print 'Password for user is %s' % password('user')
+print 'Password for admin is %s' % password('admin')
+print
+
+subprocess.call([os.getenv('SHELL')], env=env)
+success('Create test krb5 realm.')
More information about the cvs-krb5
mailing list