Imported Upstream version 1.20.1
[platform/upstream/krb5.git] / src / tests / t_audit.py
1 from k5test import *
2
3 conf = {'plugins': {'audit': {
4             'module': 'test:$plugins/audit/test/k5audit_test.so'}}}
5
6 realm = K5Realm(krb5_conf=conf, get_creds=False)
7 realm.addprinc('target')
8 realm.run([kadminl, 'modprinc', '+ok_to_auth_as_delegate', realm.host_princ])
9
10 # Make normal AS and TGS requests so they will be audited.
11 realm.kinit(realm.host_princ, flags=['-k', '-f'])
12 realm.run([kvno, 'target'])
13
14 # Make S4U2Self and S4U2Proxy requests so they will be audited.  The
15 # S4U2Proxy request is expected to fail.
16 realm.run([kvno, '-k', realm.keytab, '-U', 'user', '-P', 'target'],
17           expected_code=1, expected_msg='KDC can\'t fulfill requested option')
18
19 # Make a U2U request so it will be audited.
20 uuserver = os.path.join(buildtop, 'appl', 'user_user', 'uuserver')
21 uuclient = os.path.join(buildtop, 'appl', 'user_user', 'uuclient')
22 port_arg = str(realm.server_port())
23 realm.start_server([uuserver, port_arg], 'Server started')
24 realm.run([uuclient, hostname, 'testing message', port_arg],
25           expected_msg='Hello')
26
27 success('Audit tests')