Blame src/tests/t_errmsg.py

Packit fd8b60
from k5test import *
Packit fd8b60
Packit fd8b60
realm = K5Realm(create_kdb=False)
Packit fd8b60
Packit fd8b60
# Test err_fmt, using klist -c to induce errors.
Packit fd8b60
fmt1 = 'FOO Error: %M (see http://localhost:1234/%C for more information)'
Packit fd8b60
conf1 = {'libdefaults': {'err_fmt': fmt1}}
Packit fd8b60
e1 = realm.special_env('fmt1', False, krb5_conf=conf1)
Packit fd8b60
out = realm.run([klist, '-c', 'testdir/xx/yy'], env=e1, expected_code=1)
Packit fd8b60
if out != ('klist: FOO Error: No credentials cache found (filename: '
Packit fd8b60
           'testdir/xx/yy) (see http://localhost:1234/-1765328189 for more '
Packit fd8b60
           'information)\n'):
Packit fd8b60
    fail('err_fmt expansion failed')
Packit fd8b60
conf2 = {'libdefaults': {'err_fmt': '%M - %C'}}
Packit fd8b60
e2 = realm.special_env('fmt2', False, krb5_conf=conf2)
Packit fd8b60
out = realm.run([klist, '-c', 'testdir/xx/yy'], env=e2, expected_code=1)
Packit fd8b60
if out != ('klist: No credentials cache found (filename: testdir/xx/yy) - '
Packit fd8b60
           '-1765328189\n'):
Packit fd8b60
    fail('err_fmt expansion failed')
Packit fd8b60
conf3 = {'libdefaults': {'err_fmt': '%%%M %-% %C%'}}
Packit fd8b60
e3 = realm.special_env('fmt3', False, krb5_conf=conf3)
Packit fd8b60
out = realm.run([klist, '-c', 'testdir/xx/yy'], env=e3, expected_code=1)
Packit fd8b60
if out != ('klist: %No credentials cache found (filename: testdir/xx/yy) %-% '
Packit fd8b60
           '-1765328189%\n'):
Packit fd8b60
    fail('err_fmt expansion failed')
Packit fd8b60
Packit fd8b60
success('error message tests')