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