ticket: 6323
[idra/krb5.git] / src / tests / t_renprinc.py
1 # Copyright (C) 2011 by the Massachusetts Institute of Technology.
2 # All rights reserved.
3
4 # Export of this software from the United States of America may
5 #   require a specific license from the United States Government.
6 #   It is the responsibility of any person or organization contemplating
7 #   export to obtain such a license before exporting.
8 #
9 # WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
10 # distribute this software and its documentation for any purpose and
11 # without fee is hereby granted, provided that the above copyright
12 # notice appear in all copies and that both that copyright notice and
13 # this permission notice appear in supporting documentation, and that
14 # the name of M.I.T. not be used in advertising or publicity pertaining
15 # to distribution of the software without specific, written prior
16 # permission.  Furthermore if you modify this software you must label
17 # your software as modified software and not distribute it in such a
18 # fashion that it might be confused with the original M.I.T. software.
19 # M.I.T. makes no representations about the suitability of
20 # this software for any purpose.  It is provided "as is" without express
21 # or implied warranty.
22
23 #!/usr/bin/python
24 from k5test import *
25
26 enctype = "aes128-cts"
27
28 realm = K5Realm(create_host=False, create_user=False, start_kadmind=False)
29 salttypes = ('normal', 'v4', 'norealm', 'onlyrealm')
30
31 # For a variety of salt types, test that we can rename a principal and
32 # still get tickets with the same password.
33 for st in salttypes:
34     realm.run_kadminl('addprinc -e %s:%s -pw %s %s' %
35                       (enctype, st, password(st), st))
36     realm.kinit(st, password(st))
37     newprinc = 'new' + st
38     realm.run_kadminl('renprinc -force %s %s' % (st, newprinc))
39     realm.kinit(newprinc, password(st))
40
41 # Rename the normal salt again to test renaming a principal with
42 # special salt type (which it will have after the first rename).
43 realm.run_kadminl('renprinc -force newnormal newnormal2')
44 realm.kinit('newnormal2', password('normal'))
45
46 success('Principal renaming tests.')