summaryrefslogtreecommitdiff
path: root/src/tests/gssapi/t_authind.py
blob: 316bc40938015dd3614c0b343023ccb57888d75c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python
from k5test import *

# Test authentication indicators.  Load the test preauth module so we
# can control the indicators asserted.
testpreauth = os.path.join(buildtop, 'plugins', 'preauth', 'test', 'test.so')
conf = {'plugins': {'kdcpreauth': {'module': 'test:' + testpreauth},
                    'clpreauth': {'module': 'test:' + testpreauth}}}
realm = K5Realm(krb5_conf=conf)
realm.run([kadminl, 'addprinc', '-randkey', 'service/1'])
realm.run([kadminl, 'addprinc', '-randkey', 'service/2'])
realm.run([kadminl, 'modprinc', '+requires_preauth', realm.user_princ])
realm.run([kadminl, 'setstr', 'service/1', 'require_auth', 'superstrong'])
realm.run([kadminl, 'setstr', 'service/2', 'require_auth', 'one two'])
realm.run([kadminl, 'xst', 'service/1'])
realm.run([kadminl, 'xst', 'service/2'])

realm.kinit(realm.user_princ, password('user'),
            ['-X', 'indicators=superstrong'])
out = realm.run(['./t_srcattrs', 'p:service/1'])
if ('Attribute auth-indicators Authenticated Complete') not in out:
    fail('Expected attribute type data not seen')
# UTF8 "superstrong"
if '73757065727374726f6e67' not in out:
    fail('Expected auth indicator not seen in name attributes')

out = realm.run(['./t_srcattrs', 'p:service/2'], expected_code=1)
if 'gss_init_sec_context: KDC policy rejects request' not in out:
    fail('Expected error message not seen for indicator mismatch')

realm.kinit(realm.user_princ, password('user'), ['-X', 'indicators=one two'])
out = realm.run(['./t_srcattrs', 'p:service/2'])
# Hexademical "one" and "two"
if '6f6e65' not in out or '74776f' not in out:
    fail('Expected auth indicator not seen in name attributes')

realm.stop()
success('GSSAPI auth indicator tests')