1*7f2fe78bSCy Schubertfrom k5test import * 2*7f2fe78bSCy Schubert 3*7f2fe78bSCy Schubertrealm = K5Realm(create_kdb=False) 4*7f2fe78bSCy Schubert 5*7f2fe78bSCy Schubert# Test err_fmt, using klist -c to induce errors. 6*7f2fe78bSCy Schubertfmt1 = 'FOO Error: %M (see http://localhost:1234/%C for more information)' 7*7f2fe78bSCy Schubertconf1 = {'libdefaults': {'err_fmt': fmt1}} 8*7f2fe78bSCy Schuberte1 = realm.special_env('fmt1', False, krb5_conf=conf1) 9*7f2fe78bSCy Schubertout = realm.run([klist, '-c', 'testdir/xx/yy'], env=e1, expected_code=1) 10*7f2fe78bSCy Schubertif out != ('klist: FOO Error: No credentials cache found (filename: ' 11*7f2fe78bSCy Schubert 'testdir/xx/yy) (see http://localhost:1234/-1765328189 for more ' 12*7f2fe78bSCy Schubert 'information)\n'): 13*7f2fe78bSCy Schubert fail('err_fmt expansion failed') 14*7f2fe78bSCy Schubertconf2 = {'libdefaults': {'err_fmt': '%M - %C'}} 15*7f2fe78bSCy Schuberte2 = realm.special_env('fmt2', False, krb5_conf=conf2) 16*7f2fe78bSCy Schubertout = realm.run([klist, '-c', 'testdir/xx/yy'], env=e2, expected_code=1) 17*7f2fe78bSCy Schubertif out != ('klist: No credentials cache found (filename: testdir/xx/yy) - ' 18*7f2fe78bSCy Schubert '-1765328189\n'): 19*7f2fe78bSCy Schubert fail('err_fmt expansion failed') 20*7f2fe78bSCy Schubertconf3 = {'libdefaults': {'err_fmt': '%%%M %-% %C%'}} 21*7f2fe78bSCy Schuberte3 = realm.special_env('fmt3', False, krb5_conf=conf3) 22*7f2fe78bSCy Schubertout = realm.run([klist, '-c', 'testdir/xx/yy'], env=e3, expected_code=1) 23*7f2fe78bSCy Schubertif out != ('klist: %No credentials cache found (filename: testdir/xx/yy) %-% ' 24*7f2fe78bSCy Schubert '-1765328189%\n'): 25*7f2fe78bSCy Schubert fail('err_fmt expansion failed') 26*7f2fe78bSCy Schubert 27*7f2fe78bSCy Schubertsuccess('error message tests') 28