diff options
author | Greg Hudson <ghudson@mit.edu> | 2012-12-16 16:55:29 -0500 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2012-12-20 11:45:20 -0500 |
commit | 966547dfeb011800d4b78b8e5d494813bc80559c (patch) | |
tree | 4226bd168056336c965a4aa77c845093ef723da3 /src/tests/t_ccache.py | |
parent | 76c27cf7e3161e0f20f8935d82ae0f2feb77b01a (diff) | |
download | krb5-966547dfeb011800d4b78b8e5d494813bc80559c.tar.gz krb5-966547dfeb011800d4b78b8e5d494813bc80559c.tar.xz krb5-966547dfeb011800d4b78b8e5d494813bc80559c.zip |
Simplify k5test.py environments
The initial k5test.py design, copied from the dejagnu suite, is to
create config files and environments for four expected roles: client,
server, master, and slave. This approach exaggerates the complexity
of the common case, where the configurations don't need to vary, and
limits us to having just one slave for kprop/iprop tests.
Instead, create just one configuration by default, and add a
special_env() method which sets up a differently configured
environment for the few test cases which need one. The run_as_*()
methods are collapsed into just run(), which accepts an optional
argument for the environment returned by special_env().
Diffstat (limited to 'src/tests/t_ccache.py')
-rw-r--r-- | src/tests/t_ccache.py | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/tests/t_ccache.py b/src/tests/t_ccache.py index e85d009dde..a761d48fbe 100644 --- a/src/tests/t_ccache.py +++ b/src/tests/t_ccache.py @@ -26,66 +26,65 @@ from k5test import * realm = K5Realm(create_host=False) # Test kdestroy and klist of a non-existent ccache. -realm.run_as_client([kdestroy]) -output = realm.run_as_client([klist], expected_code=1) +realm.run([kdestroy]) +output = realm.run([klist], expected_code=1) if 'No credentials cache found' not in output: fail('Expected error message not seen in klist output') # Make a directory collection and use it for client commands. ccname = 'DIR:' + os.path.join(realm.testdir, 'cc') -realm.env_client['KRB5CCNAME'] = ccname +realm.env['KRB5CCNAME'] = ccname realm.addprinc('alice', password('alice')) realm.addprinc('bob', password('bob')) realm.addprinc('carol', password('carol')) realm.kinit('alice', password('alice')) -output = realm.run_as_client([klist]) +output = realm.run([klist]) if 'Default principal: alice@' not in output: fail('Initial kinit failed to get credentials for alice.') -realm.run_as_client([kdestroy]) -output = realm.run_as_client([klist], expected_code=1) +realm.run([kdestroy]) +output = realm.run([klist], expected_code=1) if 'No credentials cache found' not in output: fail('Initial kdestroy failed to destroy primary cache.') -output = realm.run_as_client([klist, '-l'], expected_code=1) +output = realm.run([klist, '-l'], expected_code=1) if not output.endswith('---\n') or output.count('\n') != 2: fail('Initial kdestroy failed to empty cache collection.') realm.kinit('alice', password('alice')) realm.kinit('carol', password('carol')) -output = realm.run_as_client([klist, '-l']) +output = realm.run([klist, '-l']) if '---\ncarol@' not in output or '\nalice@' not in output: fail('klist -l did not show expected output after two kinits.') realm.kinit('alice', password('alice')) -output = realm.run_as_client([klist, '-l']) +output = realm.run([klist, '-l']) if '---\nalice@' not in output or output.count('\n') != 4: fail('klist -l did not show expected output after re-kinit for alice.') realm.kinit('bob', password('bob')) -output = realm.run_as_client([klist, '-A']) +output = realm.run([klist, '-A']) if 'bob@' not in output.splitlines()[1] or 'alice@' not in output or \ 'carol' not in output or output.count('Default principal:') != 3: fail('klist -A did not show expected output after kinit for bob.') -realm.run_as_client([kswitch, '-p', 'carol']) -output = realm.run_as_client([klist, '-l']) +realm.run([kswitch, '-p', 'carol']) +output = realm.run([klist, '-l']) if '---\ncarol@' not in output or output.count('\n') != 5: fail('klist -l did not show expected output after kswitch to carol.') -realm.run_as_client([kdestroy]) -output = realm.run_as_client([klist, '-l']) +realm.run([kdestroy]) +output = realm.run([klist, '-l']) if 'carol@' in output or 'bob@' not in output or output.count('\n') != 4: fail('kdestroy failed to remove only primary ccache.') -realm.run_as_client([kdestroy, '-A']) -output = realm.run_as_client([klist, '-l'], expected_code=1) +realm.run([kdestroy, '-A']) +output = realm.run([klist, '-l'], expected_code=1) if not output.endswith('---\n') or output.count('\n') != 2: fail('kdestroy -a failed to empty cache collection.') # Test parameter expansion in default_ccache_name realm.stop() -conf = {'client': {'libdefaults': { - 'default_ccache_name': 'testdir/%{null}abc%{uid}'}}} +conf = {'libdefaults': {'default_ccache_name': 'testdir/%{null}abc%{uid}'}} realm = K5Realm(krb5_conf=conf, create_kdb=False) -del realm.env_client['KRB5CCNAME'] +del realm.env['KRB5CCNAME'] uidstr = str(os.getuid()) -out = realm.run_as_client([klist], expected_code=1) +out = realm.run([klist], expected_code=1) if 'FILE:testdir/abc%s' % uidstr not in out: fail('Wrong ccache in klist') |