diff options
author | Greg Hudson <ghudson@mit.edu> | 2012-04-26 04:34:15 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2012-04-26 04:34:15 +0000 |
commit | 60e01dc17967479f31a3669d2a5ef306d1b48750 (patch) | |
tree | 057ab22e2a3c9b974c957d10984b3a4b4f253dac /src/util/k5test.py | |
parent | d85fbcebd2d4880972e8565a3d5aba492ef59431 (diff) | |
download | krb5-60e01dc17967479f31a3669d2a5ef306d1b48750.tar.gz krb5-60e01dc17967479f31a3669d2a5ef306d1b48750.tar.xz krb5-60e01dc17967479f31a3669d2a5ef306d1b48750.zip |
Add k5test.py helpers for running kadmin
Add K5Realm.prep_kadmin() to create a ccache and K5Realm.run_kadmin()
to run a kadmin query using it. Modify t_stringattr.py to use these
helpers instead of its own.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25826 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/k5test.py')
-rw-r--r-- | src/util/k5test.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/util/k5test.py b/src/util/k5test.py index 0d04052909..6097c9be96 100644 --- a/src/util/k5test.py +++ b/src/util/k5test.py @@ -279,6 +279,15 @@ Scripts may use the following realm methods and attributes: * realm.run_kadminl(query): Run the specified query in kadmin.local. +* realm.prep_kadmin(princname=None, password=None, flags=[]): Populate + realm.kadmin_ccache with a ticket which can be used to run kadmin. + If princname is not specified, realm.admin_princ and its default + password will be used. + +* realm.run_kadmin(query, **keywords): Run the specified query in + kadmin, using realm.kadmin_ccache to authenticate. Accepts the same + keyword arguments as run_as_client. + * realm.realm: The realm's name. * realm.testdir: The realm's storage directory (absolute path). @@ -301,6 +310,9 @@ Scripts may use the following realm methods and attributes: credentials for user unless disabled by the realm construction options. +* realm.kadmin_ccache: The ccache file initialized by prep_kadmin and + used by run_kadmin. + * Attributes for the client, server, master, and slave environments. These environments are extensions of os.environ. - realm.env_client @@ -689,6 +701,7 @@ class K5Realm(object): self.krbtgt_princ = 'krbtgt/%s@%s' % (self.realm, self.realm) self.keytab = os.path.join(self.testdir, 'keytab') self.ccache = os.path.join(self.testdir, 'ccache') + self.kadmin_ccache = os.path.join(self.testdir, 'kadmin_ccache') self._krb5_conf = _cfg_merge(_default_krb5_conf, krb5_conf) self._kdc_conf = _cfg_merge(_default_kdc_conf, kdc_conf) self._kdc_proc = None @@ -917,6 +930,18 @@ class K5Realm(object): global kadmin_local return self.run_as_master([kadmin_local, '-q', query]) + def prep_kadmin(self, princname=None, pw=None, flags=[]): + if princname is None: + princname = self.admin_princ + pw = password('admin') + return self.kinit(princname, pw, + flags=['-S', 'kadmin/admin', + '-c', self.kadmin_ccache] + flags) + + def run_kadmin(self, query, **keywords): + return self.run_as_client([kadmin, '-c', self.kadmin_ccache, + '-q', query], **keywords) + def multipass_realms(**keywords): global _current_pass, _passes, testpass |