Fix autoconf 2.70 compatibility
[platform/upstream/krb5.git] / src / tests / t_kprop.py
1 from k5test import *
2
3 conf_replica = {'dbmodules': {'db': {'database_name': '$testdir/db.replica'}}}
4
5 def setup_acl(realm):
6     acl_file = os.path.join(realm.testdir, 'kpropd-acl')
7     acl = open(acl_file, 'w')
8     acl.write(realm.host_princ + '\n')
9     acl.close()
10
11 def check_output(kpropd):
12     output('*** kpropd output follows\n')
13     while True:
14         line = kpropd.stdout.readline()
15         if 'Database load process for full propagation completed' in line:
16             break
17         output('kpropd: ' + line)
18         if 'Rejected connection' in line:
19             fail('kpropd rejected connection from kprop')
20
21 # kprop/kpropd are the only users of krb5_auth_con_initivector, so run
22 # this test over all enctypes to exercise mkpriv cipher state.
23 for realm in multipass_realms(create_user=False):
24     replica = realm.special_env('replica', True, kdc_conf=conf_replica)
25
26     # Set up the kpropd acl file.
27     setup_acl(realm)
28
29     # Create the replica db.
30     dumpfile = os.path.join(realm.testdir, 'dump')
31     realm.run([kdb5_util, 'dump', dumpfile])
32     realm.run([kdb5_util, 'load', dumpfile], replica)
33     realm.run([kdb5_util, 'stash', '-P', 'master'], replica)
34
35     # Make some changes to the master db.
36     realm.addprinc('wakawaka')
37
38     # Start kpropd.
39     kpropd = realm.start_kpropd(replica, ['-d'])
40
41     realm.run([kdb5_util, 'dump', dumpfile])
42     realm.run([kprop, '-f', dumpfile, '-P', str(realm.kprop_port()), hostname])
43     check_output(kpropd)
44
45     realm.run([kadminl, 'listprincs'], replica, expected_msg='wakawaka')
46
47 # default_realm tests follow.
48 # default_realm and domain_realm different than realm.realm (test -r argument).
49 conf_rep2 = {'dbmodules': {'db': {'database_name': '$testdir/db.replica2'}}}
50 krb5_conf_rep2 = {'libdefaults': {'default_realm': 'FOO'},
51                   'domain_realm': {hostname: 'FOO'}}
52 # default_realm and domain_realm map differ.
53 conf_rep3 = {'dbmodules': {'db': {'database_name': '$testdir/db.replica3'}}}
54 krb5_conf_rep3 = {'domain_realm':  {hostname: 'BAR'}}
55
56 realm = K5Realm(create_user=False)
57 replica2 = realm.special_env('replica2', True, kdc_conf=conf_rep2,
58                              krb5_conf=krb5_conf_rep2)
59 replica3 = realm.special_env('replica3', True, kdc_conf=conf_rep3,
60                              krb5_conf=krb5_conf_rep3)
61
62 setup_acl(realm)
63
64 # Create the replica db.
65 dumpfile = os.path.join(realm.testdir, 'dump')
66 realm.run([kdb5_util, 'dump', dumpfile])
67 realm.run([kdb5_util, '-r', realm.realm, 'load', dumpfile], replica2)
68 realm.run([kdb5_util, 'load', dumpfile], replica3)
69
70 # Make some changes to the master db.
71 realm.addprinc('wakawaka')
72
73 # Test override of default_realm with -r realm argument.
74 kpropd = realm.start_kpropd(replica2, ['-r', realm.realm, '-d'])
75 realm.run([kdb5_util, 'dump', dumpfile])
76 realm.run([kprop, '-r', realm.realm, '-f', dumpfile, '-P',
77            str(realm.kprop_port()), hostname])
78 check_output(kpropd)
79 realm.run([kadminl, '-r', realm.realm, 'listprincs'], replica2,
80           expected_msg='wakawaka')
81
82 stop_daemon(kpropd)
83
84 # Test default_realm and domain_realm mismatch.
85 kpropd = realm.start_kpropd(replica3, ['-d'])
86 realm.run([kdb5_util, 'dump', dumpfile])
87 realm.run([kprop, '-f', dumpfile, '-P', str(realm.kprop_port()), hostname])
88 check_output(kpropd)
89 realm.run([kadminl, 'listprincs'], replica3, expected_msg='wakawaka')
90
91 success('kprop tests')