Fix autoconf 2.70 compatibility
[platform/upstream/krb5.git] / src / tests / t_changepw.py
1 from k5test import *
2
3 # This file is intended to cover any password-changing mechanism.  For
4 # now it only contains a regression test for #7868.
5
6 realm = K5Realm(create_host=False, get_creds=False, start_kadmind=True)
7
8 # Mark a principal as expired and change its password through kinit.
9 realm.run([kadminl, 'modprinc', '-pwexpire', '1 day ago', 'user'])
10 pwinput = password('user') + '\nabcd\nabcd\n'
11 realm.run([kinit, realm.user_princ], input=pwinput)
12
13 # Do the same thing with FAST, with tracing turned on.
14 realm.run([kadminl, 'modprinc', '-pwexpire', '1 day ago', 'user'])
15 pwinput = 'abcd\nefgh\nefgh\n'
16 tracefile = os.path.join(realm.testdir, 'trace')
17 realm.run(['env', 'KRB5_TRACE=' + tracefile, kinit, '-T', realm.ccache,
18            realm.user_princ], input=pwinput)
19
20 # Read the trace and check that FAST was used when getting the
21 # kadmin/changepw ticket.
22 f = open(tracefile, 'r')
23 trace = f.read()
24 f.close()
25 getting_changepw = fast_used_for_changepw = False
26 for line in trace.splitlines():
27     if 'Getting initial credentials for user@' in line:
28         getting_changepw_ticket = False
29     if 'Setting initial creds service to kadmin/changepw' in line:
30         getting_changepw_ticket = True
31     if getting_changepw_ticket and 'Using FAST' in line:
32         fast_used_for_changepw = True
33 if not fast_used_for_changepw:
34     fail('FAST was not used to get kadmin/changepw ticket')
35
36 success('Password change tests')