xref: /freebsd/crypto/krb5/src/tests/t_renprinc.py (revision b670c9bafc0e31c7609969bf374b2e80bdc00211)
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
23from k5test import *
24
25enctype = "aes128-cts"
26
27realm = K5Realm(create_host=False, create_user=False)
28salttypes = ('normal', 'norealm', 'onlyrealm')
29
30# For a variety of salt types, test that we can rename a principal and
31# still get tickets with the same password.
32for st in salttypes:
33    realm.run([kadminl, 'addprinc', '-e', enctype + ':' + st,
34               '-pw', password(st), st])
35    realm.kinit(st, password(st))
36    newprinc = 'new' + st
37    realm.run([kadminl, 'renprinc', st, newprinc])
38    realm.kinit(newprinc, password(st))
39
40# Rename the normal salt again to test renaming a principal with
41# special salt type (which it will have after the first rename).
42realm.run([kadminl, 'renprinc', 'newnormal', 'newnormal2'])
43realm.kinit('newnormal2', password('normal'))
44
45success('Principal renaming tests')
46