Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/krb5/src/tests/t_errmsg.py
34878 views
1
from k5test import *
2
3
realm = K5Realm(create_kdb=False)
4
5
# Test err_fmt, using klist -c to induce errors.
6
fmt1 = 'FOO Error: %M (see http://localhost:1234/%C for more information)'
7
conf1 = {'libdefaults': {'err_fmt': fmt1}}
8
e1 = realm.special_env('fmt1', False, krb5_conf=conf1)
9
out = realm.run([klist, '-c', 'testdir/xx/yy'], env=e1, expected_code=1)
10
if out != ('klist: FOO Error: No credentials cache found (filename: '
11
'testdir/xx/yy) (see http://localhost:1234/-1765328189 for more '
12
'information)\n'):
13
fail('err_fmt expansion failed')
14
conf2 = {'libdefaults': {'err_fmt': '%M - %C'}}
15
e2 = realm.special_env('fmt2', False, krb5_conf=conf2)
16
out = realm.run([klist, '-c', 'testdir/xx/yy'], env=e2, expected_code=1)
17
if out != ('klist: No credentials cache found (filename: testdir/xx/yy) - '
18
'-1765328189\n'):
19
fail('err_fmt expansion failed')
20
conf3 = {'libdefaults': {'err_fmt': '%%%M %-% %C%'}}
21
e3 = realm.special_env('fmt3', False, krb5_conf=conf3)
22
out = realm.run([klist, '-c', 'testdir/xx/yy'], env=e3, expected_code=1)
23
if out != ('klist: %No credentials cache found (filename: testdir/xx/yy) %-% '
24
'-1765328189%\n'):
25
fail('err_fmt expansion failed')
26
27
success('error message tests')
28
29